From 6e4d1bde8eda25f558a5371b4ef37cd931f02b4a Mon Sep 17 00:00:00 2001 From: luiscuenca Date: Wed, 24 Jul 2019 13:16:53 -0700 Subject: [PATCH] Fix code and warnings --- interface/src/avatar/MyAvatar.cpp | 29 ++++++++----------- interface/src/avatar/MyAvatar.h | 1 - libraries/physics/src/CharacterController.cpp | 7 ++++- libraries/physics/src/CharacterController.h | 1 + 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/interface/src/avatar/MyAvatar.cpp b/interface/src/avatar/MyAvatar.cpp index 11e2434237..9491ce67cd 100644 --- a/interface/src/avatar/MyAvatar.cpp +++ b/interface/src/avatar/MyAvatar.cpp @@ -6227,10 +6227,6 @@ void MyAvatar::setSitDriveKeysStatus(bool enabled) { } void MyAvatar::beginSit(const glm::vec3& position, const glm::quat& rotation) { - const QString ANIMATION_URL = PathUtils::defaultScriptsLocation().toString() + "/resources/animations/sittingIdle.fbx"; - const int ANIMATION_FPS = 30; - const int ANIMATION_FIRST_FRAME = 1; - const int ANIMATION_LAST_FRAME = 350; _characterController.setSeated(true); setCollisionsEnabled(false); setHMDLeanRecenterEnabled(false); @@ -6241,20 +6237,19 @@ void MyAvatar::beginSit(const glm::vec3& position, const glm::quat& rotation) { clearPinOnJoint(hipIndex); goToLocation(position, true, rotation, false, false); pinJoint(hipIndex, position, rotation); - _isSeated = true; } void MyAvatar::endSit(const glm::vec3& position, const glm::quat& rotation) { - clearPinOnJoint(getJointIndex("Hips")); - _characterController.setSeated(false); - _characterController.updateState(); - setCollisionsEnabled(true); - setHMDLeanRecenterEnabled(true); - centerBody(); - float STANDUP_BUMP = 0.225f; - glm::vec3 currentPosition = getWorldPosition(); - currentPosition.y = currentPosition.y + STANDUP_BUMP; - setWorldPosition(currentPosition); - // Enable movement again - setSitDriveKeysStatus(true); + if (_characterController.getSeated()) { + clearPinOnJoint(getJointIndex("Hips")); + _characterController.setSeated(false); + setCollisionsEnabled(true); + setHMDLeanRecenterEnabled(true); + centerBody(); + setWorldPosition(position); + setWorldOrientation(rotation); + // Enable movement again + setSitDriveKeysStatus(true); + } + } \ No newline at end of file diff --git a/interface/src/avatar/MyAvatar.h b/interface/src/avatar/MyAvatar.h index d952136e8e..db373c6402 100644 --- a/interface/src/avatar/MyAvatar.h +++ b/interface/src/avatar/MyAvatar.h @@ -2554,7 +2554,6 @@ private: bool _isBeingPushed { false }; bool _isBraking { false }; bool _isAway { false }; - bool _isSeated { false }; float _boomLength { ZOOM_DEFAULT }; float _yawSpeed; // degrees/sec diff --git a/libraries/physics/src/CharacterController.cpp b/libraries/physics/src/CharacterController.cpp index 0eb5e29e94..e36f97b425 100755 --- a/libraries/physics/src/CharacterController.cpp +++ b/libraries/physics/src/CharacterController.cpp @@ -806,7 +806,7 @@ void CharacterController::updateState() { } break; } - case State::Hover: + case State::Hover: { btScalar horizontalSpeed = (velocity - velocity.dot(_currentUp) * _currentUp).length(); bool flyingFast = horizontalSpeed > (MAX_WALKING_SPEED * 0.75f); if (!_zoneFlyingAllowed) { @@ -819,6 +819,11 @@ void CharacterController::updateState() { SET_STATE(State::Ground, "touching ground"); } break; + } + case State::Seated: { + SET_STATE(State::Ground, "Standing up"); + break; + } } } } diff --git a/libraries/physics/src/CharacterController.h b/libraries/physics/src/CharacterController.h index 3dafcda219..8c65310ff1 100755 --- a/libraries/physics/src/CharacterController.h +++ b/libraries/physics/src/CharacterController.h @@ -137,6 +137,7 @@ public: void setPendingFlagsUpdateCollisionMask(){ _pendingFlags |= PENDING_FLAG_UPDATE_COLLISION_MASK; } void setSeated(bool isSeated) { _isSeated = isSeated; } + bool getSeated() { return _isSeated; } protected: #ifdef DEBUG_STATE_CHANGE