Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 3 additions & 12 deletions .Jules/palette.md
Original file line number Diff line number Diff line change
@@ -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.
14 changes: 14 additions & 0 deletions src/Camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand All @@ -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;

Expand Down
9 changes: 9 additions & 0 deletions src/Camera.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
Expand Down
12 changes: 9 additions & 3 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -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;
Expand Down