Only apply rotation from input is actually enabled

And normalize resulting rotation quaternion, just to be safe
This commit is contained in:
Emma Broman
2021-12-13 13:49:01 +01:00
parent 27948b8a43
commit 1e4f7b30a0
+6 -2
View File
@@ -267,7 +267,9 @@ void PathNavigator::updateCamera(double deltaTime) {
removeRollRotation(newPose, deltaTime);
}
applyLocalRotationFromInput(newPose, deltaTime);
if (_interaction.enabled) {
applyLocalRotationFromInput(newPose, deltaTime);
}
camera()->setPositionVec3(newPose.position);
camera()->setRotation(newPose.rotation);
@@ -528,7 +530,9 @@ void PathNavigator::applyLocalRotationFromInput(CameraPose& pose, double deltaTi
const glm::dquat pitchDiffRotation = glm::angleAxis(pitch, cameraRight);
const glm::dquat rollDiffRotation = glm::angleAxis(roll, cameraForward);
pose.rotation = pitchDiffRotation * yawDiffRotation * rollDiffRotation * pose.rotation;
pose.rotation = glm::normalize(
pitchDiffRotation * yawDiffRotation * rollDiffRotation * pose.rotation
);
// Reset velocities after every frame
_interaction.mouseStates.resetVelocities();