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