| 1051 | } |
| 1052 | |
| 1053 | void Editor::ProcessCameraInput() |
| 1054 | { |
| 1055 | // Calculate delta time |
| 1056 | auto currentTime = std::chrono::steady_clock::now(); |
| 1057 | float deltaTime = std::chrono::duration<float>(currentTime - m_LastFrameTime).count(); |
| 1058 | m_LastFrameTime = currentTime; |
| 1059 | |
| 1060 | bool cameraChanged = false; |
| 1061 | |
| 1062 | // Mouse rotation (only when dragging) |
| 1063 | if (ImGui::IsMouseClicked(ImGuiMouseButton_Left)) |
| 1064 | { |
| 1065 | m_IsDraggingViewport = true; |
| 1066 | ImVec2 mousePos = ImGui::GetMousePos(); |
| 1067 | m_LastMousePos = {mousePos.x, mousePos.y}; |
| 1068 | } |
| 1069 | |
| 1070 | if (m_IsDraggingViewport && ImGui::IsMouseDown(ImGuiMouseButton_Left)) |
| 1071 | { |
| 1072 | ImVec2 mousePos = ImGui::GetMousePos(); |
| 1073 | glm::vec2 currentMousePos = {mousePos.x, mousePos.y}; |
| 1074 | glm::vec2 deltaPos = currentMousePos - m_LastMousePos; |
| 1075 | |
| 1076 | m_Camera.ProcessMouseMovement(deltaPos.x, deltaPos.y); |
| 1077 | |
| 1078 | if (m_LastMousePos != currentMousePos) |
| 1079 | cameraChanged = true; |
| 1080 | |
| 1081 | m_LastMousePos = currentMousePos; |
| 1082 | } |
| 1083 | |
| 1084 | // Keyboard movement (WASD + space/left shift for up/down) |
| 1085 | if (m_IsDraggingViewport && ImGui::IsKeyDown(ImGuiKey_W)) |
| 1086 | { |
| 1087 | m_Camera.ProcessKeyboard(FlyCamera::Direction::FORWARD, deltaTime); |
| 1088 | cameraChanged = true; |
| 1089 | } |
| 1090 | if (m_IsDraggingViewport && ImGui::IsKeyDown(ImGuiKey_S)) |
| 1091 | { |
| 1092 | m_Camera.ProcessKeyboard(FlyCamera::Direction::BACKWARD, deltaTime); |
| 1093 | cameraChanged = true; |
| 1094 | } |
| 1095 | if (m_IsDraggingViewport && ImGui::IsKeyDown(ImGuiKey_A)) |
| 1096 | { |
| 1097 | m_Camera.ProcessKeyboard(FlyCamera::Direction::LEFT, deltaTime); |
| 1098 | cameraChanged = true; |
| 1099 | } |
| 1100 | if (m_IsDraggingViewport && ImGui::IsKeyDown(ImGuiKey_D)) |
| 1101 | { |
| 1102 | m_Camera.ProcessKeyboard(FlyCamera::Direction::RIGHT, deltaTime); |
| 1103 | cameraChanged = true; |
| 1104 | } |
| 1105 | if (m_IsDraggingViewport && ImGui::IsKeyDown(ImGuiKey_Space)) |
| 1106 | { |
| 1107 | m_Camera.ProcessKeyboard(FlyCamera::Direction::UP, deltaTime); |
| 1108 | cameraChanged = true; |
| 1109 | } |
| 1110 | if (m_IsDraggingViewport && ImGui::IsKeyDown(ImGuiKey_LeftShift)) |
nothing calls this directly
no test coverage detected