Fix face-tracked head disappearing into body

Normalize quaternion to ensure that acos(r.w) is valid (r.w <= 1.0) and
r.w = 1.0 when r.x = r.y = r.z = 0.0.
This commit is contained in:
David Rowe 2015-05-13 11:34:19 -07:00
parent 349886c146
commit 5050171d30

View file

@ -382,7 +382,7 @@ void DdeFaceTracker::decodePacket(const QByteArray& buffer) {
// Compute relative rotation
rotation = glm::inverse(_referenceRotation) * rotation;
if (isFiltering) {
glm::quat r = rotation * glm::inverse(_headRotation);
glm::quat r = glm::normalize(rotation * glm::inverse(_headRotation));
float theta = 2 * acos(r.w);
glm::vec3 angularVelocity;
if (theta > EPSILON) {