diff --git a/code/renderer/tr_backend.c b/code/renderer/tr_backend.c index f327db0e..ac321b34 100644 --- a/code/renderer/tr_backend.c +++ b/code/renderer/tr_backend.c @@ -576,7 +576,7 @@ void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) { if ( entityNum != oldEntityNum ) { depthRange = isCrosshair = qfalse; - if ( entityNum != ENTITYNUM_WORLD ) { + if ( entityNum != REFENTITYNUM_WORLD ) { backEnd.currentEntity = &backEnd.refdef.entities[entityNum]; backEnd.refdef.floatTime = originalTime - backEnd.currentEntity->e.shaderTime; // we have to reset the shaderTime as well otherwise image animations start diff --git a/code/renderer/tr_main.c b/code/renderer/tr_main.c index e6ab2533..b134345d 100644 --- a/code/renderer/tr_main.c +++ b/code/renderer/tr_main.c @@ -679,7 +679,7 @@ qboolean R_GetPortalOrientations( drawSurf_t *drawSurf, int entityNum, R_PlaneForSurface( drawSurf->surface, &originalPlane ); // rotate the plane if necessary - if ( entityNum != ENTITYNUM_WORLD ) { + if ( entityNum != REFENTITYNUM_WORLD ) { tr.currentEntityNum = entityNum; tr.currentEntity = &tr.refdef.entities[entityNum]; @@ -796,7 +796,7 @@ static qboolean IsMirror( const drawSurf_t *drawSurf, int entityNum ) R_PlaneForSurface( drawSurf->surface, &originalPlane ); // rotate the plane if necessary - if ( entityNum != ENTITYNUM_WORLD ) + if ( entityNum != REFENTITYNUM_WORLD ) { tr.currentEntityNum = entityNum; tr.currentEntity = &tr.refdef.entities[entityNum]; diff --git a/code/renderer/tr_scene.c b/code/renderer/tr_scene.c index d1d34e3c..fcbbe500 100644 --- a/code/renderer/tr_scene.c +++ b/code/renderer/tr_scene.c @@ -100,7 +100,7 @@ void R_AddPolygonSurfaces( void ) { shader_t *sh; srfPoly_t *poly; - tr.currentEntityNum = ENTITYNUM_WORLD; + tr.currentEntityNum = REFENTITYNUM_WORLD; tr.shiftedEntityNum = tr.currentEntityNum << QSORT_ENTITYNUM_SHIFT; for ( i = 0, poly = tr.refdef.polys; i < tr.refdef.numPolys ; i++, poly++ ) { diff --git a/code/renderer/tr_types.h b/code/renderer/tr_types.h index 2706b76b..d30e608a 100644 --- a/code/renderer/tr_types.h +++ b/code/renderer/tr_types.h @@ -27,7 +27,10 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #define MAX_DLIGHTS 32 // can't be increased, because bit flags are used on surfaces #define ENTITYNUM_BITS 10 // can't be increased without changing drawsurf bit packing +// the last N-bit number (2^ENTITYNUM_BITS - 1) is reserved for the special world refentity, +// and this is reflected by the value of MAX_ENTITIES (which therefore is not a power-of-2) #define MAX_ENTITIES ((1<localOrigin, cv->meshRadius ); } else { sphereCull = R_CullPointAndRadius( cv->localOrigin, cv->meshRadius ); @@ -651,7 +651,7 @@ void R_AddWorldSurfaces (void) { return; } - tr.currentEntityNum = ENTITYNUM_WORLD; + tr.currentEntityNum = REFENTITYNUM_WORLD; tr.shiftedEntityNum = tr.currentEntityNum << QSORT_ENTITYNUM_SHIFT; // determine which leaves are in the PVS / areamask