Fix for flickering eyeballs

Calling glm::axis() on an identity quaternion does not result in a normalized vector.
This vector was used within Rig::updateEyeJoint() to limit the rotation of the eye balls,
to prevent the eyes from rolling back into the avatar's head.

If the avatar was looking straight ahead, this could result in bad quaternions in the eye ball
joint matrices, which in turn would cause the eye ball mesh or any mesh influenced by the eyeball joints
not to render.
This commit is contained in:
Anthony J. Thibault 2016-03-29 10:01:10 -07:00
parent 24ca5b3d60
commit 80dfed77d7

View file

@ -1056,7 +1056,9 @@ void Rig::updateEyeJoint(int index, const glm::vec3& modelTranslation, const glm
// limit rotation
const float MAX_ANGLE = 30.0f * RADIANS_PER_DEGREE;
deltaQuat = glm::angleAxis(glm::clamp(glm::angle(deltaQuat), -MAX_ANGLE, MAX_ANGLE), glm::axis(deltaQuat));
if (fabsf(glm::angle(deltaQuat)) > MAX_ANGLE) {
deltaQuat = glm::angleAxis(glm::clamp(glm::angle(deltaQuat), -MAX_ANGLE, MAX_ANGLE), glm::axis(deltaQuat));
}
// directly set absolutePose rotation
_internalPoseSet._absolutePoses[index].rot = deltaQuat * headQuat;