1
0
Fork 0
mirror of https://github.com/halpz/re3.git synced 2024-12-22 17:35:29 +00:00

experiment: sorted building list for new renderer

This commit is contained in:
aap 2021-02-28 19:48:15 +01:00 committed by Sergeanur
parent c58d98a39e
commit c4f231deb4

View file

@ -75,6 +75,8 @@ int32 CRenderer::ms_nNoOfVisibleVehicles;
CEntity *CRenderer::ms_aVisibleVehiclePtrs[NUMVISIBLEENTITIES]; CEntity *CRenderer::ms_aVisibleVehiclePtrs[NUMVISIBLEENTITIES];
int32 CRenderer::ms_nNoOfVisibleBuildings; int32 CRenderer::ms_nNoOfVisibleBuildings;
CEntity *CRenderer::ms_aVisibleBuildingPtrs[NUMVISIBLEENTITIES]; CEntity *CRenderer::ms_aVisibleBuildingPtrs[NUMVISIBLEENTITIES];
CLinkList<EntityInfo> gSortedBuildings;
#endif #endif
CVector CRenderer::ms_vecCameraPosition; CVector CRenderer::ms_vecCameraPosition;
@ -92,12 +94,18 @@ CRenderer::Init(void)
{ {
gSortedVehiclesAndPeds.Init(40); gSortedVehiclesAndPeds.Init(40);
SortBIGBuildings(); SortBIGBuildings();
#ifdef NEW_RENDERER
gSortedBuildings.Init(NUMVISIBLEENTITIES);
#endif
} }
void void
CRenderer::Shutdown(void) CRenderer::Shutdown(void)
{ {
gSortedVehiclesAndPeds.Shutdown(); gSortedVehiclesAndPeds.Shutdown();
#ifdef NEW_RENDERER
gSortedBuildings.Shutdown();
#endif
} }
void void
@ -114,8 +122,12 @@ CRenderer::PreRender(void)
for(i = 0; i < ms_nNoOfVisibleVehicles; i++) for(i = 0; i < ms_nNoOfVisibleVehicles; i++)
ms_aVisibleVehiclePtrs[i]->PreRender(); ms_aVisibleVehiclePtrs[i]->PreRender();
// How is this done with cWorldStream? // How is this done with cWorldStream?
for(i = 0; i < ms_nNoOfVisibleBuildings; i++) //for(i = 0; i < ms_nNoOfVisibleBuildings; i++)
ms_aVisibleBuildingPtrs[i]->PreRender(); // ms_aVisibleBuildingPtrs[i]->PreRender();
for(CLink<EntityInfo> *node = gSortedBuildings.head.next;
node != &gSortedBuildings.tail;
node = node->next)
((CEntity*)node->item.ent)->PreRender();
for(node = CVisibilityPlugins::m_alphaBuildingList.head.next; for(node = CVisibilityPlugins::m_alphaBuildingList.head.next;
node != &CVisibilityPlugins::m_alphaBuildingList.tail; node != &CVisibilityPlugins::m_alphaBuildingList.tail;
node = node->next) node = node->next)
@ -497,11 +509,20 @@ CRenderer::RenderWorld(int pass)
// Roads // Roads
PUSH_RENDERGROUP("CRenderer::RenderWorld - Roads"); PUSH_RENDERGROUP("CRenderer::RenderWorld - Roads");
RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)FALSE); RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)FALSE);
/*
for(i = 0; i < ms_nNoOfVisibleBuildings; i++){ for(i = 0; i < ms_nNoOfVisibleBuildings; i++){
e = ms_aVisibleBuildingPtrs[i]; e = ms_aVisibleBuildingPtrs[i];
if(e->bIsBIGBuilding || IsRoad(e)) if(e->bIsBIGBuilding || IsRoad(e))
RenderOneBuilding(e); RenderOneBuilding(e);
} }
*/
for(CLink<EntityInfo> *node = gSortedBuildings.tail.prev;
node != &gSortedBuildings.head;
node = node->prev){
e = node->item.ent;
if(e->bIsBIGBuilding || IsRoad(e))
RenderOneBuilding(e);
}
for(node = CVisibilityPlugins::m_alphaBuildingList.tail.prev; for(node = CVisibilityPlugins::m_alphaBuildingList.tail.prev;
node != &CVisibilityPlugins::m_alphaBuildingList.head; node != &CVisibilityPlugins::m_alphaBuildingList.head;
node = node->prev){ node = node->prev){
@ -522,11 +543,20 @@ CRenderer::RenderWorld(int pass)
// Opaque // Opaque
PUSH_RENDERGROUP("CRenderer::RenderWorld - Opaque"); PUSH_RENDERGROUP("CRenderer::RenderWorld - Opaque");
RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)FALSE); RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)FALSE);
/*
for(i = 0; i < ms_nNoOfVisibleBuildings; i++){ for(i = 0; i < ms_nNoOfVisibleBuildings; i++){
e = ms_aVisibleBuildingPtrs[i]; e = ms_aVisibleBuildingPtrs[i];
if(!(e->bIsBIGBuilding || IsRoad(e))) if(!(e->bIsBIGBuilding || IsRoad(e)))
RenderOneBuilding(e); RenderOneBuilding(e);
} }
*/
for(CLink<EntityInfo> *node = gSortedBuildings.tail.prev;
node != &gSortedBuildings.head;
node = node->prev){
e = node->item.ent;
if(!(e->bIsBIGBuilding || IsRoad(e)))
RenderOneBuilding(e);
}
for(node = CVisibilityPlugins::m_alphaBuildingList.tail.prev; for(node = CVisibilityPlugins::m_alphaBuildingList.tail.prev;
node != &CVisibilityPlugins::m_alphaBuildingList.head; node != &CVisibilityPlugins::m_alphaBuildingList.head;
node = node->prev){ node = node->prev){
@ -640,6 +670,7 @@ CRenderer::ClearForFrame(void)
ms_nNoOfVisibleBuildings = 0; ms_nNoOfVisibleBuildings = 0;
ms_nNoOfInVisibleEntities = 0; ms_nNoOfInVisibleEntities = 0;
gSortedVehiclesAndPeds.Clear(); gSortedVehiclesAndPeds.Clear();
gSortedBuildings.Clear();
WorldRender::numBlendInsts[PASS_NOZ] = 0; WorldRender::numBlendInsts[PASS_NOZ] = 0;
WorldRender::numBlendInsts[PASS_ADD] = 0; WorldRender::numBlendInsts[PASS_ADD] = 0;
@ -1438,9 +1469,13 @@ CRenderer::InsertEntityIntoList(CEntity *ent)
// TODO: there are more flags being checked here // TODO: there are more flags being checked here
if(gbNewRenderer && (ent->IsVehicle() || ent->IsPed())) if(gbNewRenderer && (ent->IsVehicle() || ent->IsPed()))
ms_aVisibleVehiclePtrs[ms_nNoOfVisibleVehicles++] = ent; ms_aVisibleVehiclePtrs[ms_nNoOfVisibleVehicles++] = ent;
else if(gbNewRenderer && ent->IsBuilding()) else if(gbNewRenderer && ent->IsBuilding()){
ms_aVisibleBuildingPtrs[ms_nNoOfVisibleBuildings++] = ent; EntityInfo info;
else info.ent = ent;
info.sort = -(ent->GetPosition() - ms_vecCameraPosition).MagnitudeSqr();
gSortedBuildings.InsertSorted(info);
// ms_aVisibleBuildingPtrs[ms_nNoOfVisibleBuildings++] = ent;
}else
#endif #endif
ms_aVisibleEntityPtrs[ms_nNoOfVisibleEntities++] = ent; ms_aVisibleEntityPtrs[ms_nNoOfVisibleEntities++] = ent;
} }