diff options
Diffstat (limited to '')
-rw-r--r-- | src/rw/Lights.cpp | 7 | ||||
-rw-r--r-- | src/rw/RwHelper.cpp | 2 | ||||
-rw-r--r-- | src/rw/TxdStore.cpp | 93 | ||||
-rw-r--r-- | src/rw/TxdStore.h | 11 | ||||
-rw-r--r-- | src/rw/VisibilityPlugins.cpp | 31 | ||||
-rw-r--r-- | src/rw/VisibilityPlugins.h | 2 |
6 files changed, 127 insertions, 19 deletions
diff --git a/src/rw/Lights.cpp b/src/rw/Lights.cpp index 772e1961..5f8ba823 100644 --- a/src/rw/Lights.cpp +++ b/src/rw/Lights.cpp @@ -24,12 +24,7 @@ RwRGBAReal DirectionalLightColourForFrame; RwRGBAReal AmbientLightColour; RwRGBAReal DirectionalLightColour; -#ifdef EXTENDED_COLOURFILTER -#include "postfx.h" -#define USEBLURCOLORS CPostFX::UseBlurColours() -#else -#define USEBLURCOLORS CMBlur::BlurOn -#endif +#define USEBLURCOLORS true // actually CMBlur::BlurOn, but that's always supposed to be on void SetLightsWithTimeOfDayColour(RpWorld *) diff --git a/src/rw/RwHelper.cpp b/src/rw/RwHelper.cpp index 69f57933..6021b866 100644 --- a/src/rw/RwHelper.cpp +++ b/src/rw/RwHelper.cpp @@ -18,7 +18,7 @@ bool gPS2alphaTest = true; #else bool gPS2alphaTest = false; #endif -bool gBackfaceCulling = true; +bool gBackfaceCulling = false; // can we ever enable this in LCS even? #if !defined(FINAL) || defined(DEBUGMENU) static bool charsetOpen; diff --git a/src/rw/TxdStore.cpp b/src/rw/TxdStore.cpp index 0bd29718..b7936bcf 100644 --- a/src/rw/TxdStore.cpp +++ b/src/rw/TxdStore.cpp @@ -1,5 +1,7 @@ #include "common.h" +#include "main.h" +#include "smallHeap.h" #include "templates.h" #include "General.h" #include "Streaming.h" @@ -9,13 +11,19 @@ CPool<TxdDef,TxdDef> *CTxdStore::ms_pTxdPool; RwTexDictionary *CTxdStore::ms_pStoredTxd; +// LCS: file done except unused: +// CTexListStore::RemoveTexListChunk(int) +// CTexListStore::validateRefs(void) +// CTexListStore::Write(base::cRelocatableChunkWriter &) + void CTxdStore::Initialise(void) { - if(ms_pTxdPool == nil) + if(gMakeResources && ms_pTxdPool == nil) ms_pTxdPool = new CPool<TxdDef,TxdDef>(TXDSTORESIZE, "TexDictionary"); } +// removed in LCS but we should probably keep it void CTxdStore::Shutdown(void) { @@ -23,6 +31,7 @@ CTxdStore::Shutdown(void) delete ms_pTxdPool; } +// removed in LCS but we should probably keep it void CTxdStore::GameShutdown(void) { @@ -42,6 +51,7 @@ CTxdStore::AddTxdSlot(const char *name) assert(def); def->texDict = nil; def->refCount = 0; + def->refCountGu = 0; strcpy(def->name, name); return ms_pTxdPool->GetJustIndex(def); } @@ -95,7 +105,11 @@ CTxdStore::SetCurrentTxd(int slot) void CTxdStore::Create(int slot) { - GetSlot(slot)->texDict = RwTexDictionaryCreate(); + TxdDef *def = GetSlot(slot); + def->texDict = RwTexDictionaryCreate(); + // LCS: mobile sets the txd name here, but txds don't really have names + def->refCount = 0; + def->refCountGu = 0; } int @@ -111,6 +125,20 @@ CTxdStore::AddRef(int slot) } void +CTxdStore::AddRefEvenIfNotInMemory(int slot) +{ + GetSlot(slot)->refCount++; +} + +void +CTxdStore::AddRefGu(int slot) +{ + TxdDef *def = GetSlot(slot); + def->refCount++; + def->refCountGu++; +} + +void CTxdStore::RemoveRef(int slot) { if(--GetSlot(slot)->refCount <= 0) @@ -118,6 +146,15 @@ CTxdStore::RemoveRef(int slot) } void +CTxdStore::RemoveRefGu(int slot) +{ + TxdDef *def = GetSlot(slot); + def->refCount--; + if(gUseChunkFiles) + def->refCountGu--; +} + +void CTxdStore::RemoveRefWithoutDelete(int slot) { GetSlot(slot)->refCount--; @@ -128,15 +165,32 @@ CTxdStore::LoadTxd(int slot, RwStream *stream) { TxdDef *def = GetSlot(slot); - if(RwStreamFindChunk(stream, rwID_TEXDICTIONARY, nil, nil)){ - def->texDict = RwTexDictionaryGtaStreamRead(stream); - return def->texDict != nil; + if(stream){ + if(RwStreamFindChunk(stream, rwID_TEXDICTIONARY, nil, nil)){ + def->texDict = RwTexDictionaryGtaStreamRead(stream); + return def->texDict != nil; + } + }else{ + // TODO(LCS)? fall back reading from file } printf("Failed to load TXD\n"); return false; } bool +CTxdStore::LoadTxd(int slot, void *data, void *chunk) +{ + TxdDef *def = GetSlot(slot); + def->texDict = (RwTexDictionary*)data; + if(strncasecmp(def->name, "radar", 5) == 0){ + def->refCount = 0; + def->refCountGu = 0; + } + CStreaming::RegisterPointer(&def->texDict, 3, true); + return def->texDict != nil; +} + +bool CTxdStore::LoadTxd(int slot, const char *filename) { RwStream *stream; @@ -152,6 +206,7 @@ CTxdStore::LoadTxd(int slot, const char *filename) return ret; } +// removed in LCS but we should probably keep it bool CTxdStore::StartLoadTxd(int slot, RwStream *stream) { @@ -165,6 +220,7 @@ CTxdStore::StartLoadTxd(int slot, RwStream *stream) } } +// removed in LCS but we should probably keep it bool CTxdStore::FinishLoadTxd(int slot, RwStream *stream) { @@ -174,10 +230,31 @@ CTxdStore::FinishLoadTxd(int slot, RwStream *stream) } void -CTxdStore::RemoveTxd(int slot) +CTxdStore::RemoveTxd(int slot, bool notChunk) { TxdDef *def = GetSlot(slot); - if(def->texDict) - RwTexDictionaryDestroy(def->texDict); + if(def->texDict){ + if(!gUseChunkFiles || notChunk) + RwTexDictionaryDestroy(def->texDict); + else{ + // TODO? Rsl3D specific: RslTextureDestroyDispList for all textures + CStreaming::UnregisterPointer(&def->texDict, 3); + cSmallHeap::msInstance.Free(def->texDict); + } + } def->texDict = nil; + def->refCount = 0; + def->refCountGu = 0; +} + +void +CTxdStore::Load(RwTexDictionary *stored, CPool<TxdDef> *pool) +{ + ms_pTxdPool = pool; + ms_pStoredTxd = stored; + for(int i = 0; i < TXDSTORESIZE; i++){ + TxdDef *def = GetSlot(i); + if(def) + def->refCount = def->texDict != nil; + } } diff --git a/src/rw/TxdStore.h b/src/rw/TxdStore.h index 937fd1b7..31fcf87f 100644 --- a/src/rw/TxdStore.h +++ b/src/rw/TxdStore.h @@ -4,7 +4,8 @@ struct TxdDef { RwTexDictionary *texDict; - int refCount; + int16 refCount; + int16 refCountGu; char name[20]; }; @@ -26,13 +27,19 @@ public: static void Create(int slot); static int GetNumRefs(int slot); static void AddRef(int slot); + static void AddRefEvenIfNotInMemory(int slot); + static void AddRefGu(int slot); static void RemoveRef(int slot); + static void RemoveRefGu(int slot); static void RemoveRefWithoutDelete(int slot); static bool LoadTxd(int slot, RwStream *stream); + static bool LoadTxd(int slot, void *data, void *chunk); static bool LoadTxd(int slot, const char *filename); static bool StartLoadTxd(int slot, RwStream *stream); static bool FinishLoadTxd(int slot, RwStream *stream); - static void RemoveTxd(int slot); + static void RemoveTxd(int slot, bool notChunk = false); + + static void Load(RwTexDictionary *stored, CPool<TxdDef> *pool); static TxdDef *GetSlot(int slot) { assert(slot >= 0); diff --git a/src/rw/VisibilityPlugins.cpp b/src/rw/VisibilityPlugins.cpp index 01db546c..eebbb93b 100644 --- a/src/rw/VisibilityPlugins.cpp +++ b/src/rw/VisibilityPlugins.cpp @@ -267,6 +267,7 @@ CVisibilityPlugins::RenderWheelAtomicCB(RpAtomic *atomic) mi = GetAtomicModelInfo(atomic); len = Sqrt(DistToCameraSq); + len *= 0.5f; // HACK HACK, LOD wheels look shite lodatm = mi->GetAtomicFromDistance(len * TheCamera.LODDistMultiplier / VEHICLE_LODDIST_MULTIPLIER); if(lodatm){ if(RpAtomicGetGeometry(lodatm) != RpAtomicGetGeometry(atomic)) @@ -466,6 +467,14 @@ CVisibilityPlugins::RenderVehicleHiDetailCB_Boat(RpAtomic *atomic) } RpAtomic* +CVisibilityPlugins::RenderVehicleHiDetailCB_Boat_Far(RpAtomic *atomic) +{ + if(DistToCameraSq < ms_bigVehicleLod1Dist) + RENDERCALLBACK(atomic); + return atomic; +} + +RpAtomic* CVisibilityPlugins::RenderVehicleHiDetailAlphaCB_Boat(RpAtomic *atomic) { if(DistToCameraSq < ms_vehicleLod0Dist){ @@ -496,6 +505,23 @@ CVisibilityPlugins::RenderVehicleLoDetailCB_Boat(RpAtomic *atomic) } RpAtomic* +CVisibilityPlugins::RenderVehicleLoDetailCB_Boat_Far(RpAtomic *atomic) +{ + RpClump *clump; + int32 alpha; + + clump = RpAtomicGetClump(atomic); + if(DistToCameraSq >= ms_bigVehicleLod1Dist){ + alpha = GetClumpAlpha(clump); + if(alpha == 255) + RENDERCALLBACK(atomic); + else + RenderAlphaAtomic(atomic, alpha); + } + return atomic; +} + +RpAtomic* CVisibilityPlugins::RenderVehicleLowDetailCB_BigVehicle(RpAtomic *atomic) { RwFrame *clumpframe; @@ -653,8 +679,9 @@ CVisibilityPlugins::RenderVehicleTailRotorAlphaCB(RpAtomic *atomic) RpAtomic* CVisibilityPlugins::RenderPlayerCB(RpAtomic *atomic) { - if(CWorld::Players[0].m_pSkinTexture) - RpGeometryForAllMaterials(RpAtomicGetGeometry(atomic), SetTextureCB, CWorld::Players[0].m_pSkinTexture); +// LCS: removed +// if(CWorld::Players[0].m_pSkinTexture) +// RpGeometryForAllMaterials(RpAtomicGetGeometry(atomic), SetTextureCB, CWorld::Players[0].m_pSkinTexture); RENDERCALLBACK(atomic); return atomic; } diff --git a/src/rw/VisibilityPlugins.h b/src/rw/VisibilityPlugins.h index 9cdbc0c7..f188096c 100644 --- a/src/rw/VisibilityPlugins.h +++ b/src/rw/VisibilityPlugins.h @@ -61,7 +61,9 @@ public: static RpAtomic *RenderVehicleHiDetailAlphaCB_BigVehicle(RpAtomic *atomic); static RpAtomic *RenderVehicleHiDetailCB_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); static RpAtomic *RenderVehicleLowDetailCB_BigVehicle(RpAtomic *atomic); static RpAtomic *RenderVehicleLowDetailAlphaCB_BigVehicle(RpAtomic *atomic); static RpAtomic *RenderVehicleReallyLowDetailCB(RpAtomic *atomic); |