diff --git a/interface/src/avatar/Avatar.cpp b/interface/src/avatar/Avatar.cpp index a9bd4e2f39..cab6e9f1df 100755 --- a/interface/src/avatar/Avatar.cpp +++ b/interface/src/avatar/Avatar.cpp @@ -205,16 +205,25 @@ void Avatar::simulate(float deltaTime, Transmitter* transmitter) { enableHandMovement &= (it->jointID != AVATAR_JOINT_RIGHT_WRIST); } - // update avatar skeleton - _skeleton.update(deltaTime, getOrientation(), _position); - - - // if this is not my avatar, then hand position comes from transmitted data - _skeleton.joint[ AVATAR_JOINT_RIGHT_FINGERTIPS ].position = _handPosition; - //update the movement of the hand and process handshaking with other avatars... updateHandMovementAndTouching(deltaTime, enableHandMovement); + // use speed and angular velocity to determine walking vs. standing + if (_speed + fabs(_bodyYawDelta) > 0.2) { + _mode = AVATAR_MODE_WALKING; + } else { + _mode = AVATAR_MODE_INTERACTING; + } + + // update position by velocity, and subtract the change added earlier for gravity + _position += _velocity * deltaTime; + + // update avatar skeleton + _skeleton.update(deltaTime, getOrientation(), _position); + + // if this is not my avatar, then hand position comes from transmitted data + _skeleton.joint[ AVATAR_JOINT_RIGHT_FINGERTIPS ].position = _handPosition; + _hand.simulate(deltaTime, false); _skeletonModel.simulate(deltaTime); _head.setBodyRotation(glm::vec3(_bodyPitch, _bodyYaw, _bodyRoll)); @@ -225,15 +234,6 @@ void Avatar::simulate(float deltaTime, Transmitter* transmitter) { _head.setSkinColor(glm::vec3(SKIN_COLOR[0], SKIN_COLOR[1], SKIN_COLOR[2])); _head.simulate(deltaTime, false); - // use speed and angular velocity to determine walking vs. standing - if (_speed + fabs(_bodyYawDelta) > 0.2) { - _mode = AVATAR_MODE_WALKING; - } else { - _mode = AVATAR_MODE_INTERACTING; - } - - // update position by velocity, and subtract the change added earlier for gravity - _position += _velocity * deltaTime; // Zero thrust out now that we've added it to velocity in this frame _thrust = glm::vec3(0, 0, 0); diff --git a/interface/src/avatar/Avatar.h b/interface/src/avatar/Avatar.h index 2e3f9d001b..c435191a18 100755 --- a/interface/src/avatar/Avatar.h +++ b/interface/src/avatar/Avatar.h @@ -205,7 +205,6 @@ protected: SkeletonModel _skeletonModel; bool _ballSpringsInitialized; float _bodyYawDelta; - //AvatarBall _bodyBall[ NUM_AVATAR_BODY_BALLS ]; AvatarMode _mode; glm::vec3 _velocity; glm::vec3 _thrust; diff --git a/interface/src/avatar/MyAvatar.cpp b/interface/src/avatar/MyAvatar.cpp index 732ca58939..c65c6d50a3 100644 --- a/interface/src/avatar/MyAvatar.cpp +++ b/interface/src/avatar/MyAvatar.cpp @@ -136,10 +136,6 @@ void MyAvatar::simulate(float deltaTime, Transmitter* transmitter) { enableHandMovement &= (it->jointID != AVATAR_JOINT_RIGHT_WRIST); } - // update avatar skeleton - _skeleton.update(deltaTime, getOrientation(), _position); - - // update the movement of the hand and process handshaking with other avatars... updateHandMovementAndTouching(deltaTime, enableHandMovement); @@ -209,7 +205,10 @@ void MyAvatar::simulate(float deltaTime, Transmitter* transmitter) { } else { applyDamping(deltaTime, _velocity, linearDamping, SQUARED_DAMPING_STRENGTH); } - + + // update the euler angles + setOrientation(orientation); + // Compute instantaneous acceleration float forwardAcceleration = glm::length(glm::dot(getBodyFrontDirection(), getVelocity() - oldVelocity)) / deltaTime; const float ACCELERATION_PITCH_DECAY = 0.4f; @@ -243,16 +242,6 @@ void MyAvatar::simulate(float deltaTime, Transmitter* transmitter) { } } - _hand.simulate(deltaTime, true); - _skeletonModel.simulate(deltaTime); - _head.setBodyRotation(glm::vec3(_bodyPitch, _bodyYaw, _bodyRoll)); - glm::vec3 headPosition; - _skeletonModel.getHeadPosition(headPosition); - _head.setPosition(headPosition); - _head.setScale(_scale); - _head.setSkinColor(glm::vec3(SKIN_COLOR[0], SKIN_COLOR[1], SKIN_COLOR[2])); - _head.simulate(deltaTime, true); - const float WALKING_SPEED_THRESHOLD = 0.2f; // use speed and angular velocity to determine walking vs. standing if (_speed + fabs(_bodyYawDelta) > WALKING_SPEED_THRESHOLD) { @@ -284,6 +273,18 @@ void MyAvatar::simulate(float deltaTime, Transmitter* transmitter) { _position += _velocity * deltaTime; + // update avatar skeleton and simulate hand and head + _skeleton.update(deltaTime, getOrientation(), _position); + _hand.simulate(deltaTime, true); + _skeletonModel.simulate(deltaTime); + _head.setBodyRotation(glm::vec3(_bodyPitch, _bodyYaw, _bodyRoll)); + glm::vec3 headPosition; + _skeletonModel.getHeadPosition(headPosition); + _head.setPosition(headPosition); + _head.setScale(_scale); + _head.setSkinColor(glm::vec3(SKIN_COLOR[0], SKIN_COLOR[1], SKIN_COLOR[2])); + _head.simulate(deltaTime, true); + // Zero thrust out now that we've added it to velocity in this frame _thrust = glm::vec3(0, 0, 0);