diff --git a/interface/src/avatar/SkeletonModel.cpp b/interface/src/avatar/SkeletonModel.cpp index d40c660c4b..711e11def6 100644 --- a/interface/src/avatar/SkeletonModel.cpp +++ b/interface/src/avatar/SkeletonModel.cpp @@ -372,8 +372,8 @@ bool SkeletonModel::getRightHandPosition(glm::vec3& position) const { return getJointPosition(getRightHandJointIndex(), position); } -bool SkeletonModel::restoreLeftHandPosition(float percent, float priority) { - return restoreJointPosition(getLeftHandJointIndex(), percent, priority); +bool SkeletonModel::restoreLeftHandPosition(float fraction, float priority) { + return restoreJointPosition(getLeftHandJointIndex(), fraction, priority); } bool SkeletonModel::getLeftShoulderPosition(glm::vec3& position) const { @@ -384,8 +384,8 @@ float SkeletonModel::getLeftArmLength() const { return getLimbLength(getLeftHandJointIndex()); } -bool SkeletonModel::restoreRightHandPosition(float percent, float priority) { - return restoreJointPosition(getRightHandJointIndex(), percent, priority); +bool SkeletonModel::restoreRightHandPosition(float fraction, float priority) { + return restoreJointPosition(getRightHandJointIndex(), fraction, priority); } bool SkeletonModel::getRightShoulderPosition(glm::vec3& position) const { diff --git a/interface/src/avatar/SkeletonModel.h b/interface/src/avatar/SkeletonModel.h index 8c5cfed23a..91070e4ad6 100644 --- a/interface/src/avatar/SkeletonModel.h +++ b/interface/src/avatar/SkeletonModel.h @@ -49,10 +49,10 @@ public: /// \return true whether or not the position was found bool getRightHandPosition(glm::vec3& position) const; - /// Restores some percentage of the default position of the left hand. - /// \param percent the percentage of the default position to restore + /// Restores some fraction of the default position of the left hand. + /// \param fraction the fraction of the default position to restore /// \return whether or not the left hand joint was found - bool restoreLeftHandPosition(float percent = 1.0f, float priority = 1.0f); + bool restoreLeftHandPosition(float fraction = 1.0f, float priority = 1.0f); /// Gets the position of the left shoulder. /// \return whether or not the left shoulder joint was found @@ -61,10 +61,10 @@ public: /// Returns the extended length from the left hand to its last free ancestor. float getLeftArmLength() const; - /// Restores some percentage of the default position of the right hand. - /// \param percent the percentage of the default position to restore + /// Restores some fraction of the default position of the right hand. + /// \param fraction the fraction of the default position to restore /// \return whether or not the right hand joint was found - bool restoreRightHandPosition(float percent = 1.0f, float priority = 1.0f); + bool restoreRightHandPosition(float fraction = 1.0f, float priority = 1.0f); /// Gets the position of the right shoulder. /// \return whether or not the right shoulder joint was found diff --git a/interface/src/renderer/Model.cpp b/interface/src/renderer/Model.cpp index d4d344a862..bae1e7246d 100644 --- a/interface/src/renderer/Model.cpp +++ b/interface/src/renderer/Model.cpp @@ -590,9 +590,8 @@ void Model::setJointState(int index, bool valid, const glm::quat& rotation, floa if (valid) { state._rotation = rotation; state._animationPriority = priority; - } else if (priority == state._animationPriority) { - state._rotation = _geometry->getFBXGeometry().joints.at(index).rotation; - state._animationPriority = 0.0f; + } else { + state.restoreRotation(1.0f, priority); } } } @@ -1232,7 +1231,7 @@ bool Model::setJointRotation(int jointIndex, const glm::quat& rotation, float pr return true; } -bool Model::restoreJointPosition(int jointIndex, float percent, float priority) { +bool Model::restoreJointPosition(int jointIndex, float fraction, float priority) { if (jointIndex == -1 || _jointStates.isEmpty()) { return false; } @@ -1241,7 +1240,7 @@ bool Model::restoreJointPosition(int jointIndex, float percent, float priority) foreach (int index, freeLineage) { JointState& state = _jointStates[index]; - state.restoreRotation(percent, priority); + state.restoreRotation(fraction, priority); } return true; } @@ -1874,9 +1873,9 @@ glm::quat JointState::getJointRotation(bool fromBind) const { return _combinedRotation * (fromBind ? _fbxJoint->inverseBindRotation : _fbxJoint->inverseDefaultRotation); } -void JointState::restoreRotation(float percent, float priority) { +void JointState::restoreRotation(float fraction, float priority) { if (priority == _animationPriority) { - _rotation = safeMix(_rotation, _fbxJoint->rotation, percent); + _rotation = safeMix(_rotation, _fbxJoint->rotation, fraction); _animationPriority = 0.0f; } } diff --git a/interface/src/renderer/Model.h b/interface/src/renderer/Model.h index c2b7e80026..de6a760e0f 100644 --- a/interface/src/renderer/Model.h +++ b/interface/src/renderer/Model.h @@ -49,7 +49,7 @@ public: const glm::vec3& getDefaultTranslationInParentFrame() const; - void restoreRotation(float percent, float priority); + void restoreRotation(float fraction, float priority); glm::quat _rotation; // rotation relative to parent glm::mat4 _transform; // rotation to world frame + translation in model frame @@ -244,10 +244,10 @@ protected: bool setJointRotation(int jointIndex, const glm::quat& rotation, float priority = 1.0f); /// Restores the indexed joint to its default position. - /// \param percent the percentage of the default position to apply (i.e., 0.25f to slerp one fourth of the way to + /// \param fraction the fraction of the default position to apply (i.e., 0.25f to slerp one fourth of the way to /// the original position /// \return true if the joint was found - bool restoreJointPosition(int jointIndex, float percent = 1.0f, float priority = 0.0f); + bool restoreJointPosition(int jointIndex, float fraction = 1.0f, float priority = 0.0f); /// Computes and returns the extended length of the limb terminating at the specified joint and starting at the joint's /// first free ancestor.