Sit bug fixes

* You should not be able to move after being seated, even if you switch seats.
* You should not be able to jump out of the chair by holding the space bar.
* Fixed small issue with the sitting to standing transition being delayed. (causing the user to look
  like there were sitting in mid-air)  This was due to a missing transition in the animation.json
This commit is contained in:
Anthony J. Thibault 2019-09-17 13:40:43 -07:00
parent dd0b527d63
commit 1157d59f67
3 changed files with 31 additions and 18 deletions

View file

@ -4598,6 +4598,10 @@
{ {
"state": "strafeLeftHmd", "state": "strafeLeftHmd",
"var": "isMovingLeftHmd" "var": "isMovingLeftHmd"
},
{
"state": "idle",
"var": "isNotSeated"
} }
] ]
}, },

View file

@ -4374,8 +4374,15 @@ float MyAvatar::getRawDriveKey(DriveKeys key) const {
} }
void MyAvatar::relayDriveKeysToCharacterController() { void MyAvatar::relayDriveKeysToCharacterController() {
if (getDriveKey(TRANSLATE_Y) > 0.0f && (!qApp->isHMDMode() || (useAdvancedMovementControls() && getFlyingHMDPref()))) { if (_endSitKeyPressComplete) {
_characterController.jump(); if (getDriveKey(TRANSLATE_Y) > 0.0f && (!qApp->isHMDMode() || (useAdvancedMovementControls() && getFlyingHMDPref()))) {
_characterController.jump();
}
} else {
// used to prevent character from jumping after endSit is called.
if (getDriveKey(TRANSLATE_Y) == 0.0f) {
_endSitKeyPressComplete = true;
}
} }
} }
@ -6255,15 +6262,17 @@ void MyAvatar::beginSit(const glm::vec3& position, const glm::quat& rotation) {
return; return;
} }
_characterController.setSeated(true); if (!_characterController.getSeated()) {
setCollisionsEnabled(false); _characterController.setSeated(true);
setHMDLeanRecenterEnabled(false); setCollisionsEnabled(false);
// Disable movement setHMDLeanRecenterEnabled(false);
setSitDriveKeysStatus(false); // Disable movement
centerBody(); setSitDriveKeysStatus(false);
int hipIndex = getJointIndex("Hips"); centerBody();
clearPinOnJoint(hipIndex); int hipIndex = getJointIndex("Hips");
pinJoint(hipIndex, position, rotation); clearPinOnJoint(hipIndex);
pinJoint(hipIndex, position, rotation);
}
} }
void MyAvatar::endSit(const glm::vec3& position, const glm::quat& rotation) { void MyAvatar::endSit(const glm::vec3& position, const glm::quat& rotation) {
@ -6281,12 +6290,9 @@ void MyAvatar::endSit(const glm::vec3& position, const glm::quat& rotation) {
slamPosition(position); slamPosition(position);
setWorldOrientation(rotation); setWorldOrientation(rotation);
// the jump key is used to exit the chair. We add a delay here to prevent // used to prevent character from jumping after endSit is called.
// the avatar from jumping right as they exit the chair. _endSitKeyPressComplete = false;
float TIME_BEFORE_DRIVE_ENABLED_MS = 150.0f;
QTimer::singleShot(TIME_BEFORE_DRIVE_ENABLED_MS, [this]() { setSitDriveKeysStatus(true);
// Enable movement again
setSitDriveKeysStatus(true);
});
} }
} }

View file

@ -2903,6 +2903,9 @@ private:
int _reactionEnabledRefCounts[NUM_AVATAR_BEGIN_END_REACTIONS] { 0, 0, 0 }; int _reactionEnabledRefCounts[NUM_AVATAR_BEGIN_END_REACTIONS] { 0, 0, 0 };
mutable std::mutex _reactionLock; mutable std::mutex _reactionLock;
// used to prevent character from jumping after endSit is called.
bool _endSitKeyPressComplete { false };
}; };
QScriptValue audioListenModeToScriptValue(QScriptEngine* engine, const AudioListenerMode& audioListenerMode); QScriptValue audioListenModeToScriptValue(QScriptEngine* engine, const AudioListenerMode& audioListenerMode);