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
4 changes: 4 additions & 0 deletions .Jules/palette.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
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

// Store initial values for reset
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 Down Expand Up @@ -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;
};
13 changes: 10 additions & 3 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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";
}

Expand Down Expand Up @@ -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() {
Expand Down