Merge pull request #13548 from luiscuenca/slantedAvatarFix

Fix avatar become more and more slanted over time while in HMD mode
This commit is contained in:
John Conklin II 2018-07-05 15:53:45 -07:00 committed by GitHub
commit a97d4f655a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -269,7 +269,8 @@ void CharacterController::playerStep(btCollisionWorld* collisionWorld, btScalar
}
btQuaternion deltaRot = desiredRot * startRot.inverse();
float angularSpeed = deltaRot.getAngle() / _followTimeRemaining;
btQuaternion angularDisplacement = btQuaternion(deltaRot.getAxis(), angularSpeed * dt);
glm::vec3 rotationAxis = glm::normalize(glm::axis(bulletToGLM(deltaRot))); // deltaRot.getAxis() is inaccurate
btQuaternion angularDisplacement = btQuaternion(glmToBullet(rotationAxis), angularSpeed * dt);
btQuaternion endRot = angularDisplacement * startRot;
// in order to accumulate displacement of avatar position, we need to take _shapeLocalOffset into account.