diff --git a/interface/src/avatar/Hand.cpp b/interface/src/avatar/Hand.cpp index 201b332a8c..e5be719b40 100644 --- a/interface/src/avatar/Hand.cpp +++ b/interface/src/avatar/Hand.cpp @@ -262,15 +262,6 @@ void Hand::simulate(float deltaTime, bool isMine) { if (isMine) { _buckyBalls.simulate(deltaTime); - } - - const glm::vec3 leapHandsOffsetFromFace(0.0, -0.2, -0.3); // place the hand in front of the face where we can see it - - Head& head = _owningAvatar->getHead(); - _baseOrientation = _owningAvatar->getOrientation(); - _basePosition = head.calculateAverageEyePosition() + _baseOrientation * leapHandsOffsetFromFace * head.getScale(); - - if (isMine) { updateCollisions(); } @@ -465,7 +456,7 @@ void Hand::calculateGeometry() { const float standardBallRadius = FINGERTIP_COLLISION_RADIUS; _leapFingerTipBalls.resize(_leapFingerTipBalls.size() + 1); HandBall& ball = _leapFingerTipBalls.back(); - ball.rotation = _baseOrientation; + ball.rotation = getBaseOrientation(); ball.position = finger.getTipPosition(); ball.radius = standardBallRadius; ball.touchForce = 0.0; @@ -487,7 +478,7 @@ void Hand::calculateGeometry() { const float standardBallRadius = 0.005f; _leapFingerRootBalls.resize(_leapFingerRootBalls.size() + 1); HandBall& ball = _leapFingerRootBalls.back(); - ball.rotation = _baseOrientation; + ball.rotation = getBaseOrientation(); ball.position = finger.getRootPosition(); ball.radius = standardBallRadius; ball.touchForce = 0.0; diff --git a/interface/src/renderer/Model.cpp b/interface/src/renderer/Model.cpp index 76cf655c1e..c6c820a0f9 100644 --- a/interface/src/renderer/Model.cpp +++ b/interface/src/renderer/Model.cpp @@ -798,7 +798,10 @@ bool Model::restoreJointPosition(int jointIndex, float percent) { const QVector& freeLineage = geometry.joints.at(jointIndex).freeLineage; foreach (int index, freeLineage) { - _jointStates[index].rotation = safeMix(_jointStates[index].rotation, geometry.joints.at(index).rotation, percent); + JointState& state = _jointStates[index]; + const FBXJoint& joint = geometry.joints.at(index); + state.rotation = safeMix(state.rotation, joint.rotation, percent); + state.translation = glm::mix(state.translation, joint.translation, percent); } return true; } diff --git a/libraries/avatars/src/HandData.cpp b/libraries/avatars/src/HandData.cpp index 7fc0c79b47..81d4469486 100644 --- a/libraries/avatars/src/HandData.cpp +++ b/libraries/avatars/src/HandData.cpp @@ -16,8 +16,6 @@ const int fingerVectorRadix = 4; HandData::HandData(AvatarData* owningAvatar) : - _basePosition(0.0f, 0.0f, 0.0f), - _baseOrientation(0.0f, 0.0f, 0.0f, 1.0f), _owningAvatarData(owningAvatar) { // Start with two palms @@ -26,11 +24,11 @@ HandData::HandData(AvatarData* owningAvatar) : } glm::vec3 HandData::worldPositionToLeapPosition(const glm::vec3& worldPosition) const { - return glm::inverse(_baseOrientation) * (worldPosition - _basePosition) / LEAP_UNIT_SCALE; + return glm::inverse(getBaseOrientation()) * (worldPosition - getBasePosition()) / LEAP_UNIT_SCALE; } glm::vec3 HandData::worldVectorToLeapVector(const glm::vec3& worldVector) const { - return glm::inverse(_baseOrientation) * worldVector / LEAP_UNIT_SCALE; + return glm::inverse(getBaseOrientation()) * worldVector / LEAP_UNIT_SCALE; } PalmData& HandData::addNewPalm() { @@ -254,6 +252,15 @@ bool HandData::findSpherePenetration(const glm::vec3& penetratorCenter, float pe return false; } +glm::quat HandData::getBaseOrientation() const { + return _owningAvatarData->getOrientation(); +} + +glm::vec3 HandData::getBasePosition() const { + const glm::vec3 LEAP_HANDS_OFFSET_FROM_TORSO(0.0, 0.3, -0.3); + return _owningAvatarData->getPosition() + getBaseOrientation() * LEAP_HANDS_OFFSET_FROM_TORSO * + _owningAvatarData->getTargetScale(); +} void FingerData::setTrailLength(unsigned int length) { _tipTrailPositions.resize(length); diff --git a/libraries/avatars/src/HandData.h b/libraries/avatars/src/HandData.h index ef9009312e..4faf408fca 100755 --- a/libraries/avatars/src/HandData.h +++ b/libraries/avatars/src/HandData.h @@ -50,10 +50,10 @@ public: // position conversion glm::vec3 leapPositionToWorldPosition(const glm::vec3& leapPosition) { - return _basePosition + _baseOrientation * (leapPosition * LEAP_UNIT_SCALE); + return getBasePosition() + getBaseOrientation() * (leapPosition * LEAP_UNIT_SCALE); } glm::vec3 leapDirectionToWorldDirection(const glm::vec3& leapDirection) { - return _baseOrientation * leapDirection; + return getBaseOrientation() * leapDirection; } glm::vec3 worldPositionToLeapPosition(const glm::vec3& worldPosition) const; glm::vec3 worldVectorToLeapVector(const glm::vec3& worldVector) const; @@ -86,10 +86,12 @@ public: friend class AvatarData; protected: - glm::vec3 _basePosition; // Hands are placed relative to this - glm::quat _baseOrientation; // Hands are placed relative to this AvatarData* _owningAvatarData; std::vector _palms; + + glm::quat getBaseOrientation() const; + glm::vec3 getBasePosition() const; + private: // privatize copy ctor and assignment operator so copies of this object cannot be made HandData(const HandData&);