From 7267c1c8a11c05f7d9b98f2c9d05ef4f13d2d03c Mon Sep 17 00:00:00 2001 From: Nikolas Date: Tue, 5 Aug 2025 00:15:52 +0200 Subject: [PATCH] Make culling distances consistent across raylib --- src/config.h | 4 ++-- src/rcamera.h | 4 ++-- src/rcore.c | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/config.h b/src/config.h index bfd1fad13..9c6e334f7 100644 --- a/src/config.h +++ b/src/config.h @@ -135,8 +135,8 @@ #define RL_MAX_SHADER_LOCATIONS 32 // Maximum number of shader locations supported -#define RL_CULL_DISTANCE_NEAR 0.001 // Default projection matrix near cull distance -#define RL_CULL_DISTANCE_FAR 10000.0 // Default projection matrix far cull distance +#define RL_CULL_DISTANCE_NEAR 0.05 // Default projection matrix near cull distance +#define RL_CULL_DISTANCE_FAR 4000.0 // Default projection matrix far cull distance // Default shader vertex attribute locations #define RL_DEFAULT_SHADER_ATTRIB_LOCATION_POSITION 0 diff --git a/src/rcamera.h b/src/rcamera.h index a598e1107..62c1225ec 100644 --- a/src/rcamera.h +++ b/src/rcamera.h @@ -65,8 +65,8 @@ #endif #if defined(RCAMERA_STANDALONE) - #define CAMERA_CULL_DISTANCE_NEAR 0.01 - #define CAMERA_CULL_DISTANCE_FAR 1000.0 + #define CAMERA_CULL_DISTANCE_NEAR 0.05 + #define CAMERA_CULL_DISTANCE_FAR 4000.0 #else #define CAMERA_CULL_DISTANCE_NEAR RL_CULL_DISTANCE_NEAR #define CAMERA_CULL_DISTANCE_FAR RL_CULL_DISTANCE_FAR diff --git a/src/rcore.c b/src/rcore.c index 099bbe9c8..46e39991f 100644 --- a/src/rcore.c +++ b/src/rcore.c @@ -1530,7 +1530,7 @@ Ray GetScreenToWorldRayEx(Vector2 position, Camera camera, int width, int height double right = top*aspect; // Calculate projection matrix from orthographic - matProj = MatrixOrtho(-right, right, -top, top, 0.01, 1000.0); + matProj = MatrixOrtho(-right, right, -top, top, rlGetCullDistanceNear(), rlGetCullDistanceFar()); } // Unproject far/near points