diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/core/World.cpp | 2 | ||||
-rw-r--r-- | src/core/config.h | 5 | ||||
-rw-r--r-- | src/core/main.cpp | 49 | ||||
-rw-r--r-- | src/core/main.h | 1 | ||||
-rw-r--r-- | src/core/re3.cpp | 7 | ||||
-rw-r--r-- | src/entities/Entity.cpp | 21 | ||||
-rw-r--r-- | src/entities/Entity.h | 8 | ||||
-rw-r--r-- | src/extras/custompipes_d3d9.cpp | 9 | ||||
-rw-r--r-- | src/extras/custompipes_gl.cpp | 9 | ||||
-rw-r--r-- | src/leeds/base/relocatableChunk.cpp | 2 | ||||
-rw-r--r-- | src/leeds/base/relocatableChunk.h | 2 | ||||
-rw-r--r-- | src/modelinfo/MloModelInfo.cpp | 58 | ||||
-rw-r--r-- | src/modelinfo/MloModelInfo.h | 20 | ||||
-rw-r--r-- | src/modelinfo/ModelInfo.h | 2 | ||||
-rw-r--r-- | src/modelinfo/SimpleModelInfo.cpp | 8 | ||||
-rw-r--r-- | src/modelinfo/XtraCompsModelInfo.cpp | 21 | ||||
-rw-r--r-- | src/modelinfo/XtraCompsModelInfo.h | 19 | ||||
-rw-r--r-- | src/renderer/PlayerSkin.cpp | 2 | ||||
-rw-r--r-- | src/renderer/Renderer.cpp | 413 | ||||
-rw-r--r-- | src/renderer/Renderer.h | 17 | ||||
-rw-r--r-- | src/renderer/WaterLevel.cpp | 8 | ||||
-rw-r--r-- | src/rw/RwHelper.cpp | 1 | ||||
-rw-r--r-- | src/rw/VisibilityPlugins.cpp | 224 | ||||
-rw-r--r-- | src/rw/VisibilityPlugins.h | 29 | ||||
-rw-r--r-- | src/vehicles/Plane.cpp | 6 | ||||
-rw-r--r-- | src/vehicles/Plane.h | 1 |
26 files changed, 654 insertions, 290 deletions
diff --git a/src/core/World.cpp b/src/core/World.cpp index 43af9f12..fb0323ae 100644 --- a/src/core/World.cpp +++ b/src/core/World.cpp @@ -1931,6 +1931,7 @@ CWorld::Process(void) if(movingEnt->GetIsStatic()) { movingEnt->RemoveFromMovingList(); } } } +#ifdef VIS_DISTANCE_ALPHA for(int y = 0; y < NUMSECTORS_Y; y++) for(int x = 0; x < NUMSECTORS_X; x++){ CPtrNode *node; @@ -1952,6 +1953,7 @@ CWorld::Process(void) for(node = sect->m_lists[ENTITYLIST_DUMMIES_OVERLAP].first; node; node = node->next) ((CEntity*)node->item)->UpdateDistanceFade(); } +#endif bForceProcessControl = true; for(CPtrNode *node = ms_listMovingEntityPtrs.first; node; node = node->next) { CPhysical *movingEnt = (CPhysical *)node->item; diff --git a/src/core/config.h b/src/core/config.h index bee60489..681d239b 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -248,6 +248,11 @@ enum Config { # define PS2_MATFX #endif +// Mobile only. +// Looks like they tried to fix fading but it still sucks +// do not use this +//#define VIS_DISTANCE_ALPHA + #ifdef VU_COLLISION #define COMPRESSED_COL_VECTORS // currently need compressed vectors in this code #endif diff --git a/src/core/main.cpp b/src/core/main.cpp index 4a61267d..2a130684 100644 --- a/src/core/main.cpp +++ b/src/core/main.cpp @@ -94,6 +94,7 @@ bool gSecondExportPass; bool gUseModelResources; bool gUseResources; bool gNASTY_NASTY_MEM_SHUTDOWN_HACK; // rather unused +bool gbPreviewCity; // don't do worldstream-style rendering but traditional method float FramesPerSecond = 30.0f; @@ -1228,7 +1229,6 @@ DisplayGameDebugText() #ifdef NEW_RENDERER bool gbRenderRoads = true; bool gbRenderEverythingBarRoads = true; -bool gbRenderFadingInUnderwaterEntities = true; bool gbRenderFadingInEntities = true; bool gbRenderWater = true; bool gbRenderBoats = true; @@ -1246,7 +1246,8 @@ MattRenderScene(void) /// CRenderer::ClearForFrame(); // before ConstructRenderList CClock::CalcEnvMapTimeMultiplicator(); RwRenderStateSet(rwRENDERSTATECULLMODE, (void*)rwCULLMODECULLNONE); - CWaterLevel::RenderWater(); // actually CMattRenderer::RenderWater +if(gbRenderWater) + CRenderer::RenderWater(); // actually CMattRenderer::RenderWater CClock::ms_EnvMapTimeMultiplicator = 1.0f; // cWorldStream::ClearDynamics /// CRenderer::ConstructRenderList(); // before PreRender @@ -1260,24 +1261,14 @@ if(gbRenderWorld1) if(gbRenderRoads) CRenderer::RenderRoads(); - CRenderer::GenerateEnvironmentMap(); // should be after static shadows, but that's weird - - CRenderer::RenderPeds(); - - // not sure where to put these since LCS has no underwater entities -if(gbRenderBoats) - CRenderer::RenderBoats(); -if(gbRenderFadingInUnderwaterEntities) - CRenderer::RenderFadingInUnderwaterEntities(); RwRenderStateSet(rwRENDERSTATECULLMODE, (void*)rwCULLMODECULLNONE); -if(gbRenderWater) - CRenderer::RenderTransparentWater(); if(gbRenderEverythingBarRoads) CRenderer::RenderEverythingBarRoads(); - // seam fixer - // moved this: - // CRenderer::RenderFadingInEntities(); + // TODO: seam fixer + // these aren't very transparent. just objects +if(gbRenderFadingInEntities) + CRenderer::RenderFadingInEntities(); } void @@ -1290,7 +1281,8 @@ RenderScene_new(void) MattRenderScene(); DefinedState(); // CMattRenderer::ResetRenderStates - // moved CRenderer::RenderBoats to before transparent water +if(gbRenderBoats) + CRenderer::RenderBoats(); POP_RENDERGROUP(); } @@ -1300,12 +1292,12 @@ void RenderEffects_new(void) { PUSH_RENDERGROUP("RenderEffects_new"); -/* // stupid to do this before the whole world is drawn! - CShadows::RenderStaticShadows(); - CShadows::RenderStoredShadows(); - CSkidmarks::Render(); - CRubbish::Render(); -*/ + // stupid to do this before the whole world is drawn! +// CShadows::RenderStaticShadows(); + CRenderer::GenerateEnvironmentMap(); +// CShadows::RenderStoredShadows(); +// CSkidmarks::Render(); +// CRubbish::Render(); // these aren't really effects DefinedState(); @@ -1323,9 +1315,6 @@ if(gbRenderWorld2) if(gbRenderVehicles) CRenderer::RenderVehicles(); } - // better render these after transparent world -if(gbRenderFadingInEntities) - CRenderer::RenderFadingInEntities(); // actual effects here @@ -1592,12 +1581,8 @@ Idle(void *arg) #ifdef PC_WATER CWaterLevel::PreCalcWaterGeometry(); #endif -#ifdef NEW_RENDERER - if(gbNewRenderer){ - CWorld::AdvanceCurrentScanCode(); // don't think this is even necessary - CRenderer::ClearForFrame(); - } -#endif + CWorld::AdvanceCurrentScanCode(); + CRenderer::ClearForFrame(); CRenderer::ConstructRenderList(); tbEndTimer("CnstrRenderList"); diff --git a/src/core/main.h b/src/core/main.h index 3fa26e78..400730a0 100644 --- a/src/core/main.h +++ b/src/core/main.h @@ -42,6 +42,7 @@ extern bool gSecondExportPass; extern bool gUseModelResources; extern bool gUseResources; extern bool gNASTY_NASTY_MEM_SHUTDOWN_HACK; +extern bool gbPreviewCity; class CSprite2d; diff --git a/src/core/re3.cpp b/src/core/re3.cpp index c66ce82a..2cd40e57 100644 --- a/src/core/re3.cpp +++ b/src/core/re3.cpp @@ -629,9 +629,6 @@ void SaveINISettings() StoreIni("CustomPipesValues", "GlossMult", CustomPipes::GlossMult); #endif StoreIni("Rendering", "BackfaceCulling", gBackfaceCulling); -#ifdef NEW_RENDERER - StoreIni("Rendering", "NewRenderer", gbNewRenderer); -#endif #ifdef PROPER_SCALING StoreIni("Draw", "ProperScaling", CDraw::ms_bProperScaling); @@ -1005,10 +1002,8 @@ DebugMenuPopulate(void) DebugMenuAddVarBool8("Render", "VSynch", &FrontEndMenuManager.m_PrefsVsync, nil); DebugMenuAddVar("Render", "Max FPS", &RsGlobal.maxFPS, nil, 1, 1, 1000, nil); #ifdef NEW_RENDERER - DebugMenuAddVarBool8("Render", "New Renderer", &gbNewRenderer, nil); extern bool gbRenderRoads; extern bool gbRenderEverythingBarRoads; -extern bool gbRenderFadingInUnderwaterEntities; extern bool gbRenderFadingInEntities; extern bool gbRenderWater; extern bool gbRenderBoats; @@ -1018,7 +1013,6 @@ extern bool gbRenderWorld1; extern bool gbRenderWorld2; DebugMenuAddVarBool8("Debug Render", "gbRenderRoads", &gbRenderRoads, nil); DebugMenuAddVarBool8("Debug Render", "gbRenderEverythingBarRoads", &gbRenderEverythingBarRoads, nil); - DebugMenuAddVarBool8("Debug Render", "gbRenderFadingInUnderwaterEntities", &gbRenderFadingInUnderwaterEntities, nil); DebugMenuAddVarBool8("Debug Render", "gbRenderFadingInEntities", &gbRenderFadingInEntities, nil); DebugMenuAddVarBool8("Debug Render", "gbRenderWater", &gbRenderWater, nil); DebugMenuAddVarBool8("Debug Render", "gbRenderBoats", &gbRenderBoats, nil); @@ -1026,6 +1020,7 @@ extern bool gbRenderWorld2; DebugMenuAddVarBool8("Debug Render", "gbRenderWorld0", &gbRenderWorld0, nil); DebugMenuAddVarBool8("Debug Render", "gbRenderWorld1", &gbRenderWorld1, nil); DebugMenuAddVarBool8("Debug Render", "gbRenderWorld2", &gbRenderWorld2, nil); + DebugMenuAddVarBool8("Debug Render", "gbPreviewCity", &gbPreviewCity, nil); #endif #ifdef EXTENDED_COLOURFILTER diff --git a/src/entities/Entity.cpp b/src/entities/Entity.cpp index cd50923a..ed432e77 100644 --- a/src/entities/Entity.cpp +++ b/src/entities/Entity.cpp @@ -86,9 +86,9 @@ CEntity::CEntity(void) bHasPreRenderEffects = false; bIsTreeModel = false; - m_flagG2 = false; - m_flagG4 = false; - m_flagG8 = false; + bIsVehicle = false; + bIsPed = false; + bMakeVisible = false; m_scanCode = 0; m_modelIndex = -1; @@ -444,8 +444,11 @@ void CEntity::Render(void) { if(m_rwObject){ - if(CVisibilityPlugins::GetObjectDistanceAlpha(m_rwObject) != 0){ - // NB: LCS does not use bImBeingRendered here, +#ifdef VIS_DISTANCE_ALPHA + if(CVisibilityPlugins::GetObjectDistanceAlpha(m_rwObject) != 0) +#endif + { + // TODO(LCS): LCS does not use bImBeingRendered here, // but that may be due to the streamed world. better keep it for safety bImBeingRendered = true; if(RwObjectGetType(m_rwObject) == rpATOMIC) @@ -457,13 +460,12 @@ CEntity::Render(void) } } +#ifdef VIS_DISTANCE_ALPHA void CEntity::UpdateDistanceFade(void) { -// TODO(LCS): -// increasing and decreasing alpha depending on bDistanceFade doesn't make any sense -// so disable this whole thing until it does. -return; + // bDistanceFade is only valid when entity is in alpha list + // but we're always checking it here, see fix in CRenderer int alpha = CVisibilityPlugins::GetObjectDistanceAlpha(m_rwObject); if(CCutsceneMgr::IsRunning() || TheCamera.WorldViewerBeingUsed) alpha = 255; @@ -473,6 +475,7 @@ return; alpha = Min(alpha+32, 255); CVisibilityPlugins::SetObjectDistanceAlpha(m_rwObject, alpha); } +#endif void CEntity::UpdateAnim(void) diff --git a/src/entities/Entity.h b/src/entities/Entity.h index 239292c5..dbe8c6e2 100644 --- a/src/entities/Entity.h +++ b/src/entities/Entity.h @@ -100,9 +100,9 @@ public: // LCS flagsG uint32 bIsTreeModel : 1; - uint32 m_flagG2 : 1; - uint32 m_flagG4 : 1; - uint32 m_flagG8 : 1; + uint32 bIsVehicle : 1; // not sure what exactly these two are for + uint32 bIsPed : 1; + uint32 bMakeVisible : 1; uint16 m_scanCode; uint16 m_randomSeed; @@ -163,7 +163,9 @@ public: return (RpClump*)m_rwObject; } +#ifdef VIS_DISTANCE_ALPHA void UpdateDistanceFade(void); +#endif void GetBoundCentre(CVUVECTOR &out); CVector GetBoundCentre(void); float GetBoundRadius(void); diff --git a/src/extras/custompipes_d3d9.cpp b/src/extras/custompipes_d3d9.cpp index cb5fcadc..dd3a95b7 100644 --- a/src/extras/custompipes_d3d9.cpp +++ b/src/extras/custompipes_d3d9.cpp @@ -16,6 +16,7 @@ #include "TxdStore.h" #include "Renderer.h" #include "World.h" +#include "VisibilityPlugins.h" #include "custompipes.h" #ifndef LIBRW @@ -464,9 +465,13 @@ worldRenderCB(rw::Atomic *atomic, rw::d3d9::InstanceDataHeader *header) else d3d::setTexture(0, gpWhiteTexture); // actually we don't even render this - setMaterial(m->color, m->surfaceProps, WorldPipeSwitch == WORLDPIPE_PS2 ? 0.5f : 1.0f); + rw::RGBA color = m->color; +#ifdef VIS_DISTANCE_ALPHA + color.alpha = (color.alpha * CVisibilityPlugins::GetObjectDistanceAlpha((RwObject*)atomic))/255.0f; +#endif + setMaterial(color, m->surfaceProps, WorldPipeSwitch == WORLDPIPE_PS2 ? 0.5f : 1.0f); - SetRenderState(VERTEXALPHA, inst->vertexAlpha || m->color.alpha != 255); + SetRenderState(VERTEXALPHA, inst->vertexAlpha || color.alpha != 255); drawInst(header, inst); inst++; diff --git a/src/extras/custompipes_gl.cpp b/src/extras/custompipes_gl.cpp index e70bd6db..ed6a529a 100644 --- a/src/extras/custompipes_gl.cpp +++ b/src/extras/custompipes_gl.cpp @@ -15,6 +15,7 @@ #include "TxdStore.h" #include "Renderer.h" #include "World.h" +#include "VisibilityPlugins.h" #include "custompipes.h" #ifndef LIBRW @@ -457,9 +458,13 @@ worldRenderCB(rw::Atomic *atomic, rw::gl3::InstanceDataHeader *header) setTexture(0, m->texture); - setMaterial(m->color, m->surfaceProps, CustomPipes::WorldPipeSwitch == CustomPipes::WORLDPIPE_PS2 ? 0.5f : 1.0f); + rw::RGBA color = m->color; +#ifdef VIS_DISTANCE_ALPHA + color.alpha = (color.alpha * CVisibilityPlugins::GetObjectDistanceAlpha((RwObject*)atomic))/255.0f; +#endif + setMaterial(color, m->surfaceProps, CustomPipes::WorldPipeSwitch == CustomPipes::WORLDPIPE_PS2 ? 0.5f : 1.0f); - rw::SetRenderState(VERTEXALPHA, inst->vertexAlpha || m->color.alpha != 0xFF); + rw::SetRenderState(VERTEXALPHA, inst->vertexAlpha || color.alpha != 0xFF); drawInst(header, inst); inst++; diff --git a/src/leeds/base/relocatableChunk.cpp b/src/leeds/base/relocatableChunk.cpp index 5cb5a426..5391f420 100644 --- a/src/leeds/base/relocatableChunk.cpp +++ b/src/leeds/base/relocatableChunk.cpp @@ -33,4 +33,6 @@ namespace base void cRelocatableChunkWriter::Save(const char* filename, uint32 a3, uint32 a4, bool a5) {} void cRelocatableChunkWriter::Save(void* file, uint32 a3, uint32 a4, bool a5, sChunkHeader* pHeader) {} + + void RegisterRelocatableChunkFunc(const void *func) {} };
\ No newline at end of file diff --git a/src/leeds/base/relocatableChunk.h b/src/leeds/base/relocatableChunk.h index 2658aa21..6e9e21e0 100644 --- a/src/leeds/base/relocatableChunk.h +++ b/src/leeds/base/relocatableChunk.h @@ -50,4 +50,6 @@ namespace base void Save(const char* filename, uint32 a3, uint32 a4, bool a5); void Save(void* file, uint32 a3, uint32 a4, bool a5, sChunkHeader* pHeader); }; + + void RegisterRelocatableChunkFunc(const void *func); };
\ No newline at end of file diff --git a/src/modelinfo/MloModelInfo.cpp b/src/modelinfo/MloModelInfo.cpp new file mode 100644 index 00000000..dc5e64fa --- /dev/null +++ b/src/modelinfo/MloModelInfo.cpp @@ -0,0 +1,58 @@ +#include "common.h" + +#include "VisibilityPlugins.h" +#include "ModelInfo.h" + +base::cRelocatableChunkClassInfo CMloModelInfo::msClassInfo("CMloModelInfo", VTABLE_ADDR(&msClassInstance), sizeof(msClassInstance)); +CMloModelInfo CMloModelInfo::msClassInstance; + +void +CMloModelInfo::ConstructClump() +{ +/* + m_clump = RpClumpCreate(); + RwFrame *mainFrame = RwFrameCreate(); + RwFrameSetIdentity(mainFrame); + RpClumpSetFrame(m_clump, mainFrame); + + for (int i = firstInstance; i < lastInstance; i++) { + int modelId = CModelInfo::GetMloInstanceStore().store[i].m_modelIndex; + RwMatrix *attMat = CModelInfo::GetMloInstanceStore().store[i].GetMatrix().m_attachment; + CSimpleModelInfo *minfo = (CSimpleModelInfo*)CModelInfo::GetModelInfo(modelId); + + if (minfo->m_atomics[0] != nil) { + RpAtomic *newAtomic = RpAtomicClone(minfo->m_atomics[0]); + RwFrame *newFrame = RwFrameCreate(); + if (newAtomic != nil && newFrame != nil) { + *RwFrameGetMatrix(newFrame) = *attMat; + RpAtomicSetFrame(newAtomic, newFrame); + RwFrameAddChild(mainFrame, newFrame); + RpClumpAddAtomic(m_clump, newAtomic); + } else { + debug("Failed to allocate memory while creating template MLO.\n"); + } + } + } + + if (RpClumpGetNumAtomics(m_clump) != 0) { + CVisibilityPlugins::SetClumpModelInfo(m_clump, this); + } else { + RpClumpDestroy(m_clump); + m_clump = nil; + } +*/ +} + +void +CMloModelInfo::RcWriteThis(base::cRelocatableChunkWriter &writer) +{ + writer.AllocateRaw(this, sizeof(*this), sizeof(void*), false, true); + writer.Class(VTABLE_ADDR(this), msClassInfo); +} + +void +CMloModelInfo::RcWriteEmpty(base::cRelocatableChunkWriter &writer) +{ + writer.AllocateRaw(this, sizeof(*this), sizeof(void*), false, true); + writer.Class(VTABLE_ADDR(this), msClassInfo); +} diff --git a/src/modelinfo/MloModelInfo.h b/src/modelinfo/MloModelInfo.h new file mode 100644 index 00000000..918efb89 --- /dev/null +++ b/src/modelinfo/MloModelInfo.h @@ -0,0 +1,20 @@ +#pragma once + +#include "ClumpModelInfo.h" + +class CMloModelInfo : public CClumpModelInfo +{ +public: + float drawDist; + int firstInstance; + int lastInstance; +public: + CMloModelInfo(void) : CClumpModelInfo(MITYPE_MLO) {} + void ConstructClump(); + + virtual void RcWriteThis(base::cRelocatableChunkWriter &writer); + virtual void RcWriteEmpty(base::cRelocatableChunkWriter &writer); + + static base::cRelocatableChunkClassInfo msClassInfo; + static CMloModelInfo msClassInstance; +};
\ No newline at end of file diff --git a/src/modelinfo/ModelInfo.h b/src/modelinfo/ModelInfo.h index f92a73ad..a0be1937 100644 --- a/src/modelinfo/ModelInfo.h +++ b/src/modelinfo/ModelInfo.h @@ -2,11 +2,13 @@ #include "2dEffect.h" #include "SimpleModelInfo.h" +#include "MloModelInfo.h" #include "TimeModelInfo.h" #include "WeaponModelInfo.h" #include "ClumpModelInfo.h" #include "PedModelInfo.h" #include "VehicleModelInfo.h" +#include "XtraCompsModelInfo.h" #include "templates.h" class CModelInfo diff --git a/src/modelinfo/SimpleModelInfo.cpp b/src/modelinfo/SimpleModelInfo.cpp index 8d0ea677..ba1cfb40 100644 --- a/src/modelinfo/SimpleModelInfo.cpp +++ b/src/modelinfo/SimpleModelInfo.cpp @@ -206,8 +206,8 @@ CSimpleModelInfo::GetAtomicFromDistance(float dist) { int i; i = 0; -// HACk until we figure out what's going on -if(m_atomics == nil) return nil; + if(m_atomics == nil) + return nil; if(m_isDamaged) i = m_firstDamaged; for(; i < m_numAtomics; i++) @@ -219,8 +219,8 @@ if(m_atomics == nil) return nil; RpAtomic* CSimpleModelInfo::GetFirstAtomicFromDistance(float dist) { -// HACk until we figure out what's going on -if(m_atomics == nil) return nil; + if(m_atomics == nil) + return nil; if(dist < m_lodDistances[0] * TheCamera.LODDistMultiplier) return m_atomics[0]; return nil; diff --git a/src/modelinfo/XtraCompsModelInfo.cpp b/src/modelinfo/XtraCompsModelInfo.cpp new file mode 100644 index 00000000..c11edaf8 --- /dev/null +++ b/src/modelinfo/XtraCompsModelInfo.cpp @@ -0,0 +1,21 @@ +#include "common.h" + +#include "VisibilityPlugins.h" +#include "ModelInfo.h" + +base::cRelocatableChunkClassInfo CXtraCompsModelInfo::msClassInfo("CXtraCompsModelInfo", VTABLE_ADDR(&msClassInstance), sizeof(msClassInstance)); +CXtraCompsModelInfo CXtraCompsModelInfo::msClassInstance; + +void +CXtraCompsModelInfo::RcWriteThis(base::cRelocatableChunkWriter &writer) +{ + writer.AllocateRaw(this, sizeof(*this), sizeof(void*), false, true); + writer.Class(VTABLE_ADDR(this), msClassInfo); +} + +void +CXtraCompsModelInfo::RcWriteEmpty(base::cRelocatableChunkWriter &writer) +{ + writer.AllocateRaw(this, sizeof(*this), sizeof(void*), false, true); + writer.Class(VTABLE_ADDR(this), msClassInfo); +} diff --git a/src/modelinfo/XtraCompsModelInfo.h b/src/modelinfo/XtraCompsModelInfo.h new file mode 100644 index 00000000..7cd9b7ea --- /dev/null +++ b/src/modelinfo/XtraCompsModelInfo.h @@ -0,0 +1,19 @@ +#pragma once + +#include "ClumpModelInfo.h" + +class CXtraCompsModelInfo : public CClumpModelInfo +{ + int field_34; +public: + CXtraCompsModelInfo(void) : CClumpModelInfo(MITYPE_XTRACOMPS) { field_34 = 0; } + void Shutdown(void) {}; + RwObject *CreateInstance(void) { return nil; } + void SetClump(RpClump*) {}; + + virtual void RcWriteThis(base::cRelocatableChunkWriter &writer); + virtual void RcWriteEmpty(base::cRelocatableChunkWriter &writer); + + static base::cRelocatableChunkClassInfo msClassInfo; + static CXtraCompsModelInfo msClassInstance; +};
\ No newline at end of file diff --git a/src/renderer/PlayerSkin.cpp b/src/renderer/PlayerSkin.cpp index ee944ca7..672312d4 100644 --- a/src/renderer/PlayerSkin.cpp +++ b/src/renderer/PlayerSkin.cpp @@ -124,7 +124,7 @@ void CPlayerSkin::BeginFrontendSkinEdit(void) { LoadPlayerDff(); - RpClumpForAllAtomics(gpPlayerClump, CClumpModelInfo::SetAtomicRendererCB, (void*)CVisibilityPlugins::RenderPlayerCB); +// RpClumpForAllAtomics(gpPlayerClump, CClumpModelInfo::SetAtomicRendererCB, (void*)CVisibilityPlugins::RenderPlayerCB); CWorld::Players[0].LoadPlayerSkin(); gOldFov = CDraw::GetFOV(); CDraw::SetFOV(30.0f); diff --git a/src/renderer/Renderer.cpp b/src/renderer/Renderer.cpp index 85c52032..8e460208 100644 --- a/src/renderer/Renderer.cpp +++ b/src/renderer/Renderer.cpp @@ -28,10 +28,17 @@ #include "custompipes.h" #include "Frontend.h" #include "Ferry.h" +#include "Plane.h" +#include "WaterLevel.h" + +// maybe some day... +//#define GTA_WORLDSTREAM bool gbShowPedRoadGroups; bool gbShowCarRoadGroups; bool gbShowCollisionPolys; +bool gbShowCollisionPolysReflections; +bool gbShowCollisionPolysNoShadows; bool gbShowCollisionLines; bool gbBigWhiteDebugLightSwitchedOn; @@ -44,6 +51,9 @@ bool gbDontRenderVehicles; bool gbRenderDebugEnvMap; // unused +bool gbLighting; + +// unused int16 TestCloseThings; int16 TestBigThings; @@ -59,9 +69,9 @@ int32 CRenderer::ms_nNoOfVisibleEntities; CEntity *CRenderer::ms_aVisibleEntityPtrs[NUMVISIBLEENTITIES]; CEntity *CRenderer::ms_aInVisibleEntityPtrs[NUMINVISIBLEENTITIES]; int32 CRenderer::ms_nNoOfInVisibleEntities; -#ifdef NEW_RENDERER int32 CRenderer::ms_nNoOfVisibleVehicles; CEntity *CRenderer::ms_aVisibleVehiclePtrs[NUMVISIBLEENTITIES]; +#ifdef NEW_RENDERER int32 CRenderer::ms_nNoOfVisibleBuildings; CEntity *CRenderer::ms_aVisibleBuildingPtrs[NUMVISIBLEENTITIES]; #endif @@ -71,16 +81,12 @@ CVehicle *CRenderer::m_pFirstPersonVehicle; bool CRenderer::m_loadingPriority; float CRenderer::ms_lodDistScale = 1.2f; -// unused -BlockedRange CRenderer::aBlockedRanges[16]; -BlockedRange* CRenderer::pFullBlockedRanges; -BlockedRange* CRenderer::pEmptyBlockedRanges; - void CRenderer::Init(void) { gSortedVehiclesAndPeds.Init(40); - SortBIGBuildings(); + if(gMakeResources) + SortBIGBuildings(); } void @@ -98,10 +104,10 @@ CRenderer::PreRender(void) for(i = 0; i < ms_nNoOfVisibleEntities; i++) ms_aVisibleEntityPtrs[i]->PreRender(); + for(i = 0; i < ms_nNoOfVisibleVehicles; i++) + ms_aVisibleVehiclePtrs[i]->PreRender(); #ifdef NEW_RENDERER if(gbNewRenderer){ - 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(); @@ -131,11 +137,14 @@ CRenderer::PreRender(void) void CRenderer::RenderOneRoad(CEntity *e) { +#ifndef MASTER if(gbDontRenderBuildings) return; - if(gbShowCollisionPolys) + if(gbShowCollisionPolys || gbShowCollisionPolysReflections || gbShowCollisionPolysNoShadows) CCollision::DrawColModel_Coloured(e->GetMatrix(), *CModelInfo::GetModelInfo(e->GetModelIndex())->GetColModel(), e->GetModelIndex()); - else{ + else +#endif + { PUSH_RENDERGROUP(CModelInfo::GetModelInfo(e->GetModelIndex())->GetModelName()); e->Render(); @@ -153,12 +162,15 @@ CRenderer::RenderOneNonRoad(CEntity *e) bool resetLights; #ifndef MASTER - if(gbShowCollisionPolys){ + if(gbShowCollisionPolys || gbShowCollisionPolysReflections || gbShowCollisionPolysNoShadows){ if(!e->IsVehicle()){ CCollision::DrawColModel_Coloured(e->GetMatrix(), *CModelInfo::GetModelInfo(e->GetModelIndex())->GetColModel(), e->GetModelIndex()); return; } - }else if(e->IsBuilding()){ + }else +#endif +#ifndef FINAL + if(e->IsBuilding()){ if(e->bIsBIGBuilding){ if(gbDontRenderBigBuildings) return; @@ -169,7 +181,7 @@ CRenderer::RenderOneNonRoad(CEntity *e) }else #endif if(e->IsPed()){ -#ifndef MASTER +#ifndef FINAL if(gbDontRenderPeds) return; #endif @@ -177,7 +189,7 @@ CRenderer::RenderOneNonRoad(CEntity *e) if(ped->m_nPedState == PED_DRIVING) return; } -#ifndef MASTER +#ifndef FINAL else if(e->IsObject() || e->IsDummy()){ if(gbDontRenderObjects) return; @@ -201,16 +213,36 @@ CRenderer::RenderOneNonRoad(CEntity *e) // Render Peds in vehicle before vehicle itself if(e->IsVehicle()){ veh = (CVehicle*)e; - if(veh->pDriver && veh->pDriver->m_nPedState == PED_DRIVING) +#ifdef VIS_DISTANCE_ALPHA + int vehalpha = CVisibilityPlugins::GetObjectDistanceAlpha(veh->m_rwObject); +#endif + if(veh->pDriver && veh->pDriver->m_nPedState == PED_DRIVING){ +#ifdef VIS_DISTANCE_ALPHA + int alpha = CVisibilityPlugins::GetObjectDistanceAlpha(veh->pDriver->m_rwObject); + CVisibilityPlugins::SetObjectDistanceAlpha(veh->pDriver->m_rwObject, vehalpha); veh->pDriver->Render(); + CVisibilityPlugins::SetObjectDistanceAlpha(veh->pDriver->m_rwObject, alpha); +#else + veh->pDriver->Render(); +#endif + } for(i = 0; i < 8; i++) - if(veh->pPassengers[i] && veh->pPassengers[i]->m_nPedState == PED_DRIVING) + if(veh->pPassengers[i] && veh->pPassengers[i]->m_nPedState == PED_DRIVING){ +#ifdef VIS_DISTANCE_ALPHA + int alpha = CVisibilityPlugins::GetObjectDistanceAlpha(veh->pPassengers[i]->m_rwObject); + CVisibilityPlugins::SetObjectDistanceAlpha(veh->pPassengers[i]->m_rwObject, vehalpha); + veh->pPassengers[i]->Render(); + CVisibilityPlugins::SetObjectDistanceAlpha(veh->pPassengers[i]->m_rwObject, alpha); +#else veh->pPassengers[i]->Render(); +#endif + } SetCullMode(rwCULLMODECULLNONE); } e->Render(); if(e->IsVehicle()){ + // TODO(LCS): LCS does not use bImBeingRendered, keeping it for safety e->bImBeingRendered = true; CVisibilityPlugins::RenderAlphaAtomics(); e->bImBeingRendered = false; @@ -247,7 +279,7 @@ CRenderer::RenderRoads(void) PUSH_RENDERGROUP("CRenderer::RenderRoads"); RwRenderStateSet(rwRENDERSTATEFOGENABLE, (void*)TRUE); - RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)TRUE); +// RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)TRUE); SetCullMode(rwCULLMODECULLBACK); DeActivateDirectional(); SetAmbientColours(); @@ -273,18 +305,18 @@ inline bool PutIntoSortedVehicleList(CVehicle *veh) return veh->bTouchingWater; } +// this only renders objects in LCS void CRenderer::RenderEverythingBarRoads(void) { int i; CEntity *e; - EntityInfo ei; PUSH_RENDERGROUP("CRenderer::RenderEverythingBarRoads"); - RwRenderStateSet(rwRENDERSTATEFOGENABLE, (void*)TRUE); - RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)TRUE); +// RwRenderStateSet(rwRENDERSTATEFOGENABLE, (void*)TRUE); +// RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)TRUE); SetCullMode(rwCULLMODECULLBACK); - gSortedVehiclesAndPeds.Clear(); +// gSortedVehiclesAndPeds.Clear(); for(i = 0; i < ms_nNoOfVisibleEntities; i++){ e = ms_aVisibleEntityPtrs[i]; @@ -297,17 +329,19 @@ CRenderer::RenderEverythingBarRoads(void) continue; #endif - if(e->IsVehicle() || - e->IsPed() && CVisibilityPlugins::GetClumpAlpha((RpClump*)e->m_rwObject) != 255){ - if(e->IsVehicle() && PutIntoSortedVehicleList((CVehicle*)e)){ - ei.ent = e; - ei.sort = (ms_vecCameraPosition - e->GetPosition()).MagnitudeSqr(); - gSortedVehiclesAndPeds.InsertSorted(ei); - }else{ - if(!CVisibilityPlugins::InsertEntityIntoSortedList(e, (ms_vecCameraPosition - e->GetPosition()).Magnitude())){ - printf("Ran out of space in alpha entity list"); - RenderOneNonRoad(e); - } + // we're not even rendering peds here.... +#ifdef VIS_DISTANCE_ALPHA + // this looks like a fix for objects just popping in + int distAlpha = CVisibilityPlugins::GetObjectDistanceAlpha(e->m_rwObject); + if(e->IsPed() && CVisibilityPlugins::GetClumpAlpha((RpClump*)e->m_rwObject) != 255 || + distAlpha != 255){ + if(distAlpha != 0 && !CVisibilityPlugins::InsertEntityIntoSortedList(e, (ms_vecCameraPosition - e->GetPosition()).Magnitude())){ +#else + if(e->IsPed() && CVisibilityPlugins::GetClumpAlpha((RpClump*)e->m_rwObject) != 255){ + if(!CVisibilityPlugins::InsertEntityIntoSortedList(e, (ms_vecCameraPosition - e->GetPosition()).Magnitude())){ +#endif + printf("Ran out of space in alpha entity list"); + RenderOneNonRoad(e); } }else RenderOneNonRoad(e); @@ -318,30 +352,26 @@ CRenderer::RenderEverythingBarRoads(void) void CRenderer::RenderBoats(void) { + int i; + CEntity *e; + EntityInfo ei; CLink<EntityInfo> *node; PUSH_RENDERGROUP("CRenderer::RenderBoats"); + gbLighting = true; RwRenderStateSet(rwRENDERSTATEFOGENABLE, (void*)TRUE); - RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)TRUE); +// RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)TRUE); SetCullMode(rwCULLMODECULLBACK); -#ifdef NEW_RENDERER - int i; - CEntity *e; - EntityInfo ei; - if(gbNewRenderer){ - gSortedVehiclesAndPeds.Clear(); - // not the real thing - for(i = 0; i < ms_nNoOfVisibleVehicles; i++){ - e = ms_aVisibleVehiclePtrs[i]; - if(e->IsVehicle() && PutIntoSortedVehicleList((CVehicle*)e)){ - ei.ent = e; - ei.sort = (ms_vecCameraPosition - e->GetPosition()).MagnitudeSqr(); - gSortedVehiclesAndPeds.InsertSorted(ei); - } + gSortedVehiclesAndPeds.Clear(); + for(i = 0; i < ms_nNoOfVisibleVehicles; i++){ + e = ms_aVisibleVehiclePtrs[i]; + if(e->IsVehicle() && PutIntoSortedVehicleList((CVehicle*)e)){ + ei.ent = e; + ei.sort = (ms_vecCameraPosition - e->GetPosition()).MagnitudeSqr(); + gSortedVehiclesAndPeds.InsertSorted(ei); } } -#endif for(node = gSortedVehiclesAndPeds.tail.prev; node != &gSortedVehiclesAndPeds.head; @@ -349,6 +379,69 @@ CRenderer::RenderBoats(void) CVehicle *v = (CVehicle*)node->item.ent; RenderOneNonRoad(v); } + RwRenderStateSet(rwRENDERSTATEFOGENABLE, (void*)FALSE); + gbLighting = false; + POP_RENDERGROUP(); +} + +// also renders peds +void +CRenderer::RenderVehicles(void) +{ + int i; + CEntity *e; + + PUSH_RENDERGROUP("CRenderer::RenderVehicles"); + // LCS: not on android + RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDSRCALPHA); + RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDINVSRCALPHA); + // TODO(LCS): PS2VehicleAlphaFunc(); + + gbLighting = true; + RwRenderStateSet(rwRENDERSTATEFOGENABLE, (void*)TRUE); + + CVisibilityPlugins::InitAlphaEntityList(); + for(i = 0; i < ms_nNoOfVisibleVehicles; i++){ + e = ms_aVisibleVehiclePtrs[i]; +#ifdef VIS_DISTANCE_ALPHA + if(CVisibilityPlugins::GetClumpAlpha((RpClump*)e->m_rwObject) == 0 || + CVisibilityPlugins::GetObjectDistanceAlpha(e->m_rwObject) == 0) + continue; +#endif + + int behindDriver = e->bIsPed && ((CPed*)e)->m_nPedState == PED_DRIVING && + TheCamera.GetLookDirection() == LOOKING_FORWARD; + // what is going on here? !behindDriver will always be true because we're checking for !PED_DRIVING + if(!e->bDistanceFade && (e->IsPed() || e->bIsPed) && ((CPed*)e)->m_nPedState != PED_DRIVING && !behindDriver){ +#ifdef VIS_DISTANCE_ALPHA + if(CVisibilityPlugins::GetClumpAlpha((RpClump*)e->m_rwObject) != 255 || + CVisibilityPlugins::GetObjectDistanceAlpha(e->m_rwObject) != 255) + ; // set blend render states + else + ; // set default render states +#endif + RenderOneNonRoad(e); + }else if(!PutIntoSortedVehicleList((CVehicle*)e) && // boats handled elsewhere + !CVisibilityPlugins::InsertEntityIntoSortedList(e, (ms_vecCameraPosition - e->GetPosition()).Magnitude())){ +#ifdef VIS_DISTANCE_ALPHA + if(CVisibilityPlugins::GetClumpAlpha((RpClump*)e->m_rwObject) != 255 || + CVisibilityPlugins::GetObjectDistanceAlpha(e->m_rwObject) != 255) + ; // set blend render states + else + ; // set default render states +#endif + printf("Ran out of space in alpha entity list"); + RenderOneNonRoad(e); + } + } + CVisibilityPlugins::RenderFadingEntities(); + + CFerry::RenderAllRemaning(); + CPlane::RenderAllRemaning(); + // TODO(LCS): gpGlobalEnvironmentMap = nil; + // TODO(LCS): CMattRenderer::Get().ResetRenderStates(); + RwRenderStateSet(rwRENDERSTATEFOGENABLE, (void*)FALSE); + gbLighting = false; POP_RENDERGROUP(); } @@ -356,7 +449,6 @@ CRenderer::RenderBoats(void) #ifndef LIBRW #error "Need librw for EXTENDED_PIPELINES" #endif -#include "WaterLevel.h" enum { // blend passes @@ -437,12 +529,16 @@ CRenderer::RenderOneBuilding(CEntity *ent, float camdist) ent->bImBeingRendered = false; // TODO: this seems wrong, but do we even need it? } +// our replacement for cWorldStream::Render void CRenderer::RenderWorld(int pass) { int i; CEntity *e; CLink<CVisibilityPlugins::AlphaObjectInfo> *node; + // use old renderer + if(gbPreviewCity) + return; RwRenderStateSet(rwRENDERSTATEFOGENABLE, (void*)TRUE); SetCullMode(rwCULLMODECULLBACK); @@ -506,59 +602,21 @@ CRenderer::RenderWorld(int pass) break; } } +#endif +// actually CMattRenderer::RenderWater +// adapted slightly void -CRenderer::RenderPeds(void) -{ - int i; - CEntity *e; - - PUSH_RENDERGROUP("CRenderer::RenderPeds"); - for(i = 0; i < ms_nNoOfVisibleVehicles; i++){ - e = ms_aVisibleVehiclePtrs[i]; - if(e->IsPed()) - RenderOneNonRoad(e); - } - POP_RENDERGROUP(); -} - -void -CRenderer::RenderVehicles(void) +CRenderer::RenderWater(void) { int i; CEntity *e; - EntityInfo ei; - CLink<EntityInfo> *node; - PUSH_RENDERGROUP("CRenderer::RenderVehicles"); - // not the real thing - for(i = 0; i < ms_nNoOfVisibleVehicles; i++){ - e = ms_aVisibleVehiclePtrs[i]; - if(!e->IsVehicle()) - continue; - if(PutIntoSortedVehicleList((CVehicle*)e)) - continue; // boats handled elsewhere - ei.ent = e; - ei.sort = (ms_vecCameraPosition - e->GetPosition()).MagnitudeSqr(); - gSortedVehiclesAndPeds.InsertSorted(ei); - } - - for(node = gSortedVehiclesAndPeds.tail.prev; - node != &gSortedVehiclesAndPeds.head; - node = node->prev) - RenderOneNonRoad(node->item.ent); - - CFerry::RenderAllRemaning(); - POP_RENDERGROUP(); -} + PUSH_RENDERGROUP("CRenderer::RenderWater"); -void -CRenderer::RenderTransparentWater(void) -{ - int i; - CEntity *e; + gbLighting = false; + CWaterLevel::RenderWater(); - PUSH_RENDERGROUP("CRenderer::RenderTransparentWater"); RwRenderStateSet(rwRENDERSTATETEXTURERASTER, nil); RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)TRUE); RwRenderStateSet(rwRENDERSTATEFOGENABLE, (void*)FALSE); @@ -582,6 +640,7 @@ CRenderer::RenderTransparentWater(void) CWaterLevel::RenderTransparentWater(); SetStencilState(0); + gbLighting = true; POP_RENDERGROUP(); } @@ -590,22 +649,23 @@ CRenderer::ClearForFrame(void) { ms_nNoOfVisibleEntities = 0; ms_nNoOfVisibleVehicles = 0; - ms_nNoOfVisibleBuildings = 0; ms_nNoOfInVisibleEntities = 0; gSortedVehiclesAndPeds.Clear(); +#ifdef NEW_RENDERER + ms_nNoOfVisibleBuildings = 0; WorldRender::numBlendInsts[PASS_NOZ] = 0; WorldRender::numBlendInsts[PASS_ADD] = 0; WorldRender::numBlendInsts[PASS_BLEND] = 0; -} #endif +} void CRenderer::RenderFadingInEntities(void) { PUSH_RENDERGROUP("CRenderer::RenderFadingInEntities"); RwRenderStateSet(rwRENDERSTATEFOGENABLE, (void*)TRUE); - RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)TRUE); +// RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)TRUE); SetCullMode(rwCULLMODECULLBACK); DeActivateDirectional(); SetAmbientColours(); @@ -617,6 +677,9 @@ void CRenderer::RenderFadingInUnderwaterEntities(void) { PUSH_RENDERGROUP("CRenderer::RenderFadingInUnderwaterEntities"); + RwRenderStateSet(rwRENDERSTATEFOGENABLE, (void*)TRUE); +// RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)TRUE); + SetCullMode(rwCULLMODECULLBACK); DeActivateDirectional(); SetAmbientColours(); CVisibilityPlugins::RenderFadingUnderwaterEntities(); @@ -663,6 +726,9 @@ CRenderer::SetupEntityVisibility(CEntity *ent) float dist; bool request = true; + if(mi->GetModelType() == MITYPE_SIMPLE){ + // TODO(LCS): some cWorldStream dynamics stuff + } if(mi->GetModelType() == MITYPE_TIME){ ti = (CTimeModelInfo*)mi; other = ti->GetOtherTimeModel(); @@ -672,8 +738,10 @@ CRenderer::SetupEntityVisibility(CEntity *ent) ti->m_alpha = 255; }else{ // Hide if possible - if(CANTIMECULL) + if(CANTIMECULL){ + ent->DeleteRwObject(); return VIS_INVISIBLE; + } // can't cull, so we'll try to draw this one, but don't request // it since what we really want is the other one. request = false; @@ -682,6 +750,7 @@ CRenderer::SetupEntityVisibility(CEntity *ent) if(mi->GetModelType() != MITYPE_SIMPLE && mi->GetModelType() != MITYPE_WEAPON){ if(FindPlayerVehicle() == ent && TheCamera.Cams[TheCamera.ActiveCam].Mode == CCam::MODE_1STPERSON && +// TODO(LCS): something in CWorld::Players... !(FindPlayerVehicle()->IsBike() && ((CBike*)FindPlayerVehicle())->bWheelieCam)){ // Player's vehicle in first person mode CVehicle *veh = (CVehicle*)ent; @@ -689,6 +758,7 @@ CRenderer::SetupEntityVisibility(CEntity *ent) int direction = TheCamera.Cams[TheCamera.ActiveCam].DirectionWasLooking; if(direction == LOOKING_FORWARD || ent->GetModelIndex() == MI_RHINO || + ent->GetModelIndex() == MI_BUS || ent->GetModelIndex() == MI_COACH || TheCamera.m_bInATunnelAndABigVehicle || direction == LOOKING_BEHIND && veh->pHandling->Flags & HANDLING_UNKNOWN){ @@ -697,7 +767,7 @@ CRenderer::SetupEntityVisibility(CEntity *ent) } if(direction != LOOKING_BEHIND || - !veh->IsBoat() || model == MI_REEFER || model == MI_TROPIC || model == MI_PREDATOR || model == MI_SKIMMER){ + !veh->IsBoat() || model == MI_REEFER || model == MI_PREDATOR){ m_pFirstPersonVehicle = (CVehicle*)ent; ent->bNoBrightHeadLights = false; return VIS_OFFSCREEN; @@ -739,7 +809,8 @@ CRenderer::SetupEntityVisibility(CEntity *ent) dist = (ent->GetPosition() - ms_vecCameraPosition).Magnitude(); -#ifndef FIX_BUGS +//#ifndef FIX_BUGS +#if 0 // Whatever this is supposed to do, it breaks fading for objects // whose draw dist is > LOD_DISTANCE-FADE_DISTANCE, i.e. 280 // because decreasing dist here makes the object visible above LOD_DISTANCE @@ -749,6 +820,9 @@ CRenderer::SetupEntityVisibility(CEntity *ent) if(LOD_DISTANCE < dist && dist < mi->GetLargestLodDistance() + FADE_DISTANCE) dist += mi->GetLargestLodDistance() - LOD_DISTANCE; #endif + // LCS has this now, wonder if it's any better: + if(LOD_DISTANCE + STREAM_DISTANCE < dist && dist < mi->GetLargestLodDistance()) + dist = mi->GetLargestLodDistance(); if(ent->IsObject() && ent->bRenderDamaged) mi->m_isDamaged = true; @@ -800,7 +874,7 @@ CRenderer::SetupEntityVisibility(CEntity *ent) // We might be fading - a = mi->GetAtomicFromDistance(dist - FADE_DISTANCE); + a = mi->GetLastAtomic(dist - FADE_DISTANCE); mi->m_isDamaged = false; if(a == nil){ // request model @@ -866,7 +940,7 @@ CRenderer::SetupBigBuildingVisibility(CEntity *ent) // Find out whether to draw below near distance. // This is only the case if there is a non-LOD which is either not // loaded or not completely faded in yet. - if(dist < mi->GetNearDistance() && dist < LOD_DISTANCE){ + if(dist < mi->GetNearDistance() && dist < LOD_DISTANCE + STREAM_DISTANCE){ // No non-LOD or non-LOD is completely visible. if(nonLOD == nil || nonLOD->GetRwObject() && nonLOD->m_alpha == 255) @@ -922,7 +996,7 @@ CRenderer::SetupBigBuildingVisibility(CEntity *ent) // get faded atomic a = mi->GetFirstAtomicFromDistance(dist - FADE_DISTANCE); if(a == nil){ - if(ent->bStreamBIGBuilding && dist-STREAM_DISTANCE < mi->GetLodDistance(0) && request){ + if(ent->bStreamBIGBuilding && dist-STREAM_DISTANCE-FADE_DISTANCE < mi->GetLodDistance(0) && request){ return ent->GetIsOnScreen() ? VIS_STREAMME : VIS_INVISIBLE; }else{ ent->DeleteRwObject(); @@ -951,30 +1025,15 @@ void CRenderer::ConstructRenderList(void) { COcclusion::ProcessBeforeRendering(); -#ifdef NEW_RENDERER - if(!gbNewRenderer) -#endif -{ - ms_nNoOfVisibleEntities = 0; - ms_nNoOfInVisibleEntities = 0; -} ms_vecCameraPosition = TheCamera.GetPosition(); // 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(); + + // LCS: mobile has a bunch of code after this, } void @@ -1123,7 +1182,9 @@ CRenderer::ScanWorld(void) poly[2].y = CWorld::GetSectorY(vectors[CORNER_FAR_TOPRIGHT].y); ScanSectorPoly(poly, 3, ScanSectorList); } - + +#ifndef GTA_WORLDSTREAM + // TODO(LCS): may be better to have this code with gbPreviewCity #ifdef NO_ISLAND_LOADING if (FrontEndMenuManager.m_PrefsIslandLoading == CMenuManager::ISLAND_LOADING_HIGH) { ScanBigBuildingList(CWorld::GetBigBuildingList(LEVEL_BEACH)); @@ -1137,6 +1198,7 @@ CRenderer::ScanWorld(void) ScanBigBuildingList(CWorld::GetBigBuildingList(CGame::currLevel)); } ScanBigBuildingList(CWorld::GetBigBuildingList(LEVEL_GENERIC)); +#endif } } } @@ -1429,6 +1491,7 @@ CRenderer::ScanSectorPoly(RwV2d *poly, int32 numVertices, void (*scanfunc)(CPtrL } } +// probably didn't exist as a separate function in LCS void CRenderer::InsertEntityIntoList(CEntity *ent) { @@ -1436,15 +1499,32 @@ CRenderer::InsertEntityIntoList(CEntity *ent) if (!ent->m_rwObject) return; #endif -#ifdef NEW_RENDERER - // TODO: there are more flags being checked here - if(gbNewRenderer && (ent->IsVehicle() || ent->IsPed())) + if(ent->IsVehicle() || ent->bIsVehicle || ent->IsPed() || ent->bIsPed) ms_aVisibleVehiclePtrs[ms_nNoOfVisibleVehicles++] = ent; - else if(gbNewRenderer && ent->IsBuilding()) +#ifdef NEW_RENDERER + else if(!gbPreviewCity && ent->IsBuilding()) + ms_aVisibleBuildingPtrs[ms_nNoOfVisibleBuildings++] = ent; +#endif + else + ms_aVisibleEntityPtrs[ms_nNoOfVisibleEntities++] = ent; +#if defined(VIS_DISTANCE_ALPHA) && defined(FIX_BUGS) + // this flag can only be trusted if entity is in alpha list + // unfortunately we're checking it in other cases too, which is bad. + // no idea why this isn't a problem on android + ent->bDistanceFade = false; +#endif +} + +void +CRenderer::AddVisibleEntity(CEntity *ent) +{ +#ifdef NEW_RENDERER + if(!gbPreviewCity && ent->IsBuilding()) ms_aVisibleBuildingPtrs[ms_nNoOfVisibleBuildings++] = ent; else #endif ms_aVisibleEntityPtrs[ms_nNoOfVisibleEntities++] = ent; + ent->bOffscreen = false; } void @@ -1454,18 +1534,21 @@ CRenderer::ScanBigBuildingList(CPtrList &list) CEntity *ent; int vis; - int f = CTimer::GetFrameCounter() & 3; + int f = CTimer::GetFrameCounter() & 6; for(node = list.first; node; node = node->next){ ent = (CEntity*)node->item; - if(ent->bOffscreen || (ent->m_randomSeed&3) != f){ + if(ent->bOffscreen || (ent->m_randomSeed&6) != f){ ent->bOffscreen = true; vis = SetupBigBuildingVisibility(ent); }else - vis = VIS_VISIBLE; + vis = ent->bOffscreen ? VIS_INVISIBLE : VIS_VISIBLE; + if(ent->bMakeVisible){ + ent->bMakeVisible = false; + ent->bIsVisible = true; + } switch(vis){ case VIS_VISIBLE: - InsertEntityIntoList(ent); - ent->bOffscreen = false; + AddVisibleEntity(ent); break; case VIS_STREAMME: if(!CStreaming::ms_disableStreaming) @@ -1484,7 +1567,15 @@ CRenderer::ScanSectorList(CPtrList *lists) int i; float dx, dy; - for(i = 0; i < NUMSECTORENTITYLISTS; i++){ + int numLists = NUMSECTORENTITYLISTS; +#ifdef GTA_WORLDSTREAM + if(gbPreviewCity){ + numLists -= ENTITYLIST_UNKNOWN; + lists += ENTITYLIST_UNKNOWN; + } +#endif + + for(i = 0; i < numLists; i++){ list = &lists[i]; for(node = list->first; node; node = node->next){ ent = (CEntity*)node->item; @@ -1493,7 +1584,12 @@ CRenderer::ScanSectorList(CPtrList *lists) ent->m_scanCode = CWorld::GetCurrentScanCode(); ent->bOffscreen = false; - switch(SetupEntityVisibility(ent)){ + int vis = SetupEntityVisibility(ent); + if(ent->bMakeVisible){ + ent->bMakeVisible = false; + ent->bIsVisible = true; + } + switch(vis){ case VIS_VISIBLE: InsertEntityIntoList(ent); break; @@ -1529,7 +1625,15 @@ CRenderer::ScanSectorList_Priority(CPtrList *lists) int i; float dx, dy; - for(i = 0; i < NUMSECTORENTITYLISTS; i++){ + int numLists = NUMSECTORENTITYLISTS; +#ifdef GTA_WORLDSTREAM + if(gbPreviewCity){ + numLists -= ENTITYLIST_UNKNOWN; + lists += ENTITYLIST_UNKNOWN; + } +#endif + + for(i = 0; i < numLists; i++){ list = &lists[i]; for(node = list->first; node; node = node->next){ ent = (CEntity*)node->item; @@ -1538,7 +1642,12 @@ CRenderer::ScanSectorList_Priority(CPtrList *lists) ent->m_scanCode = CWorld::GetCurrentScanCode(); ent->bOffscreen = false; - switch(SetupEntityVisibility(ent)){ + int vis = SetupEntityVisibility(ent); + if(ent->bMakeVisible){ + ent->bMakeVisible = false; + ent->bIsVisible = true; + } + switch(vis){ case VIS_VISIBLE: InsertEntityIntoList(ent); break; @@ -1577,7 +1686,15 @@ CRenderer::ScanSectorList_Subway(CPtrList *lists) int i; float dx, dy; - for(i = 0; i < NUMSECTORENTITYLISTS; i++){ + int numLists = NUMSECTORENTITYLISTS; +#ifdef GTA_WORLDSTREAM + if(gbPreviewCity){ + numLists -= ENTITYLIST_UNKNOWN; + lists += ENTITYLIST_UNKNOWN; + } +#endif + + for(i = 0; i < numLists; i++){ list = &lists[i]; for(node = list->first; node; node = node->next){ ent = (CEntity*)node->item; @@ -1612,7 +1729,15 @@ CRenderer::ScanSectorList_RequestModels(CPtrList *lists) CEntity *ent; int i; - for(i = 0; i < NUMSECTORENTITYLISTS; i++){ + int numLists = NUMSECTORENTITYLISTS; +#ifdef GTA_WORLDSTREAM + if(gbPreviewCity){ + numLists -= ENTITYLIST_UNKNOWN; + lists += ENTITYLIST_UNKNOWN; + } +#endif + + for(i = 0; i < numLists; i++){ list = &lists[i]; for(node = list->first; node; node = node->next){ ent = (CEntity*)node->item; @@ -1659,9 +1784,12 @@ CRenderer::ShouldModelBeStreamed(CEntity *ent, const CVector &campos) if(!IsAreaVisible(ent->m_area)) return false; CTimeModelInfo *mi = (CTimeModelInfo *)CModelInfo::GetModelInfo(ent->GetModelIndex()); - if(mi->GetModelType() == MITYPE_TIME) - if(!CClock::GetIsTimeInRange(mi->GetTimeOn(), mi->GetTimeOff())) - return false; + if(!ent->IsObject() && !ent->IsDummy()){ + if(mi->GetModelType() == MITYPE_TIME) + if(!CClock::GetIsTimeInRange(mi->GetTimeOn(), mi->GetTimeOff())) + return false; + // LCS(TODO): cWorldStream::pDynamic, but just returns 0 anyway + } float dist = (ent->GetPosition() - campos).Magnitude(); if(mi->m_noFade) return dist - STREAM_DISTANCE < mi->GetLargestLodDistance(); @@ -1677,8 +1805,8 @@ CRenderer::RemoveVehiclePedLights(CEntity *ent, bool reset) if(reset) ReSetAmbientAndDirectionalColours(); } - SetAmbientColours(); - DeActivateDirectional(); +// SetAmbientColours(); +// DeActivateDirectional(); } @@ -1799,7 +1927,6 @@ AddCorona(float x, float y, float sz) coronaIndices[numCoronaIndices++] = numCoronaVerts + 3; numCoronaVerts += 4; } -#include "Debug.h" static void DrawEnvMapCoronas(float heading) diff --git a/src/renderer/Renderer.h b/src/renderer/Renderer.h index a4b6b0b8..baf2016b 100644 --- a/src/renderer/Renderer.h +++ b/src/renderer/Renderer.h @@ -25,13 +25,6 @@ extern bool gbDontRenderVehicles; class CVehicle; class CPtrList; -// unused -struct BlockedRange -{ - float a, b; // unknown - BlockedRange *prev, *next; -}; - class CRenderer { static int32 ms_nNoOfVisibleEntities; @@ -49,10 +42,6 @@ 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; @@ -93,15 +82,15 @@ public: static void RemoveVehiclePedLights(CEntity *ent, bool reset); -#ifdef NEW_RENDERER static void ClearForFrame(void); - static void RenderPeds(void); static void RenderVehicles(void); // also renders peds in LCS + static void RenderWater(void); // keep-out polys and transparent water +#ifdef NEW_RENDERER static void RenderOneBuilding(CEntity *ent, float camdist = 0.0f); static void RenderWorld(int pass); // like cWorldStream::Render(int) - static void RenderTransparentWater(void); // keep-out polys and transparent water #endif static void InsertEntityIntoList(CEntity *ent); + static void AddVisibleEntity(CEntity *ent); static void GenerateEnvironmentMap(void); }; diff --git a/src/renderer/WaterLevel.cpp b/src/renderer/WaterLevel.cpp index a241ac9f..1aa63697 100644 --- a/src/renderer/WaterLevel.cpp +++ b/src/renderer/WaterLevel.cpp @@ -374,7 +374,7 @@ CWaterLevel::CreateWavyAtomic() { wavyMaterial = RpMaterialCreate(); RpMaterialSetTexture(wavyMaterial, gpWaterTex); - RwRGBA watercolor = { 255, 255, 255, 192 }; + RwRGBA watercolor = { 255, 255, 255, 255 /*192*/ }; RpMaterialSetColor(wavyMaterial, &watercolor); } @@ -1227,7 +1227,7 @@ CWaterLevel::RenderTransparentWater(void) colorTrans.red = CTimeCycle::GetWaterRed(); colorTrans.green = CTimeCycle::GetWaterGreen(); colorTrans.blue = CTimeCycle::GetWaterBlue(); - colorTrans.alpha = CTimeCycle::GetWaterAlpha(); + colorTrans.alpha = 255; //CTimeCycle::GetWaterAlpha(); TempBufferVerticesStored = 0; TempBufferIndicesStored = 0; @@ -1676,7 +1676,6 @@ void CWaterLevel::RenderOneWavySector(float fX, float fY, float fZ, RwRGBA const &color, bool bDontRender) { CVector vecSectorPos(fX + (SMALL_SECTOR_SIZE/2), fY + (SMALL_SECTOR_SIZE/2), fZ + 2.0f); - if ( COcclusion::IsAABoxOccluded(vecSectorPos, SMALL_SECTOR_SIZE, SMALL_SECTOR_SIZE, 4.0f) ) return; @@ -1815,6 +1814,7 @@ CWaterLevel::RenderWavyMask(float fX, float fY, float fZ, int32 nCamDirX, int32 nCamDirY, RwRGBA const&color) #endif { +return; // LCS #ifndef PC_WATER bool bRender = true; if (m_nRenderWaterLayers != 0 && m_nRenderWaterLayers != 2 && m_nRenderWaterLayers != 3) @@ -2531,7 +2531,7 @@ CWaterLevel::RenderBoatWakes(void) CBoat::FillBoatList(); - float fWakeZ = 5.97f; + float fWakeZ = 0.0f;//5.97f; float fWakeLifeTimeMult = 0.01f / CBoat::WAKE_LIFETIME; for ( int32 idx = 0; idx < ARRAY_SIZE(CBoat::apFrameWakeGeneratingBoats); idx++ ) diff --git a/src/rw/RwHelper.cpp b/src/rw/RwHelper.cpp index 6021b866..3206c8bd 100644 --- a/src/rw/RwHelper.cpp +++ b/src/rw/RwHelper.cpp @@ -95,6 +95,7 @@ DefinedState(void) #endif } +//LCS: remove this void SetCullMode(uint32 mode) { diff --git a/src/rw/VisibilityPlugins.cpp b/src/rw/VisibilityPlugins.cpp index ffd7b18a..6f36ac53 100644 --- a/src/rw/VisibilityPlugins.cpp +++ b/src/rw/VisibilityPlugins.cpp @@ -14,10 +14,13 @@ #include "custompipes.h" #include "MemoryHeap.h" +//--LCS: file done +// LCS: no transparent water in LCS so no need for alpha boat and alpha underwater lists + CLinkList<CVisibilityPlugins::AlphaObjectInfo> CVisibilityPlugins::m_alphaList; -CLinkList<CVisibilityPlugins::AlphaObjectInfo> CVisibilityPlugins::m_alphaBoatAtomicList; +//CLinkList<CVisibilityPlugins::AlphaObjectInfo> CVisibilityPlugins::m_alphaBoatAtomicList; CLinkList<CVisibilityPlugins::AlphaObjectInfo> CVisibilityPlugins::m_alphaEntityList; -CLinkList<CVisibilityPlugins::AlphaObjectInfo> CVisibilityPlugins::m_alphaUnderwaterEntityList; +//CLinkList<CVisibilityPlugins::AlphaObjectInfo> CVisibilityPlugins::m_alphaUnderwaterEntityList; #ifdef NEW_RENDERER CLinkList<CVisibilityPlugins::AlphaObjectInfo> CVisibilityPlugins::m_alphaBuildingList; #endif @@ -34,7 +37,7 @@ float CVisibilityPlugins::ms_vehicleLod1Dist; float CVisibilityPlugins::ms_vehicleFadeDist; float CVisibilityPlugins::ms_bigVehicleLod0Dist; float CVisibilityPlugins::ms_bigVehicleLod1Dist; -float CVisibilityPlugins::ms_pedLod1Dist; +float CVisibilityPlugins::ms_pedLodDist; float CVisibilityPlugins::ms_pedFadeDist; #define RENDERCALLBACK AtomicDefaultRenderCallBack @@ -46,12 +49,12 @@ CVisibilityPlugins::Initialise(void) m_alphaList.head.item.sort = 0.0f; m_alphaList.tail.item.sort = 100000000.0f; - m_alphaBoatAtomicList.Init(NUMBOATALPHALIST); - m_alphaBoatAtomicList.head.item.sort = 0.0f; - m_alphaBoatAtomicList.tail.item.sort = 100000000.0f; +// m_alphaBoatAtomicList.Init(NUMBOATALPHALIST); +// m_alphaBoatAtomicList.head.item.sort = 0.0f; +// m_alphaBoatAtomicList.tail.item.sort = 100000000.0f; #ifdef ASPECT_RATIO_SCALE - // default 150 if not enough for bigger FOVs + // default 150 is not enough for bigger FOVs m_alphaEntityList.Init(NUMALPHAENTITYLIST * 3); #else m_alphaEntityList.Init(NUMALPHAENTITYLIST); @@ -59,24 +62,44 @@ CVisibilityPlugins::Initialise(void) m_alphaEntityList.head.item.sort = 0.0f; m_alphaEntityList.tail.item.sort = 100000000.0f; - m_alphaUnderwaterEntityList.Init(NUMALPHAUNTERWATERENTITYLIST); - m_alphaUnderwaterEntityList.head.item.sort = 0.0f; - m_alphaUnderwaterEntityList.tail.item.sort = 100000000.0f; +// m_alphaUnderwaterEntityList.Init(NUMALPHAUNTERWATERENTITYLIST); +// m_alphaUnderwaterEntityList.head.item.sort = 0.0f; +// m_alphaUnderwaterEntityList.tail.item.sort = 100000000.0f; #ifdef NEW_RENDERER m_alphaBuildingList.Init(NUMALPHAENTITYLIST); m_alphaBuildingList.head.item.sort = 0.0f; m_alphaBuildingList.tail.item.sort = 100000000.0f; #endif + + base::RegisterRelocatableChunkFunc((void*)RENDERCALLBACK); + base::RegisterRelocatableChunkFunc((void*)RenderVehicleReallyLowDetailCB); + base::RegisterRelocatableChunkFunc((void*)RenderVehicleHiDetailCB); + base::RegisterRelocatableChunkFunc((void*)RenderVehicleHiDetailAlphaCB); + base::RegisterRelocatableChunkFunc((void*)RenderTrainHiDetailCB); + base::RegisterRelocatableChunkFunc((void*)RenderTrainHiDetailAlphaCB); + base::RegisterRelocatableChunkFunc((void*)RenderWheelAtomicCB); + base::RegisterRelocatableChunkFunc((void*)RenderVehicleRotorAlphaCB); + base::RegisterRelocatableChunkFunc((void*)RenderVehicleTailRotorAlphaCB); + base::RegisterRelocatableChunkFunc((void*)RenderVehicleReallyLowDetailCB_BigVehicle); + base::RegisterRelocatableChunkFunc((void*)RenderVehicleLowDetailCB_BigVehicle); + base::RegisterRelocatableChunkFunc((void*)RenderVehicleHiDetailCB_BigVehicle); + base::RegisterRelocatableChunkFunc((void*)RenderVehicleLowDetailAlphaCB_BigVehicle); + base::RegisterRelocatableChunkFunc((void*)RenderVehicleHiDetailAlphaCB_BigVehicle); + base::RegisterRelocatableChunkFunc((void*)RenderVehicleHiDetailCB_Boat); + base::RegisterRelocatableChunkFunc((void*)RenderVehicleLoDetailCB_Boat); + base::RegisterRelocatableChunkFunc((void*)RenderVehicleHiDetailCB_Boat_Far); + base::RegisterRelocatableChunkFunc((void*)RenderVehicleLoDetailCB_Boat_Far); + base::RegisterRelocatableChunkFunc((void*)RenderPedCB); } void CVisibilityPlugins::Shutdown(void) { m_alphaList.Shutdown(); - m_alphaBoatAtomicList.Shutdown(); +// m_alphaBoatAtomicList.Shutdown(); m_alphaEntityList.Shutdown(); - m_alphaUnderwaterEntityList.Shutdown(); +// m_alphaUnderwaterEntityList.Shutdown(); #ifdef NEW_RENDERER m_alphaBuildingList.Shutdown(); #endif @@ -86,8 +109,8 @@ void CVisibilityPlugins::InitAlphaEntityList(void) { m_alphaEntityList.Clear(); - m_alphaBoatAtomicList.Clear(); - m_alphaUnderwaterEntityList.Clear(); +// m_alphaBoatAtomicList.Clear(); +// m_alphaUnderwaterEntityList.Clear(); #ifdef NEW_RENDERER m_alphaBuildingList.Clear(); #endif @@ -104,11 +127,11 @@ CVisibilityPlugins::InsertEntityIntoSortedList(CEntity *e, float dist) item.entity = e; item.sort = dist; #ifdef NEW_RENDERER - if(gbNewRenderer && e->IsBuilding()) + if(!gbPreviewCity && e->IsBuilding()) return !!m_alphaBuildingList.InsertSorted(item); #endif - if(e->bUnderwater && m_alphaUnderwaterEntityList.InsertSorted(item)) - return true; +// if(e->bUnderwater && m_alphaUnderwaterEntityList.InsertSorted(item)) +// return true; return !!m_alphaEntityList.InsertSorted(item); } @@ -127,6 +150,7 @@ CVisibilityPlugins::InsertAtomicIntoSortedList(RpAtomic *a, float dist) return !!m_alphaList.InsertSorted(item); } +/* bool CVisibilityPlugins::InsertAtomicIntoBoatSortedList(RpAtomic *a, float dist) { @@ -135,9 +159,11 @@ CVisibilityPlugins::InsertAtomicIntoBoatSortedList(RpAtomic *a, float dist) item.sort = dist; return !!m_alphaBoatAtomicList.InsertSorted(item); } +*/ // can't increase this yet unfortunately... // probably have to fix fading for this so material alpha isn't overwritten +// LCS: VIS_DISTANCE_ALPHA will probably take care of this #define VEHICLE_LODDIST_MULTIPLIER (TheCamera.GenerationDistMultiplier) void @@ -157,7 +183,7 @@ CVisibilityPlugins::SetRenderWareCamera(RwCamera *camera) ms_vehicleFadeDist = sq(100.0f * VEHICLE_LODDIST_MULTIPLIER); ms_bigVehicleLod0Dist = sq(60.0f * VEHICLE_LODDIST_MULTIPLIER); ms_bigVehicleLod1Dist = sq(150.0f * VEHICLE_LODDIST_MULTIPLIER); - ms_pedLod1Dist = sq(60.0f * TheCamera.LODDistMultiplier); + ms_pedLodDist = sq(70.0f * TheCamera.LODDistMultiplier); ms_pedFadeDist = sq(70.0f * TheCamera.LODDistMultiplier); } @@ -173,7 +199,10 @@ CVisibilityPlugins::SetupVehicleVariables(RpClump *vehicle) RwV3d distToCam; RwV3dSub(&distToCam, ms_pCameraPosn, &RwFrameGetMatrix(RpClumpGetFrame(vehicle))->pos); float dist2d = Sqrt(SQR(distToCam.x) + SQR(distToCam.y)); - PitchToCamera = Atan2(distToCam.z, dist2d); + if(distToCam.z == 0.0f && dist2d == 0.0f) + PitchToCamera = 0.0f; + else + PitchToCamera = Atan2(distToCam.z, dist2d); } RpMaterial* @@ -204,6 +233,8 @@ CVisibilityPlugins::RenderAlphaAtomics(void) RenderAtomicList(m_alphaList); } +/* +//LCS: removed void CVisibilityPlugins::RenderBoatAlphaAtomics(void) { @@ -211,6 +242,7 @@ CVisibilityPlugins::RenderBoatAlphaAtomics(void) RenderAtomicList(m_alphaBoatAtomicList); SetCullMode(rwCULLMODECULLBACK); } +*/ void CVisibilityPlugins::RenderFadingEntities(CLinkList<AlphaObjectInfo> &list) @@ -229,6 +261,8 @@ CVisibilityPlugins::RenderFadingEntities(CLinkList<AlphaObjectInfo> &list) if(mi->GetModelType() == MITYPE_SIMPLE && mi->m_noZwrite) RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, FALSE); +#if defined(FIX_BUGS) && !defined(VIS_DISTANCE_ALPHA) + //LCS: removed, but that's dumb cause it breaks distance fading if(e->bDistanceFade){ DeActivateDirectional(); SetAmbientColours(); @@ -238,7 +272,18 @@ CVisibilityPlugins::RenderFadingEntities(CLinkList<AlphaObjectInfo> &list) POP_RENDERGROUP(); e->bImBeingRendered = false; }else +#endif + { +#ifdef VIS_DISTANCE_ALPHA + // BUG: we don't even know if this is a clump + if(GetClumpAlpha((RpClump*)e->m_rwObject) != 255 || + GetObjectDistanceAlpha(e->m_rwObject) != 255) + ; // set blend render states + else + ; // set default render states +#endif CRenderer::RenderOneNonRoad(e); + } if(mi->GetModelType() == MITYPE_SIMPLE && mi->m_noZwrite) RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)TRUE); @@ -249,13 +294,13 @@ void CVisibilityPlugins::RenderFadingEntities(void) { RenderFadingEntities(m_alphaEntityList); - RenderBoatAlphaAtomics(); +// RenderBoatAlphaAtomics(); } void CVisibilityPlugins::RenderFadingUnderwaterEntities(void) { - RenderFadingEntities(m_alphaUnderwaterEntityList); +// RenderFadingEntities(m_alphaUnderwaterEntityList); } RpAtomic* @@ -267,8 +312,12 @@ CVisibilityPlugins::RenderWheelAtomicCB(RpAtomic *atomic) mi = GetAtomicModelInfo(atomic); len = Sqrt(DistToCameraSq); +#ifdef FIX_BUGS len *= 0.5f; // HACK HACK, LOD wheels look shite lodatm = mi->GetAtomicFromDistance(len * TheCamera.LODDistMultiplier / VEHICLE_LODDIST_MULTIPLIER); +#else + lodatm = mi->GetAtomicFromDistance(len); +#endif if(lodatm){ if(RpAtomicGetGeometry(lodatm) != RpAtomicGetGeometry(atomic)) RpAtomicSetGeometry(atomic, RpAtomicGetGeometry(lodatm), rpATOMICSAMEBOUNDINGSPHERE); @@ -309,6 +358,8 @@ CVisibilityPlugins::RenderAlphaAtomic(RpAtomic *atomic, int alpha) return atomic; } +/* +//LCS: removed RpAtomic* CVisibilityPlugins::RenderWeaponCB(RpAtomic *atomic) { @@ -326,7 +377,9 @@ CVisibilityPlugins::RenderWeaponCB(RpAtomic *atomic) RENDERCALLBACK(atomic); return atomic; } +*/ +//LCS: removed, but we want it RpAtomic* CVisibilityPlugins::RenderFadingAtomic(RpAtomic *atomic, float camdist) { @@ -365,7 +418,6 @@ CVisibilityPlugins::RenderFadingAtomic(RpAtomic *atomic, float camdist) } - RpAtomic* CVisibilityPlugins::RenderVehicleHiDetailCB(RpAtomic *atomic) { @@ -382,6 +434,10 @@ CVisibilityPlugins::RenderVehicleHiDetailCB(RpAtomic *atomic) if(dot > 0.0f && ((flags & ATOMIC_FLAG_ANGLECULL) || 0.1f*DistToCameraSq < dot*dot)) return atomic; } +#ifdef VIS_DISTANCE_ALPHA + if(GetObjectDistanceAlpha((RwObject*)RpAtomicGetClump(atomic)) == 255 || + !InsertAtomicIntoSortedList(atomic, DistToCameraSq)) +#endif RENDERCALLBACK(atomic); } return atomic; @@ -474,6 +530,8 @@ CVisibilityPlugins::RenderVehicleHiDetailCB_Boat_Far(RpAtomic *atomic) return atomic; } +/* +//LCS: removed RpAtomic* CVisibilityPlugins::RenderVehicleHiDetailAlphaCB_Boat(RpAtomic *atomic) { @@ -486,6 +544,7 @@ CVisibilityPlugins::RenderVehicleHiDetailAlphaCB_Boat(RpAtomic *atomic) } return atomic; } +*/ RpAtomic* CVisibilityPlugins::RenderVehicleLoDetailCB_Boat(RpAtomic *atomic) @@ -496,9 +555,9 @@ CVisibilityPlugins::RenderVehicleLoDetailCB_Boat(RpAtomic *atomic) clump = RpAtomicGetClump(atomic); if(DistToCameraSq >= ms_vehicleLod0Dist){ alpha = GetClumpAlpha(clump); - if(alpha == 255) - RENDERCALLBACK(atomic); - else +// if(alpha == 255) +// RENDERCALLBACK(atomic); +// else RenderAlphaAtomic(atomic, alpha); } return atomic; @@ -513,9 +572,9 @@ CVisibilityPlugins::RenderVehicleLoDetailCB_Boat_Far(RpAtomic *atomic) clump = RpAtomicGetClump(atomic); if(DistToCameraSq >= ms_bigVehicleLod1Dist){ alpha = GetClumpAlpha(clump); - if(alpha == 255) - RENDERCALLBACK(atomic); - else +// if(alpha == 255) +// RENDERCALLBACK(atomic); +// else RenderAlphaAtomic(atomic, alpha); } return atomic; @@ -575,9 +634,9 @@ CVisibilityPlugins::RenderVehicleReallyLowDetailCB(RpAtomic *atomic) clump = RpAtomicGetClump(atomic); if(DistToCameraSq >= ms_vehicleLod0Dist){ alpha = GetClumpAlpha(clump); - if(alpha == 255) - RENDERCALLBACK(atomic); - else +// if(alpha == 255) +// RENDERCALLBACK(atomic); +// else RenderAlphaAtomic(atomic, alpha); } return atomic; @@ -630,8 +689,7 @@ CVisibilityPlugins::RenderTrainHiDetailAlphaCB(RpAtomic *atomic) return atomic; if(flags & ATOMIC_FLAG_DRAWLAST){ - // sort before clump - if(!InsertAtomicIntoSortedList(atomic, DistToCameraSq - 0.0001f)) + if(!InsertAtomicIntoSortedList(atomic, DistToCameraSq)) RENDERCALLBACK(atomic); }else{ if(!InsertAtomicIntoSortedList(atomic, DistToCameraSq + dot)) @@ -676,28 +734,31 @@ CVisibilityPlugins::RenderVehicleTailRotorAlphaCB(RpAtomic *atomic) return atomic; } +/* RpAtomic* CVisibilityPlugins::RenderPlayerCB(RpAtomic *atomic) { -// LCS: removed -// if(CWorld::Players[0].m_pSkinTexture) -// RpGeometryForAllMaterials(RpAtomicGetGeometry(atomic), SetTextureCB, CWorld::Players[0].m_pSkinTexture); + if(CWorld::Players[0].m_pSkinTexture) + RpGeometryForAllMaterials(RpAtomicGetGeometry(atomic), SetTextureCB, CWorld::Players[0].m_pSkinTexture); RENDERCALLBACK(atomic); return atomic; } +*/ RpAtomic* CVisibilityPlugins::RenderPedCB(RpAtomic *atomic) { + RpClump *clump; + float dist; int32 alpha; - RwV3d cam2atm; - RwV3dSub(&cam2atm, &RwFrameGetLTM(RpAtomicGetFrame(atomic))->pos, ms_pCameraPosn); - if(RwV3dDotProduct(&cam2atm, &cam2atm) < ms_pedLod1Dist){ - alpha = GetClumpAlpha(RpAtomicGetClump(atomic)); - if(alpha == 255) - RENDERCALLBACK(atomic); - else + clump = RpAtomicGetClump(atomic); + dist = GetDistanceSquaredFromCamera(RpClumpGetFrame(clump)); + if(dist < ms_pedLodDist){ + alpha = GetClumpAlpha(clump); +// if(alpha == 255) +// RENDERCALLBACK(atomic); +// else RenderAlphaAtomic(atomic, alpha); } return atomic; @@ -770,24 +831,26 @@ CVisibilityPlugins::DefaultVisibilityCB(RpClump *clump) bool CVisibilityPlugins::FrustumSphereCB(RpClump *clump) { - RwSphere sphere; - RwFrame *frame = RpClumpGetFrame(clump); + return true; +} - CClumpModelInfo *modelInfo = (CClumpModelInfo*)GetFrameHierarchyId(frame); - sphere.radius = modelInfo->GetColModel()->boundingSphere.radius; - sphere.center.x = modelInfo->GetColModel()->boundingSphere.center.x; - sphere.center.y = modelInfo->GetColModel()->boundingSphere.center.y; - sphere.center.z = modelInfo->GetColModel()->boundingSphere.center.z; - RwV3dTransformPoints(&sphere.center, &sphere.center, 1, RwFrameGetLTM(frame)); - return RwCameraFrustumTestSphere(ms_pCamera, &sphere) != rwSPHEREOUTSIDE; +bool +CVisibilityPlugins::MloVisibilityCB(RpClump *clump) +{ + RwFrame *frame = RpClumpGetFrame(clump); + CMloModelInfo *modelInfo = (CMloModelInfo*)GetFrameHierarchyId(frame); + if (SQR(modelInfo->drawDist) < GetDistanceSquaredFromCamera(frame)) + return false; + return CVisibilityPlugins::FrustumSphereCB(clump); } bool CVisibilityPlugins::VehicleVisibilityCB(RpClump *clump) { - if (GetDistanceSquaredFromCamera(RpClumpGetFrame(clump)) <= ms_vehicleLod1Dist) - return FrustumSphereCB(clump); - return false; + RwFrame *frame = RpClumpGetFrame(clump); + if (ms_vehicleLod1Dist < GetDistanceSquaredFromCamera(frame)) + return false; + return FrustumSphereCB(clump); } bool @@ -838,8 +901,12 @@ CVisibilityPlugins::PluginAttach(void) void* CVisibilityPlugins::AtomicConstructor(void *object, int32, int32) { - ATOMICEXT(object)->modelInfo = nil; + ATOMICEXT(object)->modelId = -1; +#ifdef VIS_DISTANCE_ALPHA + // This seems strange, want to start out invisible before fading in + // but maybe it's set elsewhere? ATOMICEXT(object)->distanceAlpha = 255; +#endif return object; } @@ -860,14 +927,29 @@ void CVisibilityPlugins::SetAtomicModelInfo(RpAtomic *atomic, CSimpleModelInfo *modelInfo) { - AtomicExt *ext = ATOMICEXT(atomic); - ext->modelInfo = modelInfo; + int id; + + for(id = 0; id < MODELINFOSIZE; id++) + if(CModelInfo::GetModelInfo(id) == modelInfo){ + ATOMICEXT(atomic)->modelId = id; + return; + } + ATOMICEXT(atomic)->modelId = -1; +} + +void +CVisibilityPlugins::SetAtomicModelIndex(RpAtomic *atomic, int modelId) +{ + ATOMICEXT(atomic)->modelId = modelId; } CSimpleModelInfo* CVisibilityPlugins::GetAtomicModelInfo(RpAtomic *atomic) { - return ATOMICEXT(atomic)->modelInfo; + int id = ATOMICEXT(atomic)->modelId; + if(id == -1) + return nil; + return (CSimpleModelInfo*)CModelInfo::GetModelInfo(id); } void @@ -882,6 +964,12 @@ CVisibilityPlugins::ClearAtomicFlag(RpAtomic *atomic, int f) ATOMICEXT(atomic)->flags &= ~f; } +void +CVisibilityPlugins::SetAtomicId(RpAtomic *atomic, int id) +{ + ATOMICEXT(atomic)->flags = id; +} + int CVisibilityPlugins::GetAtomicId(RpAtomic *atomic) { @@ -967,7 +1055,9 @@ CVisibilityPlugins::SetClumpModelInfo(RpClump *clump, CClumpModelInfo *modelInfo // Unused switch (modelInfo->GetModelType()) { - // ignore MLO + case MITYPE_MLO: + CLUMPEXT(clump)->visibilityCB = MloVisibilityCB; + break; case MITYPE_VEHICLE: vmi = (CVehicleModelInfo*)modelInfo; if(vmi->m_vehicleType == VEHICLE_TYPE_TRAIN || @@ -981,6 +1071,12 @@ CVisibilityPlugins::SetClumpModelInfo(RpClump *clump, CClumpModelInfo *modelInfo } } +CClumpModelInfo* +CVisibilityPlugins::GetClumpModelInfo(RpClump *clump) +{ + return (CClumpModelInfo*)GetFrameHierarchyId(RpClumpGetFrame(clump)); +} + void CVisibilityPlugins::SetClumpAlpha(RpClump *clump, int alpha) { @@ -993,6 +1089,13 @@ CVisibilityPlugins::GetClumpAlpha(RpClump *clump) return CLUMPEXT(clump)->alpha; } +bool +CVisibilityPlugins::IsClumpVisible(RpClump *clump) +{ + return CLUMPEXT(clump)->visibilityCB(clump); +} + +#ifdef VIS_DISTANCE_ALPHA // LCS walks the atomic list manually but we want to be compatible with both RW and librw, // so this code isn't quite original and uses callbacks instead. static RpAtomic* @@ -1045,3 +1148,4 @@ CVisibilityPlugins::GetObjectDistanceAlpha(RwObject *object) else return GetClumpDistanceAlpha((RpClump*)object); } +#endif diff --git a/src/rw/VisibilityPlugins.h b/src/rw/VisibilityPlugins.h index 3a3e555b..0f7048cd 100644 --- a/src/rw/VisibilityPlugins.h +++ b/src/rw/VisibilityPlugins.h @@ -21,9 +21,9 @@ public: }; static CLinkList<AlphaObjectInfo> m_alphaList; - static CLinkList<AlphaObjectInfo> m_alphaBoatAtomicList; + //static CLinkList<AlphaObjectInfo> m_alphaBoatAtomicList; static CLinkList<AlphaObjectInfo> m_alphaEntityList; - static CLinkList<AlphaObjectInfo> m_alphaUnderwaterEntityList; + //static CLinkList<AlphaObjectInfo> m_alphaUnderwaterEntityList; #ifdef NEW_RENDERER static CLinkList<AlphaObjectInfo> m_alphaBuildingList; #endif @@ -35,7 +35,7 @@ public: static float ms_vehicleFadeDist; static float ms_bigVehicleLod0Dist; static float ms_bigVehicleLod1Dist; - static float ms_pedLod1Dist; + static float ms_pedLodDist; static float ms_pedFadeDist; static void Initialise(void); @@ -44,7 +44,7 @@ public: static bool InsertEntityIntoSortedList(CEntity *e, float dist); static void InitAlphaAtomicList(void); static bool InsertAtomicIntoSortedList(RpAtomic *a, float dist); - static bool InsertAtomicIntoBoatSortedList(RpAtomic *a, float dist); +// static bool InsertAtomicIntoBoatSortedList(RpAtomic *a, float dist); static void SetRenderWareCamera(RwCamera *camera); static void SetupVehicleVariables(RpClump *vehicle); @@ -52,7 +52,7 @@ public: static RpAtomic *RenderWheelAtomicCB(RpAtomic *atomic); static RpAtomic *RenderObjNormalAtomic(RpAtomic *atomic); static RpAtomic *RenderAlphaAtomic(RpAtomic *atomic, int alpha); - static RpAtomic *RenderWeaponCB(RpAtomic *atomic); +// static RpAtomic *RenderWeaponCB(RpAtomic *atomic); static RpAtomic *RenderFadingAtomic(RpAtomic *atm, float dist); static RpAtomic *RenderVehicleHiDetailCB(RpAtomic *atomic); @@ -60,7 +60,7 @@ public: static RpAtomic *RenderVehicleHiDetailCB_BigVehicle(RpAtomic *atomic); static RpAtomic *RenderVehicleHiDetailAlphaCB_BigVehicle(RpAtomic *atomic); static RpAtomic *RenderVehicleHiDetailCB_Boat(RpAtomic *atomic); - static RpAtomic *RenderVehicleHiDetailAlphaCB_Boat(RpAtomic *atomic); +// static RpAtomic *RenderVehicleHiDetailAlphaCB_Boat(RpAtomic *atomic); static RpAtomic *RenderVehicleHiDetailCB_Boat_Far(RpAtomic *atomic); static RpAtomic *RenderVehicleLoDetailCB_Boat(RpAtomic *atomic); static RpAtomic *RenderVehicleLoDetailCB_Boat_Far(RpAtomic *atomic); @@ -73,12 +73,12 @@ public: static RpAtomic *RenderVehicleRotorAlphaCB(RpAtomic *atomic); static RpAtomic *RenderVehicleTailRotorAlphaCB(RpAtomic *atomic); - static RpAtomic *RenderPlayerCB(RpAtomic *atomic); +// static RpAtomic *RenderPlayerCB(RpAtomic *atomic); static RpAtomic *RenderPedCB(RpAtomic *atomic); // for skinned models with only one clump static void RenderAtomicList(CLinkList<AlphaObjectInfo> &list); static void RenderAlphaAtomics(void); - static void RenderBoatAlphaAtomics(void); +// static void RenderBoatAlphaAtomics(void); static void RenderFadingEntities(CLinkList<AlphaObjectInfo> &list); static void RenderFadingEntities(void); static void RenderFadingUnderwaterEntities(void); @@ -86,6 +86,7 @@ public: // All actually unused static bool DefaultVisibilityCB(RpClump *clump); static bool FrustumSphereCB(RpClump *clump); + static bool MloVisibilityCB(RpClump *clump); static bool VehicleVisibilityCB(RpClump *clump); static bool VehicleVisibilityCB_BigVehicle(RpClump *clump); @@ -100,15 +101,19 @@ public: struct AtomicExt { union { - CSimpleModelInfo *modelInfo; // used by SimpleModelInfo + int16 modelId; // used by SimpleModelInfo int flags; // used by ClumpModelInfo }; - int distanceAlpha; // not sure where this is in PS2/PSP LCS +#ifdef VIS_DISTANCE_ALPHA + int distanceAlpha; +#endif }; static void SetAtomicModelInfo(RpAtomic*, CSimpleModelInfo*); + static void SetAtomicModelIndex(RpAtomic *atomic, int modelId); static CSimpleModelInfo *GetAtomicModelInfo(RpAtomic *atomic); static void SetAtomicFlag(RpAtomic*, int); static void ClearAtomicFlag(RpAtomic*, int); + static void SetAtomicId(RpAtomic *atomic, int); static int GetAtomicId(RpAtomic *atomic); static void SetAtomicRenderCallback(RpAtomic*, RpAtomicCallBackRender); @@ -138,8 +143,10 @@ public: int alpha; }; static void SetClumpModelInfo(RpClump*, CClumpModelInfo*); + static CClumpModelInfo *GetClumpModelInfo(RpClump*); static void SetClumpAlpha(RpClump*, int); static int GetClumpAlpha(RpClump*); + static bool IsClumpVisible(RpClump*); static void SetClumpDistanceAlpha(RpClump*, int); static int GetClumpDistanceAlpha(RpClump*); @@ -149,8 +156,10 @@ public: int32 offset, int32 len); static int32 ms_clumpPluginOffset; +#ifdef VIS_DISTANCE_ALPHA static void SetObjectDistanceAlpha(RwObject *object, int alpha); static int GetObjectDistanceAlpha(RwObject *object); +#endif static bool PluginAttach(void); }; diff --git a/src/vehicles/Plane.cpp b/src/vehicles/Plane.cpp index 0b40ca7e..7684d7dd 100644 --- a/src/vehicles/Plane.cpp +++ b/src/vehicles/Plane.cpp @@ -681,6 +681,12 @@ CPlane::Render(void) CEntity::Render(); } +void +CPlane::RenderAllRemaning(void) +{ + // TODO(LCS) +} + #define CRUISE_SPEED (50.0f) #define TAXI_SPEED (5.0f) diff --git a/src/vehicles/Plane.h b/src/vehicles/Plane.h index c8f02048..ee65913b 100644 --- a/src/vehicles/Plane.h +++ b/src/vehicles/Plane.h @@ -59,6 +59,7 @@ public: void Render(void); void FlagToDestroyWhenNextProcessed() { bRemoveFromWorld = true; } + static void RenderAllRemaning(void); static void InitPlanes(void); static void Shutdown(void); static CPlaneNode *LoadPath(char const *filename, int32 &numNodes, float &totalLength, bool loop); |