summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authoraap <aap@papnet.eu>2021-02-28 19:48:15 +0100
committerSergeanur <s.anureev@yandex.ua>2021-06-24 20:32:43 +0200
commitc4f231deb40f980e8aa80c09ab8d426b07dc0e69 (patch)
treea30a2dc816d51d6dbcf94c11eda1e0dd8997904e /src
parentfix new renderer (diff)
downloadre3-c4f231deb40f980e8aa80c09ab8d426b07dc0e69.tar
re3-c4f231deb40f980e8aa80c09ab8d426b07dc0e69.tar.gz
re3-c4f231deb40f980e8aa80c09ab8d426b07dc0e69.tar.bz2
re3-c4f231deb40f980e8aa80c09ab8d426b07dc0e69.tar.lz
re3-c4f231deb40f980e8aa80c09ab8d426b07dc0e69.tar.xz
re3-c4f231deb40f980e8aa80c09ab8d426b07dc0e69.tar.zst
re3-c4f231deb40f980e8aa80c09ab8d426b07dc0e69.zip
Diffstat (limited to 'src')
-rw-r--r--src/render/Renderer.cpp45
1 files changed, 40 insertions, 5 deletions
diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp
index b131e6c3..1c0bd445 100644
--- a/src/render/Renderer.cpp
+++ b/src/render/Renderer.cpp
@@ -75,6 +75,8 @@ int32 CRenderer::ms_nNoOfVisibleVehicles;
CEntity *CRenderer::ms_aVisibleVehiclePtrs[NUMVISIBLEENTITIES];
int32 CRenderer::ms_nNoOfVisibleBuildings;
CEntity *CRenderer::ms_aVisibleBuildingPtrs[NUMVISIBLEENTITIES];
+
+CLinkList<EntityInfo> gSortedBuildings;
#endif
CVector CRenderer::ms_vecCameraPosition;
@@ -92,12 +94,18 @@ CRenderer::Init(void)
{
gSortedVehiclesAndPeds.Init(40);
SortBIGBuildings();
+#ifdef NEW_RENDERER
+ gSortedBuildings.Init(NUMVISIBLEENTITIES);
+#endif
}
void
CRenderer::Shutdown(void)
{
gSortedVehiclesAndPeds.Shutdown();
+#ifdef NEW_RENDERER
+ gSortedBuildings.Shutdown();
+#endif
}
void
@@ -114,8 +122,12 @@ CRenderer::PreRender(void)
for(i = 0; i < ms_nNoOfVisibleVehicles; i++)
ms_aVisibleVehiclePtrs[i]->PreRender();
// How is this done with cWorldStream?
- for(i = 0; i < ms_nNoOfVisibleBuildings; i++)
- ms_aVisibleBuildingPtrs[i]->PreRender();
+ //for(i = 0; i < ms_nNoOfVisibleBuildings; i++)
+ // 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;
node != &CVisibilityPlugins::m_alphaBuildingList.tail;
node = node->next)
@@ -497,11 +509,20 @@ CRenderer::RenderWorld(int pass)
// Roads
PUSH_RENDERGROUP("CRenderer::RenderWorld - Roads");
RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)FALSE);
+/*
for(i = 0; i < ms_nNoOfVisibleBuildings; i++){
e = ms_aVisibleBuildingPtrs[i];
if(e->bIsBIGBuilding || IsRoad(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;
node != &CVisibilityPlugins::m_alphaBuildingList.head;
node = node->prev){
@@ -522,11 +543,20 @@ CRenderer::RenderWorld(int pass)
// Opaque
PUSH_RENDERGROUP("CRenderer::RenderWorld - Opaque");
RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)FALSE);
+/*
for(i = 0; i < ms_nNoOfVisibleBuildings; i++){
e = ms_aVisibleBuildingPtrs[i];
if(!(e->bIsBIGBuilding || IsRoad(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;
node != &CVisibilityPlugins::m_alphaBuildingList.head;
node = node->prev){
@@ -640,6 +670,7 @@ CRenderer::ClearForFrame(void)
ms_nNoOfVisibleBuildings = 0;
ms_nNoOfInVisibleEntities = 0;
gSortedVehiclesAndPeds.Clear();
+ gSortedBuildings.Clear();
WorldRender::numBlendInsts[PASS_NOZ] = 0;
WorldRender::numBlendInsts[PASS_ADD] = 0;
@@ -1438,9 +1469,13 @@ CRenderer::InsertEntityIntoList(CEntity *ent)
// TODO: there are more flags being checked here
if(gbNewRenderer && (ent->IsVehicle() || ent->IsPed()))
ms_aVisibleVehiclePtrs[ms_nNoOfVisibleVehicles++] = ent;
- else if(gbNewRenderer && ent->IsBuilding())
- ms_aVisibleBuildingPtrs[ms_nNoOfVisibleBuildings++] = ent;
- else
+ else if(gbNewRenderer && ent->IsBuilding()){
+ EntityInfo info;
+ info.ent = ent;
+ info.sort = -(ent->GetPosition() - ms_vecCameraPosition).MagnitudeSqr();
+ gSortedBuildings.InsertSorted(info);
+// ms_aVisibleBuildingPtrs[ms_nNoOfVisibleBuildings++] = ent;
+ }else
#endif
ms_aVisibleEntityPtrs[ms_nNoOfVisibleEntities++] = ent;
}