diff --git a/.Jules/palette.md b/.Jules/palette.md index 5025a48..0731f77 100644 --- a/.Jules/palette.md +++ b/.Jules/palette.md @@ -1,12 +1,3 @@ -# Palette's Journal - -## 2024-10-24 - Initial Setup -**Learning:** This is a C++ Vulkan project without a standard web frontend (HTML/CSS/JS). UX improvements will likely involve ImGui or window handling logic in C++. -**Action:** Look for ImGui usage or window creation code to apply UX improvements like window titles, icons, or keyboard input handling. - -## 2024-10-25 - Window Title as Status Bar -**Learning:** In C++ windowed applications without an overlay UI (like ImGui), the window title is the only persistent feedback mechanism. Moving state indicators (Denoiser ON/OFF, FOV) to the title provides immediate visibility without cluttering the console. -**Action:** When working on native apps, check if the window title can be utilized for status feedback if no GUI is present. -## 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-23 - [Safety Net Pattern] +**Learning:** Users often get disoriented in 3D space. Providing a "Reset to Default" action (e.g., 'R' key) acts as a critical safety net, allowing them to recover without restarting the application. +**Action:** Always include a reset mechanism for navigation controls in 3D environments. Ensure it resets not just position/rotation, but also related state like accumulation buffers to prevent visual artifacts. diff --git a/src/Camera.cpp b/src/Camera.cpp index 8534f3e..d9bc04a 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 + // Save initial state + 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..b5c5a66 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); @@ -38,6 +41,12 @@ class Camera { private: void updateCameraVectors(); + // Initial state for reset + glm::vec3 initialPosition; + float initialYaw; + float initialPitch; + float initialFov; + // Camera position and orientation glm::vec3 position; glm::vec3 front; diff --git a/src/main.cpp b/src/main.cpp index 3503741..175a5d2 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -188,9 +188,6 @@ class RacingEngine { AsyncLogger logger; // UX State Tracking - float currentFPS = 0.0f; - float frameTimeMs = 0.0f; - void updateWindowTitle() { glm::vec3 pos = camera.getPosition(); char title[512]; @@ -267,6 +264,15 @@ class RacingEngine { glfwSetWindowShouldClose(window, true); } + // R key to reset camera (Safety Net) + if (key == GLFW_KEY_R && action == GLFW_PRESS) { + engine->camera.reset(); + engine->accumulationFrames = 0; + engine->firstMouse = true; // Prevent view jump + engine->logger.log("\n[CAMERA] Reset to default view\n"); + engine->updateWindowTitle(); + } + // TAB key to toggle cursor lock if (key == GLFW_KEY_TAB && action == GLFW_PRESS && !engine->tabKeyPressed) { engine->tabKeyPressed = true;