mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-09 21:32:31 +02:00
CR drive keys
This commit is contained in:
parent
3e9474e878
commit
42316e713d
3 changed files with 77 additions and 15 deletions
|
@ -2091,8 +2091,27 @@ bool MyAvatar::getCharacterControllerEnabled() {
|
|||
}
|
||||
|
||||
void MyAvatar::clearDriveKeys() {
|
||||
for (int i = 0; i < MAX_DRIVE_KEYS; ++i) {
|
||||
setDriveKey(i, 0.0f);
|
||||
_driveKeys.fill(0.0f);
|
||||
}
|
||||
|
||||
void MyAvatar::setDriveKey(int key, float val) {
|
||||
try {
|
||||
_driveKeys.at(key) = val;
|
||||
} catch (const std::exception& exception) {
|
||||
qCCritical(interfaceapp) << Q_FUNC_INFO << ": Index out of bounds";
|
||||
}
|
||||
}
|
||||
|
||||
float MyAvatar::getDriveKey(int key) const {
|
||||
return isDriveKeyDisabled(key) ? 0.0f : getRawDriveKey(key);
|
||||
}
|
||||
|
||||
float MyAvatar::getRawDriveKey(int key) const {
|
||||
try {
|
||||
return _driveKeys.at(key);
|
||||
} catch (const std::exception& exception) {
|
||||
qCCritical(interfaceapp) << Q_FUNC_INFO << ": Index out of bounds";
|
||||
return 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2102,6 +2121,51 @@ void MyAvatar::relayDriveKeysToCharacterController() {
|
|||
}
|
||||
}
|
||||
|
||||
void MyAvatar::disableDriveKey(int key) {
|
||||
try {
|
||||
_disabledDriveKeys.set(key);
|
||||
} catch (const std::exception& exception) {
|
||||
qCCritical(interfaceapp) << Q_FUNC_INFO << ": Index out of bounds";
|
||||
}
|
||||
}
|
||||
|
||||
void MyAvatar::enableDriveKey(int key) {
|
||||
try {
|
||||
_disabledDriveKeys.reset(key);
|
||||
} catch (const std::exception& exception) {
|
||||
qCCritical(interfaceapp) << Q_FUNC_INFO << ": Index out of bounds";
|
||||
}
|
||||
}
|
||||
|
||||
void MyAvatar::disableDriveKeys(std::vector<int> key) {
|
||||
try {
|
||||
std::for_each(std::begin(key), std::end(key), [&](int val){
|
||||
_disabledDriveKeys.set(val);
|
||||
});
|
||||
} catch (const std::exception& exception) {
|
||||
qCCritical(interfaceapp) << Q_FUNC_INFO << ": Index out of bounds";
|
||||
}
|
||||
}
|
||||
|
||||
void MyAvatar::enableDriveKeys(std::vector<int> key) {
|
||||
try {
|
||||
std::for_each(std::begin(key), std::end(key), [&](int val) {
|
||||
_disabledDriveKeys.reset(val);
|
||||
});
|
||||
} catch (const std::exception& exception) {
|
||||
qCCritical(interfaceapp) << Q_FUNC_INFO << ": Index out of bounds";
|
||||
}
|
||||
}
|
||||
|
||||
bool MyAvatar::isDriveKeyDisabled(int key) const {
|
||||
try {
|
||||
return _disabledDriveKeys.test(key);
|
||||
} catch (const std::exception& exception) {
|
||||
qCCritical(interfaceapp) << Q_FUNC_INFO << ": Index out of bounds";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
glm::vec3 MyAvatar::getWorldBodyPosition() const {
|
||||
return transformPoint(_sensorToWorldMatrix, extractTranslation(_bodySensorMatrix));
|
||||
}
|
||||
|
|
|
@ -182,14 +182,16 @@ public:
|
|||
|
||||
// Set what driving keys are being pressed to control thrust levels
|
||||
void clearDriveKeys();
|
||||
void setDriveKey(int key, float val) { _driveKeys[key] = val; };
|
||||
float getDriveKey(int key) const { return isDriveKeyDisabled(key) ? 0.0f : _driveKeys[key]; };
|
||||
Q_INVOKABLE float getRawDriveKey(int key) const { return _driveKeys[key]; };
|
||||
void setDriveKey(int key, float val);
|
||||
float getDriveKey(int key) const;
|
||||
Q_INVOKABLE float getRawDriveKey(int key) const;
|
||||
void relayDriveKeysToCharacterController();
|
||||
|
||||
Q_INVOKABLE void disableDriveKey(int key) { _disabledDriveKeys.set(key); }
|
||||
Q_INVOKABLE void enableDriveKey(int key) { _disabledDriveKeys.reset(key); }
|
||||
Q_INVOKABLE bool isDriveKeyDisabled(int key) const { return _disabledDriveKeys.test(key); }
|
||||
Q_INVOKABLE void disableDriveKey(int key);
|
||||
Q_INVOKABLE void enableDriveKey(int key);
|
||||
Q_INVOKABLE void disableDriveKeys(std::vector<int> key);
|
||||
Q_INVOKABLE void enableDriveKeys(std::vector<int> key);
|
||||
Q_INVOKABLE bool isDriveKeyDisabled(int key) const;
|
||||
|
||||
eyeContactTarget getEyeContactTarget();
|
||||
|
||||
|
@ -395,7 +397,7 @@ private:
|
|||
void clampScaleChangeToDomainLimits(float desiredScale);
|
||||
glm::mat4 computeCameraRelativeHandControllerMatrix(const glm::mat4& controllerSensorMatrix) const;
|
||||
|
||||
float _driveKeys[MAX_DRIVE_KEYS];
|
||||
std::array<float, MAX_DRIVE_KEYS> _driveKeys;
|
||||
std::bitset<MAX_DRIVE_KEYS> _disabledDriveKeys;
|
||||
|
||||
bool _wasPushing;
|
||||
|
|
|
@ -125,18 +125,14 @@
|
|||
return { headType: 0 };
|
||||
}, ["headType"]);
|
||||
Script.update.connect(this, this.update);
|
||||
for (var i in OVERRIDEN_DRIVE_KEYS) {
|
||||
MyAvatar.disableDriveKey(OVERRIDEN_DRIVE_KEYS[i]);
|
||||
}
|
||||
MyAvatar.disableDriveKey(OVERRIDEN_DRIVE_KEYS);
|
||||
}
|
||||
|
||||
this.standUp = function() {
|
||||
print("Standing up (" + this.entityID + ")");
|
||||
MyAvatar.removeAnimationStateHandler(this.animStateHandlerID);
|
||||
Script.update.disconnect(this, this.update);
|
||||
for (var i in OVERRIDEN_DRIVE_KEYS) {
|
||||
MyAvatar.enableDriveKey(OVERRIDEN_DRIVE_KEYS[i]);
|
||||
}
|
||||
MyAvatar.enableDriveKey(OVERRIDEN_DRIVE_KEYS);
|
||||
|
||||
this.setSeatUser(null);
|
||||
if (Settings.getValue(SETTING_KEY) === this.entityID) {
|
||||
|
|
Loading…
Reference in a new issue