Skip to content
Permalink
Browse files
CBuildings self-shadowing bug fixed
  • Loading branch information
CookiePLMonster committed Jul 31, 2014
1 parent 395f9e6 commit 73ce8237840ea9ddb6006afa0af4f0577b208fdd
Showing with 29 additions and 12 deletions.
  1. +4 −4 VCS PC/General.cpp
  2. +1 −1 VCS PC/General.h
  3. +5 −7 VCS PC/RealTimeShadowMgr.cpp
  4. +2 −0 VCS PC/RealTimeShadowMgr.h
  5. +17 −0 VCS PC/Shadows.cpp
@@ -35,7 +35,7 @@ void CEntity::SetRealTimeShadow(class CRealTimeShadow* pShadow)
static_cast<CPhysical*>(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);
});*/
});
@@ -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)
@@ -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<const void*>(0x53BE63, &g_realTimeShadowMan);
Memory::Patch<const void*>(0x53C63F, &g_realTimeShadowMan);
Memory::Patch<const void*>(0x53C9E5, &g_realTimeShadowMan);
//Memory::Patch<const void*>(0x53EA09, &g_realTimeShadowMan);
Memory::Patch<const void*>(0x53EA09, &g_realTimeShadowMan);
Memory::Patch<const void*>(0x542487, &g_realTimeShadowMan);
Memory::Patch<const void*>(0x5B1F38, &g_realTimeShadowMan);
Memory::Patch<const void*>(0x5BA478, &g_realTimeShadowMan);
@@ -642,8 +640,8 @@ static StaticPatcher Patcher([](){
//Memory::Patch<const void*>(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<const void*>(0x5BA12C, &g_realTimeShadowMan.m_bInitialised);
Memory::Patch<const void*>(0x5BA137, &g_realTimeShadowMan.m_bNeedsReinit);
@@ -88,6 +88,8 @@ class CRealTimeShadow
{
m_Camera.ReInit();
m_ResampledCamera.ReInit();
if ( m_pEntity )
m_pEntity->bIveBeenRenderedOnce = false;
}

void Destroy();
@@ -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);

0 comments on commit 73ce823

Please sign in to comment.