1
0
Fork 0
mirror of https://git.rip/DMCA_FUCKER/re3.git synced 2024-12-22 23:30:01 +00:00

Merge pull request #827 from aap/master

finished cullzones
This commit is contained in:
aap 2020-11-22 22:49:22 +01:00 committed by GitHub
commit 9b4cfa618d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 1326 additions and 104 deletions

File diff suppressed because it is too large Load diff

View file

@ -12,7 +12,7 @@ public:
float maxz; float maxz;
int32 m_indexStart; int32 m_indexStart;
int16 m_groupIndexCount[3]; int16 m_groupIndexCount[3]; // only useful during resolution stage
int16 m_numBuildings; int16 m_numBuildings;
int16 m_numTreadablesPlus10m; int16 m_numTreadablesPlus10m;
int16 m_numTreadables; int16 m_numTreadables;
@ -26,30 +26,35 @@ public:
static void DoStuffEnteringZone_OneTreadable(uint16 i); static void DoStuffEnteringZone_OneTreadable(uint16 i);
static bool TestLine(CVector a1, CVector a2); static bool TestLine(CVector vec1, CVector vec2);
static bool DoThoroughLineTest(CVector vec1, CVector vec2, CEntity *testEntity);
float CalcDistToCullZoneSquared(float x, float y); float CalcDistToCullZoneSquared(float x, float y);
float CalcDistToCullZone(float x, float y) { return Sqrt(CalcDistToCullZoneSquared(x, y)); }; float CalcDistToCullZone(float x, float y) { return Sqrt(CalcDistToCullZoneSquared(x, y)); };
bool IsEntityCloseEnoughToZone(CEntity* entity, bool checkLevel); bool IsEntityCloseEnoughToZone(CEntity* entity, bool checkLevel);
bool PointFallsWithinZone(CVector pos, float radius);
bool TestEntityVisibilityFromCullZone(CEntity *entity, float extraDist, CEntity *LODentity);
void FindTestPoints();
void GetGroupStartAndSize(int32 groupid, int32 &start, int32 &size) { void GetGroupStartAndSize(int32 groupid, int32 &start, int32 &size) {
switch (groupid) { switch (groupid) {
case 0:
default:
// buildings
start = m_indexStart;
size = m_groupIndexCount[0];
break;
case 1: case 1:
// treadables + 10m
start = m_groupIndexCount[0] + m_indexStart; start = m_groupIndexCount[0] + m_indexStart;
size = m_groupIndexCount[1]; size = m_groupIndexCount[1];
break; break;
case 2: case 2:
// treadables
start = m_groupIndexCount[0] + m_groupIndexCount[1] + m_indexStart; start = m_groupIndexCount[0] + m_groupIndexCount[1] + m_indexStart;
size = m_groupIndexCount[2]; size = m_groupIndexCount[2];
break; break;
default:
start = m_indexStart;
size = m_groupIndexCount[0];
break;
} }
} }
void FindTestPoints() {}; // todo
bool TestEntityVisibilityFromCullZone(CEntity*, float, CEntity*) { return false; }; // todo
}; };
enum eZoneAttribs enum eZoneAttribs
@ -121,5 +126,12 @@ public:
static void DoVisibilityTestCullZone(int zoneId, bool doIt); static void DoVisibilityTestCullZone(int zoneId, bool doIt);
static bool DoWeHaveMoreThanXOccurencesOfSet(int32 count, uint16 *set); static bool DoWeHaveMoreThanXOccurencesOfSet(int32 count, uint16 *set);
static void CompressIndicesArray() {};// todo static void CompressIndicesArray();
static bool PickRandomSetForGroup(int32 zone, int32 group, uint16 *set);
static void ReplaceSetForAllGroups(uint16 *set, uint16 setid);
static void TidyUpAndMergeLists(uint16 *extraIndices, int32 numExtraIndices);
// debug
static bool LoadTempFile(void);
static void SaveTempFile(void);
}; };

View file

@ -565,6 +565,9 @@ DebugMenuPopulate(void)
DebugMenuAddVarBool8("Render", "Don't render Objects", &gbDontRenderObjects, nil); DebugMenuAddVarBool8("Render", "Don't render Objects", &gbDontRenderObjects, nil);
DebugMenuAddVarBool8("Render", "Don't Render Water", &gbDontRenderWater, nil); DebugMenuAddVarBool8("Render", "Don't Render Water", &gbDontRenderWater, nil);
DebugMenuAddVarBool8("Debug", "Show cullzone debug stuff", &gbShowCullZoneDebugStuff, nil);
DebugMenuAddVarBool8("Debug", "Disable zone cull", &gbDisableZoneCull, nil);
DebugMenuAddVarBool8("Debug", "pad 1 -> pad 2", &CPad::m_bMapPadOneToPadTwo, nil); DebugMenuAddVarBool8("Debug", "pad 1 -> pad 2", &CPad::m_bMapPadOneToPadTwo, nil);
DebugMenuAddVarBool8("Debug", "Edit on", &CSceneEdit::m_bEditOn, nil); DebugMenuAddVarBool8("Debug", "Edit on", &CSceneEdit::m_bEditOn, nil);
#ifdef MENU_MAP #ifdef MENU_MAP

View file

@ -21,12 +21,14 @@
#include "Renderer.h" #include "Renderer.h"
#include "Frontend.h" #include "Frontend.h"
#include "custompipes.h" #include "custompipes.h"
#include "Debug.h"
bool gbShowPedRoadGroups; bool gbShowPedRoadGroups;
bool gbShowCarRoadGroups; bool gbShowCarRoadGroups;
bool gbShowCollisionPolys; bool gbShowCollisionPolys;
bool gbShowCollisionLines; bool gbShowCollisionLines;
bool gbShowCullZoneDebugStuff; bool gbShowCullZoneDebugStuff;
bool gbDisableZoneCull; // not original
bool gbBigWhiteDebugLightSwitchedOn; bool gbBigWhiteDebugLightSwitchedOn;
bool gbDontRenderBuildings; bool gbDontRenderBuildings;
@ -35,6 +37,25 @@ bool gbDontRenderPeds;
bool gbDontRenderObjects; bool gbDontRenderObjects;
bool gbDontRenderVehicles; bool gbDontRenderVehicles;
int32 EntitiesRendered;
int32 EntitiesNotRendered;
int32 RenderedBigBuildings;
int32 RenderedBuildings;
int32 RenderedCars;
int32 RenderedPeds;
int32 RenderedObjects;
int32 RenderedDummies;
int32 TestedBigBuildings;
int32 TestedBuildings;
int32 TestedCars;
int32 TestedPeds;
int32 TestedObjects;
int32 TestedDummies;
// unused
int16 TestCloseThings;
int16 TestBigThings;
struct EntityInfo struct EntityInfo
{ {
CEntity *ent; CEntity *ent;
@ -61,6 +82,11 @@ float CRenderer::ms_lodDistScale = 1.2f;
#define BACKFACE_CULLING_OFF #define BACKFACE_CULLING_OFF
#endif #endif
// unused
BlockedRange CRenderer::aBlockedRanges[16];
BlockedRange *CRenderer::pFullBlockedRanges;
BlockedRange *CRenderer::pEmptyBlockedRanges;
void void
CRenderer::Init(void) CRenderer::Init(void)
{ {
@ -347,6 +373,14 @@ CRenderer::RenderCollisionLines(void)
} }
} }
// unused
void
CRenderer::RenderBlockBuildingLines(void)
{
for(BlockedRange *br = pFullBlockedRanges; br; br = br->next)
printf("Blocked: %f %f\n", br->a, br->b);
}
enum Visbility enum Visbility
{ {
VIS_INVISIBLE, VIS_INVISIBLE,
@ -355,14 +389,6 @@ enum Visbility
VIS_STREAMME VIS_STREAMME
}; };
#ifdef FIX_BUGS
#define LOD_DISTANCE (300.0f*TheCamera.LODDistMultiplier)
#else
#define LOD_DISTANCE 300.0f
#endif
#define FADE_DISTANCE 20.0f
#define STREAM_DISTANCE 30.0f
// Time Objects can be time culled if // Time Objects can be time culled if
// other == -1 || CModelInfo::GetModelInfo(other)->GetRwObject() // other == -1 || CModelInfo::GetModelInfo(other)->GetRwObject()
// i.e. we have to draw even at the wrong time if // i.e. we have to draw even at the wrong time if
@ -611,7 +637,21 @@ CRenderer::ConstructRenderList(void)
ms_nNoOfVisibleEntities = 0; ms_nNoOfVisibleEntities = 0;
ms_nNoOfInVisibleEntities = 0; ms_nNoOfInVisibleEntities = 0;
ms_vecCameraPosition = TheCamera.GetPosition(); ms_vecCameraPosition = TheCamera.GetPosition();
// TODO: blocked ranges, but unused
// unused
pFullBlockedRanges = nil;
pEmptyBlockedRanges = aBlockedRanges;
for(int i = 0; i < 16; i++){
aBlockedRanges[i].prev = &aBlockedRanges[i-1];
aBlockedRanges[i].next = &aBlockedRanges[i+1];
}
aBlockedRanges[0].prev = nil;
aBlockedRanges[15].next = nil;
// unused
TestCloseThings = 0;
TestBigThings = 0;
ScanWorld(); ScanWorld();
} }
@ -647,6 +687,24 @@ CRenderer::ScanWorld(void)
RwMatrix *cammatrix; RwMatrix *cammatrix;
RwV2d poly[3]; RwV2d poly[3];
#ifndef MASTER
// missing in game but has to be done somewhere
EntitiesRendered = 0;
EntitiesNotRendered = 0;
RenderedBigBuildings = 0;
RenderedBuildings = 0;
RenderedCars = 0;
RenderedPeds = 0;
RenderedObjects = 0;
RenderedDummies = 0;
TestedBigBuildings = 0;
TestedBuildings = 0;
TestedCars = 0;
TestedPeds = 0;
TestedObjects = 0;
TestedDummies = 0;
#endif
memset(vectors, 0, sizeof(vectors)); memset(vectors, 0, sizeof(vectors));
vectors[CORNER_FAR_TOPLEFT].x = -vw.x * f; vectors[CORNER_FAR_TOPLEFT].x = -vw.x * f;
vectors[CORNER_FAR_TOPLEFT].y = vw.y * f; vectors[CORNER_FAR_TOPLEFT].y = vw.y * f;
@ -765,6 +823,19 @@ CRenderer::ScanWorld(void)
ScanBigBuildingList(CWorld::GetBigBuildingList(LEVEL_GENERIC)); ScanBigBuildingList(CWorld::GetBigBuildingList(LEVEL_GENERIC));
} }
} }
#ifndef MASTER
if(gbShowCullZoneDebugStuff){
sprintf(gString, "Rejected: %d/%d.", EntitiesNotRendered, EntitiesNotRendered + EntitiesRendered);
CDebug::PrintAt(gString, 10, 10);
sprintf(gString, "Tested:BBuild:%d Build:%d Peds:%d Cars:%d Obj:%d Dummies:%d",
TestedBigBuildings, TestedBuildings, TestedPeds, TestedCars, TestedObjects, TestedDummies);
CDebug::PrintAt(gString, 10, 11);
sprintf(gString, "Rendered:BBuild:%d Build:%d Peds:%d Cars:%d Obj:%d Dummies:%d",
RenderedBigBuildings, RenderedBuildings, RenderedPeds, RenderedCars, RenderedObjects, RenderedDummies);
CDebug::PrintAt(gString, 10, 12);
}
#endif
} }
void void
@ -1045,8 +1116,20 @@ CRenderer::ScanBigBuildingList(CPtrList &list)
for(node = list.first; node; node = node->next){ for(node = list.first; node; node = node->next){
ent = (CEntity*)node->item; ent = (CEntity*)node->item;
if(!ent->bZoneCulled && SetupBigBuildingVisibility(ent) == VIS_VISIBLE) #ifndef MASTER
ms_aVisibleEntityPtrs[ms_nNoOfVisibleEntities++] = ent; // all missing from game actually
TestedBigBuildings++;
#endif
if(!ent->bZoneCulled){
if(SetupBigBuildingVisibility(ent) == VIS_VISIBLE)
ms_aVisibleEntityPtrs[ms_nNoOfVisibleEntities++] = ent;
#ifndef MASTER
EntitiesRendered++;
RenderedBigBuildings++;
}else{
EntitiesNotRendered++;
#endif
}
} }
} }
@ -1067,7 +1150,7 @@ CRenderer::ScanSectorList(CPtrList *lists)
continue; // already seen continue; // already seen
ent->m_scanCode = CWorld::GetCurrentScanCode(); ent->m_scanCode = CWorld::GetCurrentScanCode();
if(IsEntityCullZoneVisible(ent)) if(IsEntityCullZoneVisible(ent)){
switch(SetupEntityVisibility(ent)){ switch(SetupEntityVisibility(ent)){
case VIS_VISIBLE: case VIS_VISIBLE:
ms_aVisibleEntityPtrs[ms_nNoOfVisibleEntities++] = ent; ms_aVisibleEntityPtrs[ms_nNoOfVisibleEntities++] = ent;
@ -1090,11 +1173,37 @@ CRenderer::ScanSectorList(CPtrList *lists)
CStreaming::RequestModel(ent->GetModelIndex(), 0); CStreaming::RequestModel(ent->GetModelIndex(), 0);
break; break;
} }
else if(ent->IsBuilding() && ((CBuilding*)ent)->GetIsATreadable()){ #ifndef MASTER
if(!CStreaming::ms_disableStreaming) EntitiesRendered++;
if(SetupEntityVisibility(ent) == VIS_STREAMME) switch(ent->GetType()){
if(!m_loadingPriority || CStreaming::ms_numModelsRequested < 10) case ENTITY_TYPE_BUILDING:
CStreaming::RequestModel(ent->GetModelIndex(), 0); if(ent->bIsBIGBuilding)
RenderedBigBuildings++;
else
RenderedBuildings++;
break;
case ENTITY_TYPE_VEHICLE:
RenderedCars++;
break;
case ENTITY_TYPE_PED:
RenderedPeds++;
break;
case ENTITY_TYPE_OBJECT:
RenderedObjects++;
break;
case ENTITY_TYPE_DUMMY:
RenderedDummies++;
break;
}
#endif
}else if(ent->IsBuilding() && ((CBuilding*)ent)->GetIsATreadable() && !CStreaming::ms_disableStreaming){
if(SetupEntityVisibility(ent) == VIS_STREAMME)
if(!m_loadingPriority || CStreaming::ms_numModelsRequested < 10)
CStreaming::RequestModel(ent->GetModelIndex(), 0);
}else{
#ifndef MASTER
EntitiesNotRendered++;
#endif
} }
} }
} }
@ -1117,7 +1226,7 @@ CRenderer::ScanSectorList_Priority(CPtrList *lists)
continue; // already seen continue; // already seen
ent->m_scanCode = CWorld::GetCurrentScanCode(); ent->m_scanCode = CWorld::GetCurrentScanCode();
if(IsEntityCullZoneVisible(ent)) if(IsEntityCullZoneVisible(ent)){
switch(SetupEntityVisibility(ent)){ switch(SetupEntityVisibility(ent)){
case VIS_VISIBLE: case VIS_VISIBLE:
ms_aVisibleEntityPtrs[ms_nNoOfVisibleEntities++] = ent; ms_aVisibleEntityPtrs[ms_nNoOfVisibleEntities++] = ent;
@ -1142,10 +1251,38 @@ CRenderer::ScanSectorList_Priority(CPtrList *lists)
} }
break; break;
} }
else if(ent->IsBuilding() && ((CBuilding*)ent)->GetIsATreadable()){ #ifndef MASTER
if(!CStreaming::ms_disableStreaming) // actually missing in game
if(SetupEntityVisibility(ent) == VIS_STREAMME) EntitiesRendered++;
CStreaming::RequestModel(ent->GetModelIndex(), 0); switch(ent->GetType()){
case ENTITY_TYPE_BUILDING:
if(ent->bIsBIGBuilding)
RenderedBigBuildings++;
else
RenderedBuildings++;
break;
case ENTITY_TYPE_VEHICLE:
RenderedCars++;
break;
case ENTITY_TYPE_PED:
RenderedPeds++;
break;
case ENTITY_TYPE_OBJECT:
RenderedObjects++;
break;
case ENTITY_TYPE_DUMMY:
RenderedDummies++;
break;
}
#endif
}else if(ent->IsBuilding() && ((CBuilding*)ent)->GetIsATreadable() && !CStreaming::ms_disableStreaming){
if(SetupEntityVisibility(ent) == VIS_STREAMME)
CStreaming::RequestModel(ent->GetModelIndex(), 0);
}else{
#ifndef MASTER
// actually missing in game
EntitiesNotRendered++;
#endif
} }
} }
} }
@ -1251,9 +1388,34 @@ CRenderer::IsEntityCullZoneVisible(CEntity *ent)
CPed *ped; CPed *ped;
CObject *obj; CObject *obj;
if(gbDisableZoneCull) return true;
#ifndef MASTER
switch(ent->GetType()){
case ENTITY_TYPE_BUILDING:
if(ent->bIsBIGBuilding)
TestedBigBuildings++;
else
TestedBuildings++;
break;
case ENTITY_TYPE_VEHICLE:
TestedCars++;
break;
case ENTITY_TYPE_PED:
TestedPeds++;
break;
case ENTITY_TYPE_OBJECT:
TestedObjects++;
break;
case ENTITY_TYPE_DUMMY:
TestedDummies++;
break;
}
#endif
if(ent->bZoneCulled) if(ent->bZoneCulled)
return false; return false;
switch(ent->GetType()){ switch(ent->GetType()){
case ENTITY_TYPE_VEHICLE: case ENTITY_TYPE_VEHICLE:
return IsVehicleCullZoneVisible(ent); return IsVehicleCullZoneVisible(ent);

View file

@ -2,11 +2,20 @@
class CEntity; class CEntity;
#ifdef FIX_BUGS
#define LOD_DISTANCE (300.0f*TheCamera.LODDistMultiplier)
#else
#define LOD_DISTANCE 300.0f
#endif
#define FADE_DISTANCE 20.0f
#define STREAM_DISTANCE 30.0f
extern bool gbShowPedRoadGroups; extern bool gbShowPedRoadGroups;
extern bool gbShowCarRoadGroups; extern bool gbShowCarRoadGroups;
extern bool gbShowCollisionPolys; extern bool gbShowCollisionPolys;
extern bool gbShowCollisionLines; extern bool gbShowCollisionLines;
extern bool gbShowCullZoneDebugStuff; extern bool gbShowCullZoneDebugStuff;
extern bool gbDisableZoneCull; // not original
extern bool gbBigWhiteDebugLightSwitchedOn; extern bool gbBigWhiteDebugLightSwitchedOn;
extern bool gbDontRenderBuildings; extern bool gbDontRenderBuildings;
@ -18,6 +27,13 @@ extern bool gbDontRenderVehicles;
class CVehicle; class CVehicle;
class CPtrList; class CPtrList;
// unused
struct BlockedRange
{
float a, b; // unknown
BlockedRange *prev, *next;
};
class CRenderer class CRenderer
{ {
static int32 ms_nNoOfVisibleEntities; static int32 ms_nNoOfVisibleEntities;
@ -28,6 +44,10 @@ class CRenderer
static CVector ms_vecCameraPosition; static CVector ms_vecCameraPosition;
static CVehicle *m_pFirstPersonVehicle; static CVehicle *m_pFirstPersonVehicle;
// unused
static BlockedRange aBlockedRanges[16];
static BlockedRange *pFullBlockedRanges;
static BlockedRange *pEmptyBlockedRanges;
public: public:
static float ms_lodDistScale; static float ms_lodDistScale;
static bool m_loadingPriority; static bool m_loadingPriority;
@ -46,6 +66,8 @@ public:
static void RenderFirstPersonVehicle(void); static void RenderFirstPersonVehicle(void);
static void RenderCollisionLines(void); static void RenderCollisionLines(void);
// unused
static void RenderBlockBuildingLines(void);
static int32 SetupEntityVisibility(CEntity *ent); static int32 SetupEntityVisibility(CEntity *ent);
static int32 SetupBigBuildingVisibility(CEntity *ent); static int32 SetupBigBuildingVisibility(CEntity *ent);

View file

@ -11,8 +11,6 @@
#include "World.h" #include "World.h"
#include "custompipes.h" #include "custompipes.h"
#define FADE_DISTANCE 20.0f
CLinkList<CVisibilityPlugins::AlphaObjectInfo> CVisibilityPlugins::m_alphaList; CLinkList<CVisibilityPlugins::AlphaObjectInfo> CVisibilityPlugins::m_alphaList;
CLinkList<CVisibilityPlugins::AlphaObjectInfo> CVisibilityPlugins::m_alphaEntityList; CLinkList<CVisibilityPlugins::AlphaObjectInfo> CVisibilityPlugins::m_alphaEntityList;