mirror of
https://github.com/FWGS/xash3d-fwgs.git
synced 2026-08-05 03:24:56 +08:00
ref: gl: mirror entities culling
This commit is contained in:
@@ -119,6 +119,10 @@ qboolean R_BeamCull( const vec3_t start, const vec3_t end, qboolean pvsOnly )
|
||||
vec3_t mins, maxs;
|
||||
int i;
|
||||
|
||||
// support for custom mirror management
|
||||
if( RI.currentbeam && R_CullEntityInMirror( RI.currentbeam ))
|
||||
return true;
|
||||
|
||||
for( i = 0; i < 3; i++ )
|
||||
{
|
||||
if( start[i] < end[i] )
|
||||
|
||||
@@ -35,6 +35,31 @@ qboolean R_CullBox( const vec3_t mins, const vec3_t maxs )
|
||||
return GL_FrustumCullBox( &RI.frustum, mins, maxs, 0 );
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
R_CullEntityInMirror
|
||||
|
||||
decide whether entity should be reflected in mirror
|
||||
=================
|
||||
*/
|
||||
qboolean R_CullEntityInMirror( cl_entity_t *e )
|
||||
{
|
||||
if( FBitSet( RI.params, RP_MIRRORVIEW ))
|
||||
{
|
||||
// cull this entity out of mirrors but not normal views
|
||||
if( FBitSet( e->curstate.effects, EF_NOREFLECT ))
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// cull this entity out of normal views but not mirrors
|
||||
if( FBitSet( e->curstate.effects, EF_REFLECTONLY ))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
=============
|
||||
R_CullModel
|
||||
@@ -53,6 +78,9 @@ int R_CullModel( cl_entity_t *e, const vec3_t absmin, const vec3_t absmax )
|
||||
return 1;
|
||||
}
|
||||
|
||||
if( R_CullEntityInMirror( e ))
|
||||
return 1;
|
||||
|
||||
if( R_CullBox( absmin, absmax ))
|
||||
return 1;
|
||||
|
||||
@@ -98,7 +126,7 @@ int R_CullSurface( msurface_t *surf, gl_frustum_t *frustum, uint clipflags )
|
||||
}
|
||||
else dist = PlaneDiff( tr.modelorg, surf->plane );
|
||||
|
||||
if( glState.faceCull == GL_FRONT )
|
||||
if( glState.faceCull == GL_FRONT || FBitSet( RI.params, RP_MIRRORVIEW ))
|
||||
{
|
||||
if( FBitSet( surf->flags, SURF_PLANEBACK ))
|
||||
{
|
||||
|
||||
@@ -84,8 +84,9 @@ extern poolhandle_t r_temppool;
|
||||
#define RP_ENVVIEW BIT( 0 ) // used for cubemapshot
|
||||
#define RP_OLDVIEWLEAF BIT( 1 )
|
||||
#define RP_CLIPPLANE BIT( 2 )
|
||||
#define RP_MIRRORVIEW BIT( 3 ) // lock pvs at vieworg
|
||||
|
||||
#define RP_NONVIEWERREF (RP_ENVVIEW)
|
||||
#define RP_NONVIEWERREF (RP_ENVVIEW|RP_MIRRORVIEW)
|
||||
#define R_ModelOpaque( rm ) ( rm == kRenderNormal )
|
||||
#define R_StaticEntity( ent ) ( VectorIsNull( ent->origin ) && VectorIsNull( ent->angles ))
|
||||
#define RP_LOCALCLIENT( e ) ((e) != NULL && (e)->index == ( gp_cl->playernum + 1 ) && e->player )
|
||||
@@ -324,6 +325,7 @@ qboolean R_BeamCull( const vec3_t start, const vec3_t end, qboolean pvsOnly );
|
||||
//
|
||||
int R_CullModel( cl_entity_t *e, const vec3_t absmin, const vec3_t absmax );
|
||||
qboolean R_CullBox( const vec3_t mins, const vec3_t maxs );
|
||||
qboolean R_CullEntityInMirror( cl_entity_t *e );
|
||||
int R_CullSurface( msurface_t *surf, gl_frustum_t *frustum, uint clipflags );
|
||||
|
||||
//
|
||||
@@ -541,7 +543,6 @@ void R_DrawStretchRaw( float x, float y, float w, float h, int cols, int rows, c
|
||||
void R_DrawStretchPic( float x, float y, float w, float h, float s1, float t1, float s2, float t2, int texnum );
|
||||
qboolean R_SpeedsMessage( char *out, size_t size );
|
||||
void R_SetupSky( const char *skyboxname );
|
||||
qboolean R_CullBox( const vec3_t mins, const vec3_t maxs );
|
||||
int R_WorldToScreen( const vec3_t point, vec3_t screen );
|
||||
void R_ScreenToWorld( const vec3_t screen, vec3_t point );
|
||||
qboolean R_AddEntity( struct cl_entity_s *pRefEntity, int entityType );
|
||||
|
||||
@@ -1551,6 +1551,9 @@ void R_DrawBrushModel( cl_entity_t *e )
|
||||
if( clmodel->surfaces != WORLDMODEL->surfaces )
|
||||
allow_vbo = false;
|
||||
|
||||
if( R_CullEntityInMirror( e ))
|
||||
return;
|
||||
|
||||
if( !VectorIsNull( e->angles ))
|
||||
{
|
||||
for( i = 0; i < 3; i++ )
|
||||
|
||||
@@ -701,6 +701,9 @@ static qboolean R_SpriteOccluded( cl_entity_t *e, vec3_t origin, float *pscale )
|
||||
float blend;
|
||||
vec3_t v;
|
||||
|
||||
if( R_CullEntityInMirror( e ))
|
||||
return;
|
||||
|
||||
TriWorldToScreen( origin, v );
|
||||
|
||||
if( v[0] < RI.viewport[0] || v[0] > RI.viewport[0] + RI.viewport[2] )
|
||||
|
||||
Reference in New Issue
Block a user