30 const bool rightMouseDown =
31 glfwGetMouseButton(window, GLFW_MOUSE_BUTTON_RIGHT)
34 const bool looking = viewportHovered && rightMouseDown;
44 glfwGetCursorPos(window, &mouseX, &mouseY);
48 m_LastMouseX = mouseX;
49 m_LastMouseY = mouseY;
54 static_cast<float>(mouseX - m_LastMouseX);
57 static_cast<float>(m_LastMouseY - mouseY);
59 m_LastMouseX = mouseX;
60 m_LastMouseY = mouseY;
62 m_Yaw += deltaX * m_MouseSensitivity;
63 m_Pitch += deltaY * m_MouseSensitivity;
64 m_Pitch = std::clamp(m_Pitch, -89.0f, 89.0f);
66 const glm::vec3 forward = GetForwardDirection();
67 const glm::vec3 right = GetRightDirection();
68 const glm::vec3 worldUp{ 0.0f, 1.0f, 0.0f };
70 float speed = m_MoveSpeed;
71 if (glfwGetKey(window, GLFW_KEY_LEFT_SHIFT) == GLFW_PRESS)
74 if (glfwGetKey(window, GLFW_KEY_W) == GLFW_PRESS)
75 m_Position += forward * speed * deltaTime;
77 if (glfwGetKey(window, GLFW_KEY_S) == GLFW_PRESS)
78 m_Position -= forward * speed * deltaTime;
80 if (glfwGetKey(window, GLFW_KEY_D) == GLFW_PRESS)
81 m_Position += right * speed * deltaTime;
83 if (glfwGetKey(window, GLFW_KEY_A) == GLFW_PRESS)
84 m_Position -= right * speed * deltaTime;
86 if (glfwGetKey(window, GLFW_KEY_E) == GLFW_PRESS)
87 m_Position += worldUp * speed * deltaTime;
89 if (glfwGetKey(window, GLFW_KEY_Q) == GLFW_PRESS)
90 m_Position -= worldUp * speed * deltaTime;