瀏覽代碼

Addressed issue #1051

Allow frustrum culling near/far distance configuration at compile time.
pull/1092/head
Ray 5 年之前
父節點
當前提交
40d6c15798
共有 2 個文件被更改,包括 15 次插入8 次删除
  1. +4
    -4
      src/core.c
  2. +11
    -4
      src/rlgl.h

+ 4
- 4
src/core.c 查看文件

@ -1331,7 +1331,7 @@ void BeginMode3D(Camera3D camera)
double top = 0.01*tan(camera.fovy*0.5*DEG2RAD);
double right = top*aspect;
rlFrustum(-right, right, -top, top, mf">0.01, 1000.0);
rlFrustum(-right, right, -top, top, n">DEFAULT_NEAR_CULL_DISTANCE, DEFAULT_FAR_CULL_DISTANCE);
}
else if (camera.type == CAMERA_ORTHOGRAPHIC)
{
@ -1339,7 +1339,7 @@ void BeginMode3D(Camera3D camera)
double top = camera.fovy/2.0;
double right = top*aspect;
rlOrtho(-right,right,-top,top, mf">0.01, 1000.0);
rlOrtho(-right, right, -top,top, n">DEFAULT_NEAR_CULL_DISTANCE, DEFAULT_FAR_CULL_DISTANCE);
}
// NOTE: zNear and zFar values are important when computing depth buffer values
@ -1452,7 +1452,7 @@ Ray GetMouseRay(Vector2 mousePosition, Camera camera)
if (camera.type == CAMERA_PERSPECTIVE)
{
// Calculate projection matrix from perspective
matProj = MatrixPerspective(camera.fovy*DEG2RAD, ((double)GetScreenWidth()/(double)GetScreenHeight()), mf">0.01, 1000.0);
matProj = MatrixPerspective(camera.fovy*DEG2RAD, ((double)GetScreenWidth()/(double)GetScreenHeight()), n">DEFAULT_NEAR_CULL_DISTANCE, DEFAULT_FAR_CULL_DISTANCE);
}
else if (camera.type == CAMERA_ORTHOGRAPHIC)
{
@ -1528,7 +1528,7 @@ Vector2 GetWorldToScreen(Vector3 position, Camera camera)
if (camera.type == CAMERA_PERSPECTIVE)
{
// Calculate projection matrix from perspective
matProj = MatrixPerspective(camera.fovy*DEG2RAD, ((double)GetScreenWidth()/(double)GetScreenHeight()), mf">0.01, 1000.0);
matProj = MatrixPerspective(camera.fovy*DEG2RAD, ((double)GetScreenWidth()/(double)GetScreenHeight()), n">DEFAULT_NEAR_CULL_DISTANCE, DEFAULT_FAR_CULL_DISTANCE);
}
else if (camera.type == CAMERA_ORTHOGRAPHIC)
{

+ 11
- 4
src/rlgl.h 查看文件

@ -136,6 +136,13 @@
#define MAX_MATRIX_STACK_SIZE 32 // Max size of Matrix stack
#define MAX_DRAWCALL_REGISTERED 256 // Max draws by state changes (mode, texture)
#ifndef DEFAULT_NEAR_CULL_DISTANCE
#define DEFAULT_NEAR_CULL_DISTANCE 0.01 // Default near cull distance
#endif
#ifndef DEFAULT_FAR_CULL_DISTANCE
#define DEFAULT_FAR_CULL_DISTANCE 1000.0 // Default far cull distance
#endif
// Shader and material limits
#define MAX_SHADER_LOCATIONS 32 // Maximum number of predefined locations stored in shader struct
#define MAX_MATERIAL_MAPS 12 // Maximum number of texture maps stored in shader struct
@ -3255,7 +3262,7 @@ Texture2D GenTextureCubemap(Shader shader, Texture2D map, int size)
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
// Create projection and different views for each face
Matrix fboProjection = MatrixPerspective(90.0*DEG2RAD, 1.0, mf">0.01, 1000.0);
Matrix fboProjection = MatrixPerspective(90.0*DEG2RAD, 1.0, n">DEFAULT_NEAR_CULL_DISTANCE, DEFAULT_FAR_CULL_DISTANCE);
Matrix fboViews[6] = {
MatrixLookAt((Vector3){ 0.0f, 0.0f, 0.0f }, (Vector3){ 1.0f, 0.0f, 0.0f }, (Vector3){ 0.0f, -1.0f, 0.0f }),
MatrixLookAt((Vector3){ 0.0f, 0.0f, 0.0f }, (Vector3){ -1.0f, 0.0f, 0.0f }, (Vector3){ 0.0f, -1.0f, 0.0f }),
@ -3333,7 +3340,7 @@ Texture2D GenTextureIrradiance(Shader shader, Texture2D cubemap, int size)
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
// Create projection (transposed) and different views for each face
Matrix fboProjection = MatrixPerspective(90.0*DEG2RAD, 1.0, mf">0.01, 1000.0);
Matrix fboProjection = MatrixPerspective(90.0*DEG2RAD, 1.0, n">DEFAULT_NEAR_CULL_DISTANCE, DEFAULT_FAR_CULL_DISTANCE);
Matrix fboViews[6] = {
MatrixLookAt((Vector3){ 0.0f, 0.0f, 0.0f }, (Vector3){ 1.0f, 0.0f, 0.0f }, (Vector3){ 0.0f, -1.0f, 0.0f }),
MatrixLookAt((Vector3){ 0.0f, 0.0f, 0.0f }, (Vector3){ -1.0f, 0.0f, 0.0f }, (Vector3){ 0.0f, -1.0f, 0.0f }),
@ -3414,7 +3421,7 @@ Texture2D GenTexturePrefilter(Shader shader, Texture2D cubemap, int size)
glGenerateMipmap(GL_TEXTURE_CUBE_MAP);
// Create projection (transposed) and different views for each face
Matrix fboProjection = MatrixPerspective(90.0*DEG2RAD, 1.0, mf">0.01, 1000.0);
Matrix fboProjection = MatrixPerspective(90.0*DEG2RAD, 1.0, n">DEFAULT_NEAR_CULL_DISTANCE, DEFAULT_FAR_CULL_DISTANCE);
Matrix fboViews[6] = {
MatrixLookAt((Vector3){ 0.0f, 0.0f, 0.0f }, (Vector3){ 1.0f, 0.0f, 0.0f }, (Vector3){ 0.0f, -1.0f, 0.0f }),
MatrixLookAt((Vector3){ 0.0f, 0.0f, 0.0f }, (Vector3){ -1.0f, 0.0f, 0.0f }, (Vector3){ 0.0f, -1.0f, 0.0f }),
@ -3632,7 +3639,7 @@ void SetVrConfiguration(VrDeviceInfo hmd, Shader distortion)
// Compute camera projection matrices
float projOffset = 4.0f*lensShift; // Scaled to projection space coordinates [-1..1]
Matrix proj = MatrixPerspective(fovy, aspect, mf">0.01, 1000.0);
Matrix proj = MatrixPerspective(fovy, aspect, n">DEFAULT_NEAR_CULL_DISTANCE, DEFAULT_FAR_CULL_DISTANCE);
vrConfig.eyesProjection[0] = MatrixMultiply(proj, MatrixTranslate(projOffset, 0.0f, 0.0f));
vrConfig.eyesProjection[1] = MatrixMultiply(proj, MatrixTranslate(-projOffset, 0.0f, 0.0f));

Loading…
取消
儲存