Fixed Right click camera being buggy for some reason?

This commit is contained in:
Anemunt
2025-12-09 16:56:02 -05:00
parent 57fb740b04
commit 07bc0177d5
3 changed files with 12 additions and 3 deletions

View File

@@ -94,7 +94,13 @@ glm::mat4 Camera::getViewMatrix() const {
}
// ViewportController implementation
void ViewportController::updateFocusFromImGui(bool windowFocused) {
void ViewportController::updateFocusFromImGui(bool windowFocused, bool cursorLocked) {
if (cursorLocked) {
viewportFocused = true;
manualUnfocus = false;
return;
}
if (!windowFocused && viewportFocused && !manualUnfocus) {
viewportFocused = false;
}

View File

@@ -26,7 +26,7 @@ private:
bool manualUnfocus = false;
public:
void updateFocusFromImGui(bool windowFocused);
void updateFocusFromImGui(bool windowFocused, bool cursorLocked);
void setFocused(bool focused);
bool isViewportFocused() const;
void clearManualUnfocus();

View File

@@ -2162,6 +2162,9 @@ void Engine::renderViewport() {
glfwSetInputMode(editorWindow, GLFW_CURSOR, GLFW_CURSOR_NORMAL);
camera.firstMouse = true;
}
if (cursorLocked) {
viewportController.setFocused(true);
}
}
// Overlay hint
@@ -2180,7 +2183,7 @@ void Engine::renderViewport() {
}
bool windowFocused = ImGui::IsWindowFocused();
viewportController.updateFocusFromImGui(windowFocused);
viewportController.updateFocusFromImGui(windowFocused, cursorLocked);
ImGui::End();
}