mirror of
https://github.com/DrBeef/ioq3quest.git
synced 2024-11-23 04:12:39 +00:00
#5866: Fix surface culling through portals, and use the correct number of frustum planes.
This commit is contained in:
parent
daa9619913
commit
ed87774a77
4 changed files with 32 additions and 23 deletions
|
@ -1008,6 +1008,7 @@ typedef enum {
|
|||
VPF_DEPTHCLAMP = 0x04,
|
||||
VPF_ORTHOGRAPHIC = 0x08,
|
||||
VPF_USESUNLIGHT = 0x10,
|
||||
VPF_FARPLANEFRUSTUM = 0x20
|
||||
} viewParmFlags_t;
|
||||
|
||||
typedef struct {
|
||||
|
|
|
@ -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++)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue