Factorize weapon and muzzleflash rendering into separate options

This commit is contained in:
Silent 2019-03-06 21:59:14 +01:00
parent 6b2ad034cb
commit e94fec9c6f
No known key found for this signature in database
GPG key ID: AE53149BB0C45AF1
3 changed files with 29 additions and 17 deletions

View file

@ -41,7 +41,7 @@ void CPed::ResetGunFlashAlpha()
} }
} }
void CPed::RenderWeapon(bool bMuzzleFlash, bool bForShadow) void CPed::RenderWeapon(bool bWeapon, bool bMuzzleFlash, bool bForShadow)
{ {
if ( m_pWeaponObject ) if ( m_pWeaponObject )
{ {
@ -62,13 +62,19 @@ void CPed::RenderWeapon(bool bMuzzleFlash, bool bForShadow)
RwFrameUpdateObjects(pFrame); RwFrameUpdateObjects(pFrame);
if ( bForShadow ) if ( bForShadow )
RpClumpForAllAtomics(reinterpret_cast<RpClump*>(m_pWeaponObject), ShadowCameraRenderCB); RpClumpForAllAtomics(reinterpret_cast<RpClump*>(m_pWeaponObject), ShadowCameraRenderCB);
else if ( !bMuzzleFlash ) else
RpClumpRender(reinterpret_cast<RpClump*>(m_pWeaponObject));
else if ( m_pMuzzleFlashFrame )
{ {
SetGunFlashAlpha(false); if ( bWeapon )
RpAtomic* atomic = reinterpret_cast<RpAtomic*>(GetFirstObject(m_pMuzzleFlashFrame)); {
RpAtomicRender( atomic ); RpClumpRender(reinterpret_cast<RpClump*>(m_pWeaponObject));
}
if ( bMuzzleFlash && m_pMuzzleFlashFrame != nullptr )
{
SetGunFlashAlpha(false);
RpAtomic* atomic = reinterpret_cast<RpAtomic*>(GetFirstObject(m_pMuzzleFlashFrame));
RpAtomicRender( atomic );
}
} }
// Dual weapons // Dual weapons
@ -84,13 +90,19 @@ void CPed::RenderWeapon(bool bMuzzleFlash, bool bForShadow)
RwFrameUpdateObjects(pFrame); RwFrameUpdateObjects(pFrame);
if ( bForShadow ) if ( bForShadow )
RpClumpForAllAtomics(reinterpret_cast<RpClump*>(m_pWeaponObject), ShadowCameraRenderCB); RpClumpForAllAtomics(reinterpret_cast<RpClump*>(m_pWeaponObject), ShadowCameraRenderCB);
else if ( !bMuzzleFlash ) else
RpClumpRender(reinterpret_cast<RpClump*>(m_pWeaponObject));
else if ( m_pMuzzleFlashFrame )
{ {
SetGunFlashAlpha(true); if ( bWeapon )
RpAtomic* atomic = reinterpret_cast<RpAtomic*>(GetFirstObject(m_pMuzzleFlashFrame)); {
RpAtomicRender( atomic ); RpClumpRender(reinterpret_cast<RpClump*>(m_pWeaponObject));
}
if ( bMuzzleFlash && m_pMuzzleFlashFrame != nullptr )
{
SetGunFlashAlpha(true);
RpAtomic* atomic = reinterpret_cast<RpAtomic*>(GetFirstObject(m_pMuzzleFlashFrame));
RpAtomicRender( atomic );
}
} }
} }
if ( bMuzzleFlash ) if ( bMuzzleFlash )
@ -101,7 +113,7 @@ void CPed::RenderWeapon(bool bMuzzleFlash, bool bForShadow)
void CPed::RenderForShadow() void CPed::RenderForShadow()
{ {
RpClumpForAllAtomics(reinterpret_cast<RpClump*>(m_pRwObject), ShadowCameraRenderCB); RpClumpForAllAtomics(reinterpret_cast<RpClump*>(m_pRwObject), ShadowCameraRenderCB);
RenderWeapon(false, true); RenderWeapon(true, false, true);
// Render jetpack // Render jetpack
auto* pJetPackTask = pPedIntelligence->GetTaskJetPack(); auto* pJetPackTask = pPedIntelligence->GetTaskJetPack();

View file

@ -314,7 +314,7 @@ public:
void SetGunFlashAlpha(bool bSecondWeapon); void SetGunFlashAlpha(bool bSecondWeapon);
void Say(uint16_t phrase, uint32_t param2 = 0, float volume = 1.0f, bool param4 = false, bool param5 = false, bool param6 = false); void Say(uint16_t phrase, uint32_t param2 = 0, float volume = 1.0f, bool param4 = false, bool param5 = false, bool param6 = false);
void RenderWeapon(bool bMuzzleFlash, bool bForShadow); void RenderWeapon(bool bWeapon, bool bMuzzleFlash, bool bForShadow);
void RenderForShadow(); void RenderForShadow();
static void (CPed::*orgGiveWeapon)(uint32_t weapon, uint32_t ammo, bool flag); static void (CPed::*orgGiveWeapon)(uint32_t weapon, uint32_t ammo, bool flag);

View file

@ -440,7 +440,7 @@ void RenderVehicleHiDetailAlphaCB_HunterDoor(RpAtomic* pAtomic)
void RenderWeapon(CPed* pPed) void RenderWeapon(CPed* pPed)
{ {
pPed->RenderWeapon(false, false); pPed->RenderWeapon(true, false, false);
ms_weaponPedsForPC.Insert(pPed); ms_weaponPedsForPC.Insert(pPed);
} }
@ -456,7 +456,7 @@ void RenderWeaponPedsForPC()
{ {
CPed* ped = **it; CPed* ped = **it;
ped->SetupLighting(); ped->SetupLighting();
ped->RenderWeapon(true, false); ped->RenderWeapon(false, true, false);
ped->RemoveLighting(); ped->RemoveLighting();
} }
} }