mirror of
https://gitlab.com/GaryOderNichts/re3-wiiu.git
synced 2024-11-30 04:54:15 +01:00
finished cullzones
This commit is contained in:
parent
02c7f8381b
commit
07303c62d1
File diff suppressed because it is too large
Load Diff
@ -12,7 +12,7 @@ public:
|
||||
float maxz;
|
||||
|
||||
int32 m_indexStart;
|
||||
int16 m_groupIndexCount[3];
|
||||
int16 m_groupIndexCount[3]; // only useful during resolution stage
|
||||
int16 m_numBuildings;
|
||||
int16 m_numTreadablesPlus10m;
|
||||
int16 m_numTreadables;
|
||||
@ -26,30 +26,35 @@ public:
|
||||
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 CalcDistToCullZone(float x, float y) { return Sqrt(CalcDistToCullZoneSquared(x, y)); };
|
||||
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) {
|
||||
switch (groupid) {
|
||||
case 0:
|
||||
default:
|
||||
// buildings
|
||||
start = m_indexStart;
|
||||
size = m_groupIndexCount[0];
|
||||
break;
|
||||
case 1:
|
||||
// treadables + 10m
|
||||
start = m_groupIndexCount[0] + m_indexStart;
|
||||
size = m_groupIndexCount[1];
|
||||
break;
|
||||
case 2:
|
||||
// treadables
|
||||
start = m_groupIndexCount[0] + m_groupIndexCount[1] + m_indexStart;
|
||||
size = m_groupIndexCount[2];
|
||||
break;
|
||||
default:
|
||||
start = m_indexStart;
|
||||
size = m_groupIndexCount[0];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void FindTestPoints() {}; // todo
|
||||
bool TestEntityVisibilityFromCullZone(CEntity*, float, CEntity*) { return false; }; // todo
|
||||
};
|
||||
|
||||
enum eZoneAttribs
|
||||
@ -121,5 +126,12 @@ public:
|
||||
static void DoVisibilityTestCullZone(int zoneId, bool doIt);
|
||||
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);
|
||||
};
|
||||
|
@ -565,6 +565,9 @@ DebugMenuPopulate(void)
|
||||
DebugMenuAddVarBool8("Render", "Don't render Objects", &gbDontRenderObjects, 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", "Edit on", &CSceneEdit::m_bEditOn, nil);
|
||||
#ifdef MENU_MAP
|
||||
|
@ -21,12 +21,14 @@
|
||||
#include "Renderer.h"
|
||||
#include "Frontend.h"
|
||||
#include "custompipes.h"
|
||||
#include "Debug.h"
|
||||
|
||||
bool gbShowPedRoadGroups;
|
||||
bool gbShowCarRoadGroups;
|
||||
bool gbShowCollisionPolys;
|
||||
bool gbShowCollisionLines;
|
||||
bool gbShowCullZoneDebugStuff;
|
||||
bool gbDisableZoneCull; // not original
|
||||
bool gbBigWhiteDebugLightSwitchedOn;
|
||||
|
||||
bool gbDontRenderBuildings;
|
||||
@ -35,6 +37,25 @@ bool gbDontRenderPeds;
|
||||
bool gbDontRenderObjects;
|
||||
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
|
||||
{
|
||||
CEntity *ent;
|
||||
@ -61,6 +82,11 @@ float CRenderer::ms_lodDistScale = 1.2f;
|
||||
#define BACKFACE_CULLING_OFF
|
||||
#endif
|
||||
|
||||
// unused
|
||||
BlockedRange CRenderer::aBlockedRanges[16];
|
||||
BlockedRange *CRenderer::pFullBlockedRanges;
|
||||
BlockedRange *CRenderer::pEmptyBlockedRanges;
|
||||
|
||||
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
|
||||
{
|
||||
VIS_INVISIBLE,
|
||||
@ -355,14 +389,6 @@ enum Visbility
|
||||
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
|
||||
// other == -1 || CModelInfo::GetModelInfo(other)->GetRwObject()
|
||||
// i.e. we have to draw even at the wrong time if
|
||||
@ -611,7 +637,21 @@ CRenderer::ConstructRenderList(void)
|
||||
ms_nNoOfVisibleEntities = 0;
|
||||
ms_nNoOfInVisibleEntities = 0;
|
||||
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();
|
||||
}
|
||||
|
||||
@ -647,6 +687,24 @@ CRenderer::ScanWorld(void)
|
||||
RwMatrix *cammatrix;
|
||||
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));
|
||||
vectors[CORNER_FAR_TOPLEFT].x = -vw.x * f;
|
||||
vectors[CORNER_FAR_TOPLEFT].y = vw.y * f;
|
||||
@ -765,6 +823,19 @@ CRenderer::ScanWorld(void)
|
||||
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
|
||||
@ -1014,8 +1085,20 @@ CRenderer::ScanBigBuildingList(CPtrList &list)
|
||||
|
||||
for(node = list.first; node; node = node->next){
|
||||
ent = (CEntity*)node->item;
|
||||
if(!ent->bZoneCulled && SetupBigBuildingVisibility(ent) == VIS_VISIBLE)
|
||||
#ifndef MASTER
|
||||
// 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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1036,7 +1119,7 @@ CRenderer::ScanSectorList(CPtrList *lists)
|
||||
continue; // already seen
|
||||
ent->m_scanCode = CWorld::GetCurrentScanCode();
|
||||
|
||||
if(IsEntityCullZoneVisible(ent))
|
||||
if(IsEntityCullZoneVisible(ent)){
|
||||
switch(SetupEntityVisibility(ent)){
|
||||
case VIS_VISIBLE:
|
||||
ms_aVisibleEntityPtrs[ms_nNoOfVisibleEntities++] = ent;
|
||||
@ -1059,11 +1142,37 @@ CRenderer::ScanSectorList(CPtrList *lists)
|
||||
CStreaming::RequestModel(ent->GetModelIndex(), 0);
|
||||
break;
|
||||
}
|
||||
else if(ent->IsBuilding() && ((CBuilding*)ent)->GetIsATreadable()){
|
||||
if(!CStreaming::ms_disableStreaming)
|
||||
#ifndef MASTER
|
||||
EntitiesRendered++;
|
||||
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)
|
||||
if(!m_loadingPriority || CStreaming::ms_numModelsRequested < 10)
|
||||
CStreaming::RequestModel(ent->GetModelIndex(), 0);
|
||||
}else{
|
||||
#ifndef MASTER
|
||||
EntitiesNotRendered++;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1086,7 +1195,7 @@ CRenderer::ScanSectorList_Priority(CPtrList *lists)
|
||||
continue; // already seen
|
||||
ent->m_scanCode = CWorld::GetCurrentScanCode();
|
||||
|
||||
if(IsEntityCullZoneVisible(ent))
|
||||
if(IsEntityCullZoneVisible(ent)){
|
||||
switch(SetupEntityVisibility(ent)){
|
||||
case VIS_VISIBLE:
|
||||
ms_aVisibleEntityPtrs[ms_nNoOfVisibleEntities++] = ent;
|
||||
@ -1111,10 +1220,38 @@ CRenderer::ScanSectorList_Priority(CPtrList *lists)
|
||||
}
|
||||
break;
|
||||
}
|
||||
else if(ent->IsBuilding() && ((CBuilding*)ent)->GetIsATreadable()){
|
||||
if(!CStreaming::ms_disableStreaming)
|
||||
#ifndef MASTER
|
||||
// actually missing in game
|
||||
EntitiesRendered++;
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1220,9 +1357,34 @@ CRenderer::IsEntityCullZoneVisible(CEntity *ent)
|
||||
CPed *ped;
|
||||
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)
|
||||
return false;
|
||||
|
||||
|
||||
switch(ent->GetType()){
|
||||
case ENTITY_TYPE_VEHICLE:
|
||||
return IsVehicleCullZoneVisible(ent);
|
||||
|
@ -2,11 +2,20 @@
|
||||
|
||||
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 gbShowCarRoadGroups;
|
||||
extern bool gbShowCollisionPolys;
|
||||
extern bool gbShowCollisionLines;
|
||||
extern bool gbShowCullZoneDebugStuff;
|
||||
extern bool gbDisableZoneCull; // not original
|
||||
extern bool gbBigWhiteDebugLightSwitchedOn;
|
||||
|
||||
extern bool gbDontRenderBuildings;
|
||||
@ -18,6 +27,13 @@ extern bool gbDontRenderVehicles;
|
||||
class CVehicle;
|
||||
class CPtrList;
|
||||
|
||||
// unused
|
||||
struct BlockedRange
|
||||
{
|
||||
float a, b; // unknown
|
||||
BlockedRange *prev, *next;
|
||||
};
|
||||
|
||||
class CRenderer
|
||||
{
|
||||
static int32 ms_nNoOfVisibleEntities;
|
||||
@ -28,6 +44,10 @@ class CRenderer
|
||||
static CVector ms_vecCameraPosition;
|
||||
static CVehicle *m_pFirstPersonVehicle;
|
||||
|
||||
// unused
|
||||
static BlockedRange aBlockedRanges[16];
|
||||
static BlockedRange *pFullBlockedRanges;
|
||||
static BlockedRange *pEmptyBlockedRanges;
|
||||
public:
|
||||
static float ms_lodDistScale;
|
||||
static bool m_loadingPriority;
|
||||
@ -46,6 +66,8 @@ public:
|
||||
static void RenderFirstPersonVehicle(void);
|
||||
|
||||
static void RenderCollisionLines(void);
|
||||
// unused
|
||||
static void RenderBlockBuildingLines(void);
|
||||
|
||||
static int32 SetupEntityVisibility(CEntity *ent);
|
||||
static int32 SetupBigBuildingVisibility(CEntity *ent);
|
||||
|
@ -11,8 +11,6 @@
|
||||
#include "World.h"
|
||||
#include "custompipes.h"
|
||||
|
||||
#define FADE_DISTANCE 20.0f
|
||||
|
||||
CLinkList<CVisibilityPlugins::AlphaObjectInfo> CVisibilityPlugins::m_alphaList;
|
||||
CLinkList<CVisibilityPlugins::AlphaObjectInfo> CVisibilityPlugins::m_alphaEntityList;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user