diff --git a/.Jules/palette.md b/.Jules/palette.md index 5025a48..312508c 100644 --- a/.Jules/palette.md +++ b/.Jules/palette.md @@ -10,3 +10,7 @@ ## 2024-05-21 - Immediate Feedback in Native Apps **Learning:** In native applications (GLFW), state changes triggered by input callbacks often lack immediate visual feedback if the UI update is tied to a main loop timer. **Action:** Always call UI update functions directly from input callbacks for state toggles, rather than waiting for the next scheduled refresh. + +## 2024-05-22 - Safety Net for 3D Navigation +**Learning:** In free-roam 3D applications, users can easily become disoriented. Providing a "Reset to Default" action significantly reduces frustration. +**Action:** Always consider adding a "Reset Camera/View" shortcut in 3D navigation implementations. diff --git a/src/Camera.cpp b/src/Camera.cpp index 8534f3e..0fc8702 100644 --- a/src/Camera.cpp +++ b/src/Camera.cpp @@ -12,6 +12,12 @@ Camera::Camera(float fov, float aspectRatio, float nearPlane, float farPlane) yaw = -90.0f; pitch = -10.0f; // Look down 10 degrees + // Store initial values for reset + initialPosition = position; + initialYaw = yaw; + initialPitch = pitch; + initialFov = fov; + updateCameraVectors(); } @@ -36,6 +42,14 @@ void Camera::update(float deltaTime) { // For now, all updates happen in processKeyboard } +void Camera::reset() { + position = initialPosition; + yaw = initialYaw; + pitch = initialPitch; + fov = initialFov; + updateCameraVectors(); +} + void Camera::processKeyboard(GLFWwindow* window, float deltaTime) { float velocity = movementSpeed * deltaTime; diff --git a/src/Camera.h b/src/Camera.h index f747d90..1ecf5c6 100644 --- a/src/Camera.h +++ b/src/Camera.h @@ -17,6 +17,9 @@ class Camera { // Update camera void update(float deltaTime); + // Reset camera to initial state + void reset(); + // Input handling void processKeyboard(GLFWwindow* window, float deltaTime); void processMouseMovement(float xOffset, float yOffset); @@ -53,4 +56,10 @@ class Camera { float aspectRatio; float nearPlane; float farPlane; + + // Initial state for reset + glm::vec3 initialPosition; + float initialYaw; + float initialPitch; + float initialFov; }; diff --git a/src/main.cpp b/src/main.cpp index 3503741..3287f24 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -188,8 +188,6 @@ class RacingEngine { AsyncLogger logger; // UX State Tracking - float currentFPS = 0.0f; - float frameTimeMs = 0.0f; void updateWindowTitle() { glm::vec3 pos = camera.getPosition(); @@ -224,7 +222,7 @@ class RacingEngine { std::cout << "GLFW window created successfully!\n"; std::cout << "Camera controls: WASD - move, QE - up/down, Mouse - look, Shift - faster\n"; - std::cout << " TAB - toggle cursor lock, Scroll - zoom (FOV)\n"; + std::cout << " TAB - toggle cursor lock, Scroll - zoom (FOV), R - Reset\n"; std::cout << "Press D to toggle AI Denoiser (Tensor Cores)\n"; } @@ -299,6 +297,15 @@ class RacingEngine { if (key == GLFW_KEY_D && action == GLFW_RELEASE) { engine->denoiserKeyPressed = false; } + + // R key to reset camera + if (key == GLFW_KEY_R && action == GLFW_PRESS) { + engine->camera.reset(); + engine->accumulationFrames = 0; + engine->firstMouse = true; + engine->logger.log("\n[CAMERA] Reset to default position\n"); + engine->updateWindowTitle(); + } } void initVulkan() {