diff --git a/code/rend2/tr_local.h b/code/rend2/tr_local.h index 3d756b79..3abe5d3d 100644 --- a/code/rend2/tr_local.h +++ b/code/rend2/tr_local.h @@ -1002,12 +1002,13 @@ typedef struct { } fog_t; typedef enum { - VPF_NONE = 0x00, - VPF_SHADOWMAP = 0x01, - VPF_DEPTHSHADOW = 0x02, - VPF_DEPTHCLAMP = 0x04, - VPF_ORTHOGRAPHIC = 0x08, - VPF_USESUNLIGHT = 0x10, + VPF_NONE = 0x00, + VPF_SHADOWMAP = 0x01, + VPF_DEPTHSHADOW = 0x02, + VPF_DEPTHCLAMP = 0x04, + VPF_ORTHOGRAPHIC = 0x08, + VPF_USESUNLIGHT = 0x10, + VPF_FARPLANEFRUSTUM = 0x20 } viewParmFlags_t; typedef struct { diff --git a/code/rend2/tr_main.c b/code/rend2/tr_main.c index f91c943a..5b7ad5f7 100644 --- a/code/rend2/tr_main.c +++ b/code/rend2/tr_main.c @@ -685,11 +685,13 @@ int R_CullBox(vec3_t worldBounds[2]) { int i; cplane_t *frust; qboolean anyClip; - int r; + int r, numPlanes; + + numPlanes = (tr.viewParms.flags & VPF_FARPLANEFRUSTUM) ? 5 : 4; // check against frustum planes anyClip = qfalse; - for(i = 0; i < 4 /*FRUSTUM_PLANES*/; i++) + for(i = 0; i < numPlanes; i++) { frust = &tr.viewParms.frustum[i]; @@ -771,7 +773,7 @@ int R_CullPointAndRadiusEx( const vec3_t pt, float radius, const cplane_t* frust */ int R_CullPointAndRadius( const vec3_t pt, float radius ) { - return R_CullPointAndRadiusEx(pt, radius, tr.viewParms.frustum, ARRAY_LEN(tr.viewParms.frustum)); + return R_CullPointAndRadiusEx(pt, radius, tr.viewParms.frustum, (tr.viewParms.flags & VPF_FARPLANEFRUSTUM) ? 5 : 4); } /* @@ -1132,6 +1134,7 @@ void R_SetupFrustum (viewParms_t *dest, float xmin, float xmax, float ymax, floa dest->frustum[4].type = PLANE_NON_AXIAL; dest->frustum[4].dist = DotProduct (farpoint, dest->frustum[4].normal); SetPlaneSignbits( &dest->frustum[4] ); + dest->flags |= VPF_FARPLANEFRUSTUM; } } @@ -1316,6 +1319,8 @@ void R_SetupProjectionOrtho(viewParms_t *dest, vec3_t viewBounds[2]) dest->frustum[i].type = PLANE_NON_AXIAL; SetPlaneSignbits (&dest->frustum[i]); } + + dest->flags |= VPF_FARPLANEFRUSTUM; } /* @@ -1719,6 +1724,8 @@ qboolean R_MirrorViewBySurface (drawSurf_t *drawSurf, int entityNum) { newParms = tr.viewParms; newParms.isPortal = qtrue; + newParms.zFar = 0.0f; + newParms.flags &= ~VPF_FARPLANEFRUSTUM; if ( !R_GetPortalOrientations( drawSurf, entityNum, &surface, &camera, newParms.pvsOrigin, &newParms.isMirror ) ) { return qfalse; // bad portal, no portalentity @@ -2572,6 +2579,8 @@ void R_RenderPshadowMaps(const refdef_t *fd) dest->frustum[j].type = PLANE_NON_AXIAL; SetPlaneSignbits (&dest->frustum[j]); } + + dest->flags |= VPF_FARPLANEFRUSTUM; } for (j = 0; j < shadow->numEntities; j++) diff --git a/code/rend2/tr_surface.c b/code/rend2/tr_surface.c index aeba2c81..6f4e2b75 100644 --- a/code/rend2/tr_surface.c +++ b/code/rend2/tr_surface.c @@ -308,7 +308,7 @@ static void RB_SurfaceSprite( void ) { ri.Printf(PRINT_WARNING, "Multiple sun flares not supported\n"); return; } - if (R_CullPointAndRadiusEx(ent->e.origin, ent->e.radius, backEnd.viewParms.frustum, ARRAY_LEN(backEnd.viewParms.frustum)) == CULL_OUT) + if (R_CullPointAndRadiusEx(ent->e.origin, ent->e.radius, backEnd.viewParms.frustum, (backEnd.viewParms.flags & VPF_FARPLANEFRUSTUM) ? 5 : 4) == CULL_OUT) return; colors[0] = colors[1] = colors[2] = colors[3] = ent->e.shaderRGBA[glRefConfig.framebufferObject] / 255.0f; if (colors[0] == 0) diff --git a/code/rend2/tr_world.c b/code/rend2/tr_world.c index 54287be4..5e1bcf7b 100644 --- a/code/rend2/tr_world.c +++ b/code/rend2/tr_world.c @@ -119,11 +119,6 @@ static qboolean R_CullSurface( msurface_t *surf ) { { return qtrue; } - - if ( sphereCull == CULL_IN ) - { - return qfalse; - } } if (surf->cullinfo.type & CULLINFO_BOX) @@ -140,11 +135,6 @@ static qboolean R_CullSurface( msurface_t *surf ) { { return qtrue; } - - if ( boxCull == CULL_IN ) - { - return qfalse; - } } return qfalse; @@ -782,6 +772,8 @@ R_AddWorldSurfaces ============= */ void R_AddWorldSurfaces (void) { + int planeBits, dlightBits, pshadowBits; + if ( !r_drawworld->integer ) { return; } @@ -809,19 +801,26 @@ void R_AddWorldSurfaces (void) { tr.refdef.num_pshadows = 32 ; } + planeBits = (tr.viewParms.flags & VPF_FARPLANEFRUSTUM) ? 31 : 15; + if ( tr.viewParms.flags & VPF_DEPTHSHADOW ) { - R_RecursiveWorldNode( tr.world->nodes, 31, 0, 0); + dlightBits = 0; + pshadowBits = 0; } else if ( !(tr.viewParms.flags & VPF_SHADOWMAP) ) { - R_RecursiveWorldNode( tr.world->nodes, 15, ( 1 << tr.refdef.num_dlights ) - 1, ( 1 << tr.refdef.num_pshadows ) - 1 ); + dlightBits = ( 1 << tr.refdef.num_dlights ) - 1; + pshadowBits = ( 1 << tr.refdef.num_pshadows ) - 1; } else { - R_RecursiveWorldNode( tr.world->nodes, 31, ( 1 << tr.refdef.num_dlights ) - 1, 0 ); + dlightBits = ( 1 << tr.refdef.num_dlights ) - 1; + pshadowBits = 0; } + R_RecursiveWorldNode( tr.world->nodes, planeBits, dlightBits, pshadowBits); + // now add all the potentially visible surfaces // also mask invisible dlights for next frame {