mirror of
https://github.com/UberGames/lilium-voyager.git
synced 2024-12-14 06:01:10 +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
|
@ -1002,12 +1002,13 @@ typedef struct {
|
||||||
} fog_t;
|
} fog_t;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
VPF_NONE = 0x00,
|
VPF_NONE = 0x00,
|
||||||
VPF_SHADOWMAP = 0x01,
|
VPF_SHADOWMAP = 0x01,
|
||||||
VPF_DEPTHSHADOW = 0x02,
|
VPF_DEPTHSHADOW = 0x02,
|
||||||
VPF_DEPTHCLAMP = 0x04,
|
VPF_DEPTHCLAMP = 0x04,
|
||||||
VPF_ORTHOGRAPHIC = 0x08,
|
VPF_ORTHOGRAPHIC = 0x08,
|
||||||
VPF_USESUNLIGHT = 0x10,
|
VPF_USESUNLIGHT = 0x10,
|
||||||
|
VPF_FARPLANEFRUSTUM = 0x20
|
||||||
} viewParmFlags_t;
|
} viewParmFlags_t;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|
|
@ -685,11 +685,13 @@ int R_CullBox(vec3_t worldBounds[2]) {
|
||||||
int i;
|
int i;
|
||||||
cplane_t *frust;
|
cplane_t *frust;
|
||||||
qboolean anyClip;
|
qboolean anyClip;
|
||||||
int r;
|
int r, numPlanes;
|
||||||
|
|
||||||
|
numPlanes = (tr.viewParms.flags & VPF_FARPLANEFRUSTUM) ? 5 : 4;
|
||||||
|
|
||||||
// check against frustum planes
|
// check against frustum planes
|
||||||
anyClip = qfalse;
|
anyClip = qfalse;
|
||||||
for(i = 0; i < 4 /*FRUSTUM_PLANES*/; i++)
|
for(i = 0; i < numPlanes; i++)
|
||||||
{
|
{
|
||||||
frust = &tr.viewParms.frustum[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 )
|
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].type = PLANE_NON_AXIAL;
|
||||||
dest->frustum[4].dist = DotProduct (farpoint, dest->frustum[4].normal);
|
dest->frustum[4].dist = DotProduct (farpoint, dest->frustum[4].normal);
|
||||||
SetPlaneSignbits( &dest->frustum[4] );
|
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;
|
dest->frustum[i].type = PLANE_NON_AXIAL;
|
||||||
SetPlaneSignbits (&dest->frustum[i]);
|
SetPlaneSignbits (&dest->frustum[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dest->flags |= VPF_FARPLANEFRUSTUM;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1719,6 +1724,8 @@ qboolean R_MirrorViewBySurface (drawSurf_t *drawSurf, int entityNum) {
|
||||||
|
|
||||||
newParms = tr.viewParms;
|
newParms = tr.viewParms;
|
||||||
newParms.isPortal = qtrue;
|
newParms.isPortal = qtrue;
|
||||||
|
newParms.zFar = 0.0f;
|
||||||
|
newParms.flags &= ~VPF_FARPLANEFRUSTUM;
|
||||||
if ( !R_GetPortalOrientations( drawSurf, entityNum, &surface, &camera,
|
if ( !R_GetPortalOrientations( drawSurf, entityNum, &surface, &camera,
|
||||||
newParms.pvsOrigin, &newParms.isMirror ) ) {
|
newParms.pvsOrigin, &newParms.isMirror ) ) {
|
||||||
return qfalse; // bad portal, no portalentity
|
return qfalse; // bad portal, no portalentity
|
||||||
|
@ -2572,6 +2579,8 @@ void R_RenderPshadowMaps(const refdef_t *fd)
|
||||||
dest->frustum[j].type = PLANE_NON_AXIAL;
|
dest->frustum[j].type = PLANE_NON_AXIAL;
|
||||||
SetPlaneSignbits (&dest->frustum[j]);
|
SetPlaneSignbits (&dest->frustum[j]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dest->flags |= VPF_FARPLANEFRUSTUM;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (j = 0; j < shadow->numEntities; j++)
|
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");
|
ri.Printf(PRINT_WARNING, "Multiple sun flares not supported\n");
|
||||||
return;
|
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;
|
return;
|
||||||
colors[0] = colors[1] = colors[2] = colors[3] = ent->e.shaderRGBA[glRefConfig.framebufferObject] / 255.0f;
|
colors[0] = colors[1] = colors[2] = colors[3] = ent->e.shaderRGBA[glRefConfig.framebufferObject] / 255.0f;
|
||||||
if (colors[0] == 0)
|
if (colors[0] == 0)
|
||||||
|
|
|
@ -119,11 +119,6 @@ static qboolean R_CullSurface( msurface_t *surf ) {
|
||||||
{
|
{
|
||||||
return qtrue;
|
return qtrue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( sphereCull == CULL_IN )
|
|
||||||
{
|
|
||||||
return qfalse;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (surf->cullinfo.type & CULLINFO_BOX)
|
if (surf->cullinfo.type & CULLINFO_BOX)
|
||||||
|
@ -140,11 +135,6 @@ static qboolean R_CullSurface( msurface_t *surf ) {
|
||||||
{
|
{
|
||||||
return qtrue;
|
return qtrue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( boxCull == CULL_IN )
|
|
||||||
{
|
|
||||||
return qfalse;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return qfalse;
|
return qfalse;
|
||||||
|
@ -782,6 +772,8 @@ R_AddWorldSurfaces
|
||||||
=============
|
=============
|
||||||
*/
|
*/
|
||||||
void R_AddWorldSurfaces (void) {
|
void R_AddWorldSurfaces (void) {
|
||||||
|
int planeBits, dlightBits, pshadowBits;
|
||||||
|
|
||||||
if ( !r_drawworld->integer ) {
|
if ( !r_drawworld->integer ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -809,19 +801,26 @@ void R_AddWorldSurfaces (void) {
|
||||||
tr.refdef.num_pshadows = 32 ;
|
tr.refdef.num_pshadows = 32 ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
planeBits = (tr.viewParms.flags & VPF_FARPLANEFRUSTUM) ? 31 : 15;
|
||||||
|
|
||||||
if ( tr.viewParms.flags & VPF_DEPTHSHADOW )
|
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) )
|
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
|
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
|
// now add all the potentially visible surfaces
|
||||||
// also mask invisible dlights for next frame
|
// also mask invisible dlights for next frame
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue