Browse Source

Make culling distances consistent across raylib

Nikolas 2 weeks ago
parent
commit
7267c1c8a1
3 changed files with 5 additions and 5 deletions
  1. 2 2
      src/config.h
  2. 2 2
      src/rcamera.h
  3. 1 1
      src/rcore.c

+ 2 - 2
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

+ 2 - 2
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

+ 1 - 1
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