Skip to content

Commit f8e59f9

Browse files
authored
Merge pull request #110 from TECHNICANGEL/palette-camera-reset-5182742576547245750
Add camera reset functionality (R key) and fix build
2 parents 6d9d4da + 3ad1a59 commit f8e59f9

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

src/Camera.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,20 @@ Camera::Camera(float fov, float aspectRatio, float nearPlane, float farPlane)
1212
yaw = -90.0f;
1313
pitch = -10.0f; // Look down 10 degrees
1414

15+
// Save initial state for reset
16+
initialPosition = position;
17+
initialYaw = yaw;
18+
initialPitch = pitch;
19+
initialFov = fov;
20+
21+
updateCameraVectors();
22+
}
23+
24+
void Camera::reset() {
25+
position = initialPosition;
26+
yaw = initialYaw;
27+
pitch = initialPitch;
28+
fov = initialFov;
1529
updateCameraVectors();
1630
}
1731

src/Camera.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ class Camera {
1717
// Update camera
1818
void update(float deltaTime);
1919

20+
// Reset camera to initial state
21+
void reset();
22+
2023
// Input handling
2124
void processKeyboard(GLFWwindow* window, float deltaTime);
2225
void processMouseMovement(float xOffset, float yOffset);
@@ -49,6 +52,12 @@ class Camera {
4952
float yaw;
5053
float pitch;
5154

55+
// Initial state for reset
56+
glm::vec3 initialPosition;
57+
float initialYaw;
58+
float initialPitch;
59+
float initialFov;
60+
5261
// Projection parameters
5362
float aspectRatio;
5463
float nearPlane;

src/main.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,13 @@ class RacingEngine {
296296
if (key == GLFW_KEY_D && action == GLFW_RELEASE) {
297297
engine->denoiserKeyPressed = false;
298298
}
299+
300+
// R key to reset camera
301+
if (key == GLFW_KEY_R && action == GLFW_PRESS) {
302+
engine->camera.reset();
303+
engine->logger.log("\n[CAMERA] Reset to default view\n");
304+
engine->updateWindowTitle();
305+
}
299306
}
300307

301308
void initVulkan() {

0 commit comments

Comments
 (0)