@@ -6079,8 +6079,9 @@ void CClientPed::ReplaceAnimation(std::unique_ptr<CAnimBlendHierarchy>& pInterna
60796079
60806080void CClientPed::RestoreAnimation (std::unique_ptr<CAnimBlendHierarchy>& pInternalAnimHierarchy)
60816081{
6082- m_mapOfReplacedAnimations.erase (pInternalAnimHierarchy->GetInterface ());
6083- CIFPEngine::EngineApplyAnimation (*this , pInternalAnimHierarchy->GetInterface ());
6082+ CAnimBlendHierarchySAInterface* pInterface = pInternalAnimHierarchy->GetInterface ();
6083+ CIFPEngine::EngineApplyAnimation (*this , pInterface, pInterface);
6084+ m_mapOfReplacedAnimations.erase (pInterface);
60846085}
60856086
60866087void CClientPed::RestoreAnimations (const std::shared_ptr<CClientIFP>& IFP)
@@ -6089,7 +6090,8 @@ void CClientPed::RestoreAnimations(const std::shared_ptr<CClientIFP>& IFP)
60896090 {
60906091 if (std::addressof (*IFP.get ()) == std::addressof (*iter->second .pIFP .get ()))
60916092 {
6092- CIFPEngine::EngineApplyAnimation (*this , iter->first );
6093+ auto pAnimHierarchy = g_pGame->GetAnimManager ()->GetAnimBlendHierarchy (iter->first );
6094+ CIFPEngine::EngineApplyAnimation (*this , iter->first , iter->first );
60936095 iter = m_mapOfReplacedAnimations.erase (iter);
60946096 }
60956097 else
@@ -6106,14 +6108,13 @@ void CClientPed::RestoreAnimations(CAnimBlock& animationBlock)
61066108 for (size_t i = 0 ; i < cAnimations; i++)
61076109 {
61086110 auto pAnimHierarchyInterface = animationBlock.GetAnimationHierarchyInterface (i);
6111+ CIFPEngine::EngineApplyAnimation (*this , pAnimHierarchyInterface, pAnimHierarchyInterface);
61096112 m_mapOfReplacedAnimations.erase (pAnimHierarchyInterface);
6110- CIFPEngine::EngineApplyAnimation (*this , pAnimHierarchyInterface);
61116113 }
61126114}
61136115
61146116void CClientPed::RestoreAllAnimations ()
61156117{
6116- m_mapOfReplacedAnimations.clear ();
61176118 CAnimManager* pAnimationManager = g_pGame->GetAnimManager ();
61186119 RpClump* pClump = GetClump ();
61196120 if (pClump)
@@ -6129,12 +6130,14 @@ void CClientPed::RestoreAllAnimations()
61296130 auto pAnimStaticAssociation = pAnimationManager->GetAnimStaticAssociation (iGroupID, iAnimID);
61306131 if (pAnimStaticAssociation && pAnimHierarchy->IsCustom ())
61316132 {
6132- CIFPEngine::EngineApplyAnimation (*this , pAnimStaticAssociation->GetAnimHierachyInterface ());
6133+ auto pAnimHierarchyInterface = pAnimStaticAssociation->GetAnimHierachyInterface ();
6134+ CIFPEngine::EngineApplyAnimation (*this , pAnimHierarchyInterface, pAnimHierarchyInterface);
61336135 }
61346136 }
61356137 pAnimAssociation = std::move (pAnimNextAssociation);
61366138 }
61376139 }
6140+ m_mapOfReplacedAnimations.clear ();
61386141}
61396142
61406143SReplacedAnimation* CClientPed::GetReplacedAnimation (CAnimBlendHierarchySAInterface* pInternalHierarchyInterface)
@@ -6148,6 +6151,45 @@ SReplacedAnimation* CClientPed::GetReplacedAnimation(CAnimBlendHierarchySAInterf
61486151 return nullptr ;
61496152}
61506153
6154+ std::unique_ptr<CAnimBlendAssociation> CClientPed::GetAnimAssociation (CAnimBlendHierarchySAInterface* pOriginalHierarchyInterface)
6155+ {
6156+ RpClump* pClump = GetClump ();
6157+ if (!pClump)
6158+ {
6159+ return nullptr ;
6160+ }
6161+
6162+ auto pReplacedAnimation = GetReplacedAnimation (pOriginalHierarchyInterface);
6163+ CAnimBlendHierarchySAInterface* pReplacedInterface = nullptr ;
6164+ if (pReplacedAnimation != nullptr )
6165+ {
6166+ pReplacedInterface = pReplacedAnimation->pAnimationHierarchy ;
6167+ }
6168+
6169+ CAnimManager* pAnimationManager = g_pGame->GetAnimManager ();
6170+ auto pAnimAssociation = pAnimationManager->RpAnimBlendClumpGetFirstAssociation (pClump);
6171+ while (pAnimAssociation)
6172+ {
6173+ auto pAnimNextAssociation = pAnimationManager->RpAnimBlendGetNextAssociation (pAnimAssociation);
6174+ auto pAnimHierarchy = pAnimAssociation->GetAnimHierarchy ();
6175+ if (pAnimHierarchy)
6176+ {
6177+ CAnimBlendHierarchySAInterface* pInterface = pAnimHierarchy->GetInterface ();
6178+ if (pInterface == pOriginalHierarchyInterface)
6179+ {
6180+ return pAnimAssociation;
6181+ }
6182+ if (pReplacedInterface && pInterface == pReplacedInterface)
6183+ {
6184+ return pAnimAssociation;
6185+ }
6186+ }
6187+ pAnimAssociation = std::move (pAnimNextAssociation);
6188+ }
6189+ return nullptr ;
6190+
6191+ }
6192+
61516193CSphere CClientPed::GetWorldBoundingSphere ()
61526194{
61536195 CSphere sphere;
0 commit comments