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.
This commit is contained in:
Anthony J. Thibault 2018-03-15 13:06:27 -07:00
parent a7dc2cd12e
commit f6c4f6b9c4

View file

@ -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 {