From 259bee291e74f5f3aeaf3aec8b87c65151ac5aa5 Mon Sep 17 00:00:00 2001 From: Mitja Felicijan Date: Tue, 28 Apr 2026 17:14:19 +0200 Subject: Better player camera FOV --- config.h | 1 + game.c | 2 +- player.c | 5 ++++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/config.h b/config.h index b92b308..7013074 100644 --- a/config.h +++ b/config.h @@ -16,6 +16,7 @@ #define PLAYER_HEIGHT 64.0f #define PLAYER_RADIUS 16.0f #define PLAYER_EYE_HEIGHT 56.0f +#define PLAYER_FOV 65.0f #define PLAYER_LEAN_ANGLE 25.0f #define PLAYER_LEAN_SPEED 8.0f diff --git a/game.c b/game.c index ad932a8..168cae4 100644 --- a/game.c +++ b/game.c @@ -95,7 +95,7 @@ bool LoadMap(const char *filename) { game.camera.position = (Vector3){ 0, 10, 0 }; game.camera.target = (Vector3){ 1, 10, 0 }; game.camera.up = (Vector3){ 0, 1, 0 }; - game.camera.fovy = 75.0f; + game.camera.fovy = PLAYER_FOV; game.camera.projection = CAMERA_PERSPECTIVE; int total_brushes = 0; diff --git a/player.c b/player.c index a8c039f..01c56ca 100644 --- a/player.c +++ b/player.c @@ -266,11 +266,14 @@ void UpdatePlayer(void) { -sinf(game.pitch), cosf(game.pitch) * cosf(game.yaw) }; + + // Use a stable world-up vector and apply lean roll Vector3 up = { 0, 1, 0 }; up = Vector3RotateByAxisAngle(up, forward, leanAngle); game.camera.up = up; - game.camera.target = Vector3Add(game.camera.position, forward); + // Use a longer target distance for better precision in the projection matrix + game.camera.target = Vector3Add(game.camera.position, Vector3Scale(forward, 20.0f)); // Calculate horizontal speed for UI if (dt > 0) { -- cgit v1.2.3