mirror of
https://github.com/CookiePLMonster/SilentPatch.git
synced 2024-11-22 05:22:32 +01:00
Factorized a duplicate part of CPed::RenderWeapon into a lambda function
This commit is contained in:
parent
60c4eb3b66
commit
515afe5daf
@ -51,15 +51,10 @@ void CPed::RenderWeapon(bool bWeapon, bool bMuzzleFlash, bool bForShadow)
|
||||
RwFrame* pFrame = RpClumpGetFrame(reinterpret_cast<RpClump*>(m_pWeaponObject));
|
||||
*RwFrameGetMatrix(pFrame) = RpHAnimHierarchyGetMatrixArray(pAnimHierarchy)[RpHAnimIDGetIndex(pAnimHierarchy, bHasParachute ? 3 : 24)];
|
||||
|
||||
if ( bHasParachute )
|
||||
auto renderOneWeapon = [this](bool bWeapon, bool bMuzzleFlash, bool bForShadow, bool bRightGun)
|
||||
{
|
||||
const RwV3d vecParachuteTranslation = { 0.1f, -0.15f, 0.0f };
|
||||
const RwV3d vecParachuteRotation = { 0.0f, 1.0f, 0.0f };
|
||||
RwMatrixTranslate(RwFrameGetMatrix(pFrame), &vecParachuteTranslation, rwCOMBINEPRECONCAT);
|
||||
RwMatrixRotate(RwFrameGetMatrix(pFrame), &vecParachuteRotation, 90.0f, rwCOMBINEPRECONCAT);
|
||||
}
|
||||
RwFrameUpdateObjects(RpClumpGetFrame(reinterpret_cast<RpClump*>(m_pWeaponObject)));
|
||||
|
||||
RwFrameUpdateObjects(pFrame);
|
||||
if ( bForShadow )
|
||||
RpClumpForAllAtomics(reinterpret_cast<RpClump*>(m_pWeaponObject), ShadowCameraRenderCB);
|
||||
else
|
||||
@ -74,11 +69,22 @@ void CPed::RenderWeapon(bool bWeapon, bool bMuzzleFlash, bool bForShadow)
|
||||
RwScopedRenderState zWrite(rwRENDERSTATEZWRITEENABLE);
|
||||
RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, FALSE);
|
||||
|
||||
SetGunFlashAlpha(false);
|
||||
SetGunFlashAlpha(bRightGun);
|
||||
RpAtomic* atomic = reinterpret_cast<RpAtomic*>(GetFirstObject(m_pMuzzleFlashFrame));
|
||||
RpAtomicRender( atomic );
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
if ( bHasParachute )
|
||||
{
|
||||
const RwV3d vecParachuteTranslation = { 0.1f, -0.15f, 0.0f };
|
||||
const RwV3d vecParachuteRotation = { 0.0f, 1.0f, 0.0f };
|
||||
RwMatrixTranslate(RwFrameGetMatrix(pFrame), &vecParachuteTranslation, rwCOMBINEPRECONCAT);
|
||||
RwMatrixRotate(RwFrameGetMatrix(pFrame), &vecParachuteRotation, 90.0f, rwCOMBINEPRECONCAT);
|
||||
}
|
||||
|
||||
renderOneWeapon(bWeapon, bMuzzleFlash, bForShadow, false);
|
||||
|
||||
// Dual weapons
|
||||
if ( CWeaponInfo::GetWeaponInfo(weaponSlots[m_bActiveWeapon].m_eWeaponType, GetWeaponSkillForRenderWeaponPedsForPC())->hexFlags >> 11 & 1 )
|
||||
@ -90,26 +96,7 @@ void CPed::RenderWeapon(bool bWeapon, bool bMuzzleFlash, bool bForShadow)
|
||||
RwMatrixRotate(RwFrameGetMatrix(pFrame), &vecParachuteRotation, 180.0f, rwCOMBINEPRECONCAT);
|
||||
RwMatrixTranslate(RwFrameGetMatrix(pFrame), &vecParachuteTranslation, rwCOMBINEPRECONCAT);
|
||||
|
||||
RwFrameUpdateObjects(pFrame);
|
||||
if ( bForShadow )
|
||||
RpClumpForAllAtomics(reinterpret_cast<RpClump*>(m_pWeaponObject), ShadowCameraRenderCB);
|
||||
else
|
||||
{
|
||||
if ( bWeapon )
|
||||
{
|
||||
RpClumpRender(reinterpret_cast<RpClump*>(m_pWeaponObject));
|
||||
}
|
||||
|
||||
if ( bMuzzleFlash && m_pMuzzleFlashFrame != nullptr )
|
||||
{
|
||||
RwScopedRenderState zWrite(rwRENDERSTATEZWRITEENABLE);
|
||||
RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, FALSE);
|
||||
|
||||
SetGunFlashAlpha(true);
|
||||
RpAtomic* atomic = reinterpret_cast<RpAtomic*>(GetFirstObject(m_pMuzzleFlashFrame));
|
||||
RpAtomicRender( atomic );
|
||||
}
|
||||
}
|
||||
renderOneWeapon(bWeapon, bMuzzleFlash, bForShadow, true);
|
||||
}
|
||||
if ( bMuzzleFlash )
|
||||
ResetGunFlashAlpha();
|
||||
|
Loading…
Reference in New Issue
Block a user