From f6c4f6b9c4aa9494458244f7a752de884b66a6f4 Mon Sep 17 00:00:00 2001 From: "Anthony J. Thibault" Date: Thu, 15 Mar 2018 13:06:27 -0700 Subject: [PATCH] Fix for arm IK jitter When in HMD mode, holding your hand controller in front of your face, would often result in a 1-2 mm pop in wrist position. This was due to a problem in the IK elbow constraint. When the swing rotation out of the elbow's reference frame was close to but not exactly identity it would not be properly constrainted. But when the magnitude of that swing became big enough the constraint would engage. This small change in swing rotation was noticable as a 1-2 mm movement in the wrist. --- libraries/animation/src/ElbowConstraint.cpp | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/libraries/animation/src/ElbowConstraint.cpp b/libraries/animation/src/ElbowConstraint.cpp index 17c6bb2da6..deaf1a0945 100644 --- a/libraries/animation/src/ElbowConstraint.cpp +++ b/libraries/animation/src/ElbowConstraint.cpp @@ -66,16 +66,12 @@ bool ElbowConstraint::apply(glm::quat& rotation) const { bool twistWasClamped = (twistAngle != clampedTwistAngle); // update rotation - const float MIN_SWING_REAL_PART = 0.99999f; - if (twistWasClamped || fabsf(swingRotation.w) < MIN_SWING_REAL_PART) { - if (twistWasClamped) { - twistRotation = glm::angleAxis(clampedTwistAngle, _axis); - } - // we discard all swing and only keep twist - rotation = twistRotation * _referenceRotation; - return true; + if (twistWasClamped) { + twistRotation = glm::angleAxis(clampedTwistAngle, _axis); } - return false; + // we discard all swing and only keep twist + rotation = twistRotation * _referenceRotation; + return true; } glm::quat ElbowConstraint::computeCenterRotation() const {