mirror of
https://github.com/UberGames/ioef.git
synced 2024-12-01 00:21:19 +00:00
From /dev/humancontroller:
really fix the confusion with game entity and refentity numbers for any natural number M, the following is logical as a whole: - the array size for refentities is M; - the refentity number limit is M-1, ie., each refentity number is in [0..M-1]; - the special number for the world is M. before r1429, the code was roughly the following: // constants related to the game, should not be used by the renderer // renderer stuff refEntity_t refEntities[MAX_ENTITIES]; int numRefEntities = 0; void addRefEntity(refEntity_t re) { if (numRefEntities >= ENTITYNUM_WORLD) return; // full refEntities[numRefEntities++] = re; } void render(int num) { if (num == ENTITYNUM_WORLD) renderWorld(); else renderRefEntity(refEntities[num]); } so before r1429, - the array size for refentities was 1023; - the refentity number limit was 1021, ie., each refentity number was in [0..1021]; and - the special number for the world entity was 1022. this was a small waste of memory, as the last array element wasn't used. r1429 changed if (numRefEntities >= ENTITYNUM_WORLD) to if (numRefEntities >= MAX_ENTITIES). this creates the following configuration: - the array size for refentities is 1023; - the refentity number limit is 1022, ie., each refentity number is in [0..1022]; and - the special number for the world entity is 1022. r1429 just makes things worse: it allows 1 more refentity to be added, but that entity doesn't get drawn anyway, as its number will be equal to the special number for the world. this is a small waste of not only memory, but also processing time. perhaps in XreaL, ENTITYNUM_WORLD is a game entity constant, and has nothing to do with refentities. a new REFENTITYNUM_WORLD constant should be added to denote the special number for the world, and that constant should be used in the renderer code in place of ENTITYNUM_WORLD. so define such a constant, and let it be equal to MAX_ENTITIES, which is 1023.
This commit is contained in:
parent
d49d0753eb
commit
bc4ca164e0
5 changed files with 9 additions and 6 deletions
|
@ -576,7 +576,7 @@ void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) {
|
||||||
if ( entityNum != oldEntityNum ) {
|
if ( entityNum != oldEntityNum ) {
|
||||||
depthRange = isCrosshair = qfalse;
|
depthRange = isCrosshair = qfalse;
|
||||||
|
|
||||||
if ( entityNum != ENTITYNUM_WORLD ) {
|
if ( entityNum != REFENTITYNUM_WORLD ) {
|
||||||
backEnd.currentEntity = &backEnd.refdef.entities[entityNum];
|
backEnd.currentEntity = &backEnd.refdef.entities[entityNum];
|
||||||
backEnd.refdef.floatTime = originalTime - backEnd.currentEntity->e.shaderTime;
|
backEnd.refdef.floatTime = originalTime - backEnd.currentEntity->e.shaderTime;
|
||||||
// we have to reset the shaderTime as well otherwise image animations start
|
// we have to reset the shaderTime as well otherwise image animations start
|
||||||
|
|
|
@ -679,7 +679,7 @@ qboolean R_GetPortalOrientations( drawSurf_t *drawSurf, int entityNum,
|
||||||
R_PlaneForSurface( drawSurf->surface, &originalPlane );
|
R_PlaneForSurface( drawSurf->surface, &originalPlane );
|
||||||
|
|
||||||
// rotate the plane if necessary
|
// rotate the plane if necessary
|
||||||
if ( entityNum != ENTITYNUM_WORLD ) {
|
if ( entityNum != REFENTITYNUM_WORLD ) {
|
||||||
tr.currentEntityNum = entityNum;
|
tr.currentEntityNum = entityNum;
|
||||||
tr.currentEntity = &tr.refdef.entities[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 );
|
R_PlaneForSurface( drawSurf->surface, &originalPlane );
|
||||||
|
|
||||||
// rotate the plane if necessary
|
// rotate the plane if necessary
|
||||||
if ( entityNum != ENTITYNUM_WORLD )
|
if ( entityNum != REFENTITYNUM_WORLD )
|
||||||
{
|
{
|
||||||
tr.currentEntityNum = entityNum;
|
tr.currentEntityNum = entityNum;
|
||||||
tr.currentEntity = &tr.refdef.entities[entityNum];
|
tr.currentEntity = &tr.refdef.entities[entityNum];
|
||||||
|
|
|
@ -100,7 +100,7 @@ void R_AddPolygonSurfaces( void ) {
|
||||||
shader_t *sh;
|
shader_t *sh;
|
||||||
srfPoly_t *poly;
|
srfPoly_t *poly;
|
||||||
|
|
||||||
tr.currentEntityNum = ENTITYNUM_WORLD;
|
tr.currentEntityNum = REFENTITYNUM_WORLD;
|
||||||
tr.shiftedEntityNum = tr.currentEntityNum << QSORT_ENTITYNUM_SHIFT;
|
tr.shiftedEntityNum = tr.currentEntityNum << QSORT_ENTITYNUM_SHIFT;
|
||||||
|
|
||||||
for ( i = 0, poly = tr.refdef.polys; i < tr.refdef.numPolys ; i++, poly++ ) {
|
for ( i = 0, poly = tr.refdef.polys; i < tr.refdef.numPolys ; i++, poly++ ) {
|
||||||
|
|
|
@ -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 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
|
#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<<ENTITYNUM_BITS) - 1)
|
#define MAX_ENTITIES ((1<<ENTITYNUM_BITS) - 1)
|
||||||
|
#define REFENTITYNUM_WORLD ((1<<ENTITYNUM_BITS) - 1)
|
||||||
|
|
||||||
// renderfx flags
|
// renderfx flags
|
||||||
#define RF_MINLIGHT 0x0001 // allways have some light (viewmodel, some items)
|
#define RF_MINLIGHT 0x0001 // allways have some light (viewmodel, some items)
|
||||||
|
|
|
@ -58,7 +58,7 @@ static qboolean R_CullGrid( srfGridMesh_t *cv ) {
|
||||||
return qtrue;
|
return qtrue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( tr.currentEntityNum != ENTITYNUM_WORLD ) {
|
if ( tr.currentEntityNum != REFENTITYNUM_WORLD ) {
|
||||||
sphereCull = R_CullLocalPointAndRadius( cv->localOrigin, cv->meshRadius );
|
sphereCull = R_CullLocalPointAndRadius( cv->localOrigin, cv->meshRadius );
|
||||||
} else {
|
} else {
|
||||||
sphereCull = R_CullPointAndRadius( cv->localOrigin, cv->meshRadius );
|
sphereCull = R_CullPointAndRadius( cv->localOrigin, cv->meshRadius );
|
||||||
|
@ -651,7 +651,7 @@ void R_AddWorldSurfaces (void) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
tr.currentEntityNum = ENTITYNUM_WORLD;
|
tr.currentEntityNum = REFENTITYNUM_WORLD;
|
||||||
tr.shiftedEntityNum = tr.currentEntityNum << QSORT_ENTITYNUM_SHIFT;
|
tr.shiftedEntityNum = tr.currentEntityNum << QSORT_ENTITYNUM_SHIFT;
|
||||||
|
|
||||||
// determine which leaves are in the PVS / areamask
|
// determine which leaves are in the PVS / areamask
|
||||||
|
|
Loading…
Reference in a new issue