Improve camera

More intuitive controls.
This also makes it trivial to switch over to using the euler angles as the state variables, which eliminates roll
This commit is contained in:
2024-06-21 12:40:11 +02:00
parent d650b84e1b
commit 96a5473c8b

View File

@@ -84,8 +84,8 @@ namespace Gloom
}
// Keep track of pitch and yaw for the current frame
fYaw = xpos - lastXPos;
fPitch = ypos - lastYPos;
fYaw = (xpos - lastXPos) * cMouseSensitivity;
fPitch = (ypos - lastYPos) * cMouseSensitivity;
// Update last known cursor position
lastXPos = xpos;
@@ -143,10 +143,6 @@ namespace Gloom
/* Update the view matrix based on the current information */
void updateViewMatrix()
{
// Adjust cursor movement using the specified sensitivity
fPitch *= cMouseSensitivity;
fYaw *= cMouseSensitivity;
// Create quaternions given the current pitch and yaw
glm::quat qPitch = glm::quat(glm::vec3(fPitch, 0.0f, 0.0f));
glm::quat qYaw = glm::quat(glm::vec3(0.0f, fYaw, 0.0f));
@@ -156,7 +152,7 @@ namespace Gloom
fYaw = 0.0f;
// Update camera quaternion and normalise
cQuaternion = qYaw * qPitch * cQuaternion;
cQuaternion = qPitch * qYaw * cQuaternion;
cQuaternion = glm::normalize(cQuaternion);
// Build rotation matrix using the camera quaternion