From 73ce8237840ea9ddb6006afa0af4f0577b208fdd Mon Sep 17 00:00:00 2001 From: Silent Date: Thu, 31 Jul 2014 16:39:34 +0200 Subject: [PATCH] CBuildings self-shadowing bug fixed --- VCS PC/General.cpp | 8 ++++---- VCS PC/General.h | 2 +- VCS PC/RealTimeShadowMgr.cpp | 12 +++++------- VCS PC/RealTimeShadowMgr.h | 2 ++ VCS PC/Shadows.cpp | 17 +++++++++++++++++ 5 files changed, 29 insertions(+), 12 deletions(-) diff --git a/VCS PC/General.cpp b/VCS PC/General.cpp index f853f6c..5319124 100644 --- a/VCS PC/General.cpp +++ b/VCS PC/General.cpp @@ -35,7 +35,7 @@ void CEntity::SetRealTimeShadow(class CRealTimeShadow* pShadow) static_cast(this)->SetRealTimeShadow(pShadow); } -/*static void __declspec(naked) EntityCtorHack() +static void __declspec(naked) EntityCtorHack() { _asm { @@ -57,10 +57,10 @@ static void __declspec(naked) EntityRenderHack() pop ecx retn } -}*/ +} -/*static StaticPatcher Patcher([](){ +static StaticPatcher Patcher([](){ Memory::InjectHook(0x532AD7, EntityCtorHack, PATCH_JUMP); Memory::InjectHook(0x5343E4, EntityRenderHack, PATCH_JUMP); - });*/ \ No newline at end of file + }); \ No newline at end of file diff --git a/VCS PC/General.h b/VCS PC/General.h index 088fdf2..344b380 100644 --- a/VCS PC/General.h +++ b/VCS PC/General.h @@ -181,7 +181,7 @@ class NOVMT CEntity : public CPlaceable //********* END CEntityInfo ************// // VCS PC class extension - //bool bIveBeenRenderedOnce : 1; // for realtime shadows + bool bIveBeenRenderedOnce : 1; // for realtime shadows public: explicit inline CEntity(int dummy) diff --git a/VCS PC/RealTimeShadowMgr.cpp b/VCS PC/RealTimeShadowMgr.cpp index e6a1cdd..2d60b49 100644 --- a/VCS PC/RealTimeShadowMgr.cpp +++ b/VCS PC/RealTimeShadowMgr.cpp @@ -61,7 +61,7 @@ RpAtomic* ShadowCameraRenderCB(RpAtomic* pAtomic, void* pData) RwUInt32 geometryFlags = RpGeometryGetFlags(pGeometry); RpGeometrySetFlags(pGeometry, geometryFlags & ~(rpGEOMETRYTEXTURED|rpGEOMETRYPRELIT| - rpGEOMETRYNORMALS|rpGEOMETRYLIGHT|rpGEOMETRYMODULATEMATERIALCOLOR|rpGEOMETRYTEXTURED2)); + /*rpGEOMETRYNORMALS|*/rpGEOMETRYLIGHT|rpGEOMETRYMODULATEMATERIALCOLOR|rpGEOMETRYTEXTURED2)); AtomicDefaultRenderCallBack(pAtomic); RpGeometrySetFlags(pGeometry, geometryFlags); @@ -148,7 +148,7 @@ RwCamera* CShadowCamera::Update(RpClump* pClump, CEntity* pEntity) RwTexture* CRealTimeShadow::Update() { - if ( m_pEntity->m_pRwObject /*&& m_pEntity->bIveBeenRenderedOnce*/ ) + if ( m_pEntity->m_pRwObject && m_pEntity->bIveBeenRenderedOnce ) { // Close enough to the object? CVector* pObjPos = m_pEntity->GetCoords(); @@ -378,8 +378,6 @@ void CRealTimeShadowManager::DoShadowThisFrame(CEntity* pEntity) } } -BYTE FakeBuilding[sizeof(CBuilding)]; - void CRealTimeShadowManager::GetRealTimeShadow(CEntity* pEntity) { bool bIsPlayer; @@ -633,7 +631,7 @@ static StaticPatcher Patcher([](){ Memory::Patch(0x53BE63, &g_realTimeShadowMan); Memory::Patch(0x53C63F, &g_realTimeShadowMan); Memory::Patch(0x53C9E5, &g_realTimeShadowMan); - //Memory::Patch(0x53EA09, &g_realTimeShadowMan); + Memory::Patch(0x53EA09, &g_realTimeShadowMan); Memory::Patch(0x542487, &g_realTimeShadowMan); Memory::Patch(0x5B1F38, &g_realTimeShadowMan); Memory::Patch(0x5BA478, &g_realTimeShadowMan); @@ -642,8 +640,8 @@ static StaticPatcher Patcher([](){ //Memory::Patch(0x856AD0, &g_realTimeShadowMan); // Shadows rendering AFTER RenderScene - Memory::InjectHook(0x53E0B9, UpdateShadowsHack); - Memory::Nop(0x53EA0D, 5); + //Memory::InjectHook(0x53E0B9, UpdateShadowsHack); + //Memory::Nop(0x53EA0D, 5); Memory::Patch(0x5BA12C, &g_realTimeShadowMan.m_bInitialised); Memory::Patch(0x5BA137, &g_realTimeShadowMan.m_bNeedsReinit); diff --git a/VCS PC/RealTimeShadowMgr.h b/VCS PC/RealTimeShadowMgr.h index 69f18cc..0de50e5 100644 --- a/VCS PC/RealTimeShadowMgr.h +++ b/VCS PC/RealTimeShadowMgr.h @@ -88,6 +88,8 @@ class CRealTimeShadow { m_Camera.ReInit(); m_ResampledCamera.ReInit(); + if ( m_pEntity ) + m_pEntity->bIveBeenRenderedOnce = false; } void Destroy(); diff --git a/VCS PC/Shadows.cpp b/VCS PC/Shadows.cpp index b6b1d5a..38ae311 100644 --- a/VCS PC/Shadows.cpp +++ b/VCS PC/Shadows.cpp @@ -248,6 +248,22 @@ static void __declspec(naked) GetShadowHack() } } +static void __declspec(naked) SelfShadowingFix() +{ + _asm + { + jnz SelfShadowingFix_DontCast + cmp esi, [ebx]CRealTimeShadow.m_pEntity + jz SelfShadowingFix_DontCast + push 70A841h + retn + +SelfShadowingFix_DontCast: + push 70A93Fh + retn + } +} + /*static void __declspec(naked) StoreRTPoleShadowHack() { _asm @@ -346,6 +362,7 @@ static StaticPatcher Patcher([](){ Memory::InjectHook(0x70BDA4, StoreRTVehicleShadowHack); Memory::InjectHook(0x59FEDB, StoreRTObjectShadowHack, PATCH_JUMP); Memory::InjectHook(0x707CAA, GetShadowHack, PATCH_JUMP); + Memory::InjectHook(0x70A83B, SelfShadowingFix, PATCH_JUMP); //Memory::InjectHook(0x70C753, StoreRTPoleShadowHack); //Memory::InjectHook(0x705590, &CShadowCamera::SetCenter, PATCH_JUMP);