Skip to content
Merged
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
14 changes: 14 additions & 0 deletions src/Camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,20 @@ Camera::Camera(float fov, float aspectRatio, float nearPlane, float farPlane)
yaw = -90.0f;
pitch = -10.0f; // Look down 10 degrees

// Save initial state for reset
initialPosition = position;
initialYaw = yaw;
initialPitch = pitch;
initialFov = fov;

updateCameraVectors();
}

void Camera::reset() {
position = initialPosition;
yaw = initialYaw;
pitch = initialPitch;
fov = initialFov;
updateCameraVectors();
}

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 @@ -49,6 +52,12 @@ class Camera {
float yaw;
float pitch;

// Initial state for reset
glm::vec3 initialPosition;
float initialYaw;
float initialPitch;
float initialFov;

// Projection parameters
float aspectRatio;
float nearPlane;
Expand Down
7 changes: 7 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,13 @@ 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->logger.log("\n[CAMERA] Reset to default view\n");
engine->updateWindowTitle();
}
}

void initVulkan() {
Expand Down