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

View File

@ -314,7 +314,7 @@ public:
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 RenderWeapon(bool bMuzzleFlash, bool bForShadow);
void RenderWeapon(bool bWeapon, bool bMuzzleFlash, bool bForShadow);
void RenderForShadow();
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)
{
pPed->RenderWeapon(false, false);
pPed->RenderWeapon(true, false, false);
ms_weaponPedsForPC.Insert(pPed);
}
@ -456,7 +456,7 @@ void RenderWeaponPedsForPC()
{
CPed* ped = **it;
ped->SetupLighting();
ped->RenderWeapon(true, false);
ped->RenderWeapon(false, true, false);
ped->RemoveLighting();
}
}