diff --git a/source/ref_nri/r_alias.c b/source/ref_nri/r_alias.c index 9bf0bad68a..e62c7b07eb 100644 --- a/source/ref_nri/r_alias.c +++ b/source/ref_nri/r_alias.c @@ -787,7 +787,7 @@ bool R_AddAliasModelToDrawList( const entity_t *e ) if( e->renderfx & RF_WEAPONMODEL ) { return true; } - if( rsc.entShadowGroups[R_ENT2NUM(e)] != rn.shadowGroup->id ) { + if( rsc.entShadowGroups[e - rsc.entities] != rn.shadowGroup->id ) { return true; } } diff --git a/source/ref_nri/r_frontend.c b/source/ref_nri/r_frontend.c index 76c8ffc1c2..c06be6f698 100644 --- a/source/ref_nri/r_frontend.c +++ b/source/ref_nri/r_frontend.c @@ -31,7 +31,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. static ref_frontend_t rrf; -static void __ShutdownSwapchainTexture(); +static void __DisposeSwapchainTexture(); static void __R_InitVolatileAssets( void ) { @@ -60,7 +60,7 @@ static void __R_InitVolatileAssets( void ) } } -static void __ShutdownSwapchainTexture() { +static void __DisposeSwapchainTexture() { if(rsh.swapchain) { for( size_t i = 0; i < arrlen( rsh.backBuffers ); i++ ) { struct frame_tex_buffers_s *backBuffer = &rsh.backBuffers[i]; @@ -235,7 +235,7 @@ rserr_t RF_SetMode( int x, int y, int width, int height, int displayFrequency, b } NriSwapChainDesc swapChainDesc = { .commandQueue = rsh.nri.graphicsCommandQueue, .width = width, .height = height, .format = DefaultSwapchainFormat, .textureNum = 3, .window = nriWindow }; - __ShutdownSwapchainTexture(); + __DisposeSwapchainTexture(); assert(rsh.frameFence == NULL); NRI_ABORT_ON_FAILURE( rsh.nri.coreI.CreateFence( rsh.nri.device, 0, &rsh.frameFence ) ); @@ -385,7 +385,7 @@ void RF_Shutdown( bool verbose ) FrameCmdBufferFree(&rsh.frameCmds[i]); } - __ShutdownSwapchainTexture(); + __DisposeSwapchainTexture(); ri.Mutex_Destroy( &rf.speedsMsgLock ); ri.Mutex_Destroy( &rf.debugSurfaceLock ); diff --git a/source/ref_nri/r_local.h b/source/ref_nri/r_local.h index cda6dcc8b3..fff5b3ccee 100644 --- a/source/ref_nri/r_local.h +++ b/source/ref_nri/r_local.h @@ -418,9 +418,6 @@ extern r_shared_t rsh; extern r_scene_t rsc; extern r_globals_t rf; -#define R_ENT2NUM(ent) ((ent)-rsc.entities) -#define R_NUM2ENT(num) (rsc.entities+(num)) - extern cvar_t *vid_width; extern cvar_t *vid_height; extern cvar_t *vid_xpos; // X coordinate of window position diff --git a/source/ref_nri/r_main.c b/source/ref_nri/r_main.c index cf99f07293..5962d85141 100644 --- a/source/ref_nri/r_main.c +++ b/source/ref_nri/r_main.c @@ -1084,7 +1084,7 @@ static void R_EndGL( struct frame_cmd_buffer_s* frame ) static void R_DrawEntities( void ) { unsigned int i; - entity_t *e; + ; bool shadowmap = ( ( rn.renderFlags & RF_SHADOWMAPVIEW ) != 0 ); bool culled = true; @@ -1092,7 +1092,7 @@ static void R_DrawEntities( void ) { for( i = 0; i < rsc.numBmodelEntities; i++ ) { - e = rsc.bmodelEntities[i]; + entity_t *e = rsc.bmodelEntities[i]; if( !r_lerpmodels->integer ) e->backlerp = 0; e->outlineHeight = rsc.worldent->outlineHeight; @@ -1104,7 +1104,7 @@ static void R_DrawEntities( void ) for( i = rsc.numLocalEntities; i < rsc.numEntities; i++ ) { - e = R_NUM2ENT(i); + entity_t *e = &rsc.entities[i]; culled = true; if( !r_lerpmodels->integer ) @@ -1487,7 +1487,7 @@ void R_RenderDebugSurface( const refdef_t *fd ) R_ClearDrawList( rn.portalmasklist ); - if( R_AddSurfToDrawList( rn.meshlist, R_NUM2ENT(tr.ent), NULL, surf->shader, 0, 0, NULL, surf->drawSurf ) ) { + if( R_AddSurfToDrawList( rn.meshlist, &rsc.entities[tr.ent], NULL, surf->shader, 0, 0, NULL, surf->drawSurf ) ) { if( rn.refdef.rdflags & RDF_FLIPPED ) { RB_FlipFrontFace(NULL); } diff --git a/source/ref_nri/r_mesh.c b/source/ref_nri/r_mesh.c index 1e60056816..afd6cdeca9 100644 --- a/source/ref_nri/r_mesh.c +++ b/source/ref_nri/r_mesh.c @@ -216,7 +216,7 @@ void *R_AddSurfToDrawList( drawList_t *list, const entity_t *e, const mfog_t *fo sds = &list->drawSurfs[list->numDrawSurfs++]; sds->distKey = R_PackDistKey( shaderSort, (int)dist, order ); sds->sortKey = R_PackSortKey( shader->id, fog ? fog - rsh.worldBrushModel->fogs : -1, - portalSurf ? portalSurf - rn.portalSurfaces : -1, R_ENT2NUM(e) ); + portalSurf ? portalSurf - rn.portalSurfaces : -1, (e - rsc.entities) ); sds->drawSurf = ( drawSurfaceType_t * )drawSurf; return sds; @@ -446,7 +446,7 @@ static void _R_DrawSurfaces(struct frame_cmd_buffer_s* frame, drawList_t *list ) R_UnpackSortKey( sortKey, &shaderNum, &fogNum, &portalNum, &entNum ); shader = R_ShaderById( shaderNum ); - entity = R_NUM2ENT(entNum); + entity = &rsc.entities[entNum]; fog = fogNum >= 0 ? rsh.worldBrushModel->fogs + fogNum : NULL; portalSurface = portalNum >= 0 ? rn.portalSurfaces + portalNum : NULL; entityFX = entity->renderfx; diff --git a/source/ref_nri/r_portals.c b/source/ref_nri/r_portals.c index 3610fd6e2e..91b3a49a00 100644 --- a/source/ref_nri/r_portals.c +++ b/source/ref_nri/r_portals.c @@ -349,7 +349,7 @@ static void R_DrawPortalSurface( struct frame_cmd_buffer_s *cmd, portalSurface_t best_d = 100000000; for( i = rsc.numLocalEntities; i < rsc.numEntities; i++ ) { - ent = R_NUM2ENT(i); + ent = &rsc.entities[i]; if( ent->rtype != RT_PORTALSURFACE ) continue; diff --git a/source/ref_nri/r_scene.c b/source/ref_nri/r_scene.c index ac428d9511..e484acb7e8 100644 --- a/source/ref_nri/r_scene.c +++ b/source/ref_nri/r_scene.c @@ -34,21 +34,21 @@ void R_ClearScene( void ) rsc.numDlights = 0; rsc.numPolys = 0; - rsc.worldent = R_NUM2ENT( rsc.numLocalEntities ); + rsc.worldent = &rsc.entities[rsc.numLocalEntities]; rsc.worldent->scale = 1.0f; rsc.worldent->model = rsh.worldModel; rsc.worldent->rtype = RT_MODEL; Matrix3_Identity( rsc.worldent->axis ); rsc.numLocalEntities++; - rsc.polyent = R_NUM2ENT( rsc.numLocalEntities ); + rsc.polyent = &rsc.entities[rsc.numLocalEntities]; rsc.polyent->scale = 1.0f; rsc.polyent->model = NULL; rsc.polyent->rtype = RT_MODEL; Matrix3_Identity( rsc.polyent->axis ); rsc.numLocalEntities++; - rsc.skyent = R_NUM2ENT( rsc.numLocalEntities ); + rsc.skyent = &rsc.entities[rsc.numLocalEntities]; *rsc.skyent = *rsc.worldent; rsc.numLocalEntities++; @@ -77,7 +77,7 @@ void R_AddEntityToScene( const entity_t *ent ) if( ( ( rsc.numEntities - rsc.numLocalEntities ) < MAX_ENTITIES ) && ent ) { int eNum = rsc.numEntities; - entity_t *de = R_NUM2ENT(eNum); + entity_t *de = &rsc.entities[eNum]; *de = *ent; if( r_outlines_scale->value <= 0 ) diff --git a/source/ref_nri/r_shadow.c b/source/ref_nri/r_shadow.c index 67121e41b9..d10a316282 100644 --- a/source/ref_nri/r_shadow.c +++ b/source/ref_nri/r_shadow.c @@ -147,7 +147,8 @@ bool R_AddLightOccluder( const entity_t *ent ) return false; } - rsc.entShadowGroups[R_ENT2NUM(ent)] = group->id; + + rsc.entShadowGroups[ent - rsc.entities] = group->id; if( ent->flags & RF_WEAPONMODEL ) return true; diff --git a/source/ref_nri/r_skm.c b/source/ref_nri/r_skm.c index 56dc7e870c..7bfb942dbd 100644 --- a/source/ref_nri/r_skm.c +++ b/source/ref_nri/r_skm.c @@ -1246,7 +1246,7 @@ void R_DrawSkeletalSurf(struct frame_cmd_buffer_s* cmd, const entity_t *e, const bonePoseRelativeDQSize = sizeof( dualquat_t ) * skmodel->numbones; // fetch bones tranforms from cache (both matrices and dual quaternions) - bonePoseRelativeDQ = ( dualquat_t * )R_GetSkeletalCache( R_ENT2NUM( e ), mod->lodnum ); + bonePoseRelativeDQ = ( dualquat_t * )R_GetSkeletalCache( e - rsc.entities, mod->lodnum ); if( bonePoseRelativeDQ ) { bonePoseRelativeMat = ( mat4_t * )(( uint8_t * )bonePoseRelativeDQ + bonePoseRelativeDQSize); } @@ -1310,8 +1310,7 @@ void R_DrawSkeletalSurf(struct frame_cmd_buffer_s* cmd, const entity_t *e, const } } - bonePoseRelativeDQ = ( dualquat_t * )R_AllocSkeletalDataCache( R_ENT2NUM( e ), mod->lodnum, - bonePoseRelativeDQSize + bonePoseRelativeMatSize ); + bonePoseRelativeDQ = (dualquat_t *)R_AllocSkeletalDataCache( e - rsc.entities, mod->lodnum, bonePoseRelativeDQSize + bonePoseRelativeMatSize ); // generate dual quaternions for all bones for( i = 0; i < skmodel->numbones; i++ ) { @@ -1460,7 +1459,7 @@ bool R_AddSkeletalModelToDrawList( const entity_t *e ) if( e->renderfx & RF_WEAPONMODEL ) { return true; } - if( rsc.entShadowGroups[R_ENT2NUM(e)] != rn.shadowGroup->id ) { + if( rsc.entShadowGroups[(e - rsc.entities)] != rn.shadowGroup->id ) { return true; } } diff --git a/source/ref_nri/r_surf.c b/source/ref_nri/r_surf.c index 5e1c56779a..0906f8c4d0 100644 --- a/source/ref_nri/r_surf.c +++ b/source/ref_nri/r_surf.c @@ -462,7 +462,7 @@ bool R_AddBrushModelToDrawList( const entity_t *e ) // never render weapon models or non-occluders into shadowmaps if( rn.renderFlags & RF_SHADOWMAPVIEW ) { - if( rsc.entShadowGroups[R_ENT2NUM(e)] != rn.shadowGroup->id ) { + if( rsc.entShadowGroups[e - rsc.entities] != rn.shadowGroup->id ) { return true; } } diff --git a/source/ref_nri/r_trace.c b/source/ref_nri/r_trace.c index 0f29cdff18..568263b143 100644 --- a/source/ref_nri/r_trace.c +++ b/source/ref_nri/r_trace.c @@ -308,7 +308,7 @@ static msurface_t *R_TransformedTraceLine( rtrace_t *tr, const vec3_t start, con tr->shader = trace_surface->shader; tr->plane = trace_plane; tr->surfFlags = trace_surface->flags; - tr->ent = R_ENT2NUM(test); + tr->ent = (test - rsc.entities); } tr->fraction = trace_fraction;