From 8e90988b5ce5243c1d0f91c786df0015e9e7da7c Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Sun, 14 Aug 2022 22:50:25 -0700 Subject: [PATCH] Minor CActor/CModelData fixes, add matching CActor::UpdateAnimation --- include/MetroidPrime/CActor.hpp | 5 +++-- include/MetroidPrime/CModelData.hpp | 5 +++-- src/MetroidPrime/CActor.cpp | 13 ++++++------- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/include/MetroidPrime/CActor.hpp b/include/MetroidPrime/CActor.hpp index 156638cc..26ea0e8c 100644 --- a/include/MetroidPrime/CActor.hpp +++ b/include/MetroidPrime/CActor.hpp @@ -246,8 +246,9 @@ public: bool GetMuted() const { return xe5_26_muted; } bool HasAnimation() const { return x64_modelData && x64_modelData->GetAnimationData(); } bool HasModelData() const { return x64_modelData && (x64_modelData->GetAnimationData() || x64_modelData->HasNormalModel()); } - CModelData* GetModelData() const { return x64_modelData.get(); } - CAnimData* AnimationData() { return GetModelData()->GetAnimationData(); } + CModelData* ModelData() { return x64_modelData.get(); } + const CModelData* GetModelData() const { return x64_modelData.get(); } + CAnimData* AnimationData() { return ModelData()->AnimationData(); } const CAnimData* GetAnimationData() const { return GetModelData()->GetAnimationData(); } f32 GetAverageAnimVelocity(s32 anim); diff --git a/include/MetroidPrime/CModelData.hpp b/include/MetroidPrime/CModelData.hpp index 7bfe10be..6074cd9c 100644 --- a/include/MetroidPrime/CModelData.hpp +++ b/include/MetroidPrime/CModelData.hpp @@ -41,7 +41,8 @@ public: SAdvancementDeltas AdvanceAnimation(float dt, CStateManager& mgr, TAreaId aid, bool advTree); void AdvanceParticles(const CTransform4f& xf, float dt, CStateManager& mgr); - CAnimData* GetAnimationData() const { return xc_animData.get(); } + const CAnimData* GetAnimationData() const { return xc_animData.get(); } + CAnimData* AnimationData() { return xc_animData.get(); } CAABox GetBounds(const CTransform4f& xf) const; CAABox GetBounds() const; @@ -63,4 +64,4 @@ private: rstl::optional_object< TCachedToken< CModel > > x3c_infraModel; }; -#endif \ No newline at end of file +#endif diff --git a/src/MetroidPrime/CActor.cpp b/src/MetroidPrime/CActor.cpp index 961f74b1..a3245707 100644 --- a/src/MetroidPrime/CActor.cpp +++ b/src/MetroidPrime/CActor.cpp @@ -88,10 +88,9 @@ CActor::CActor(TUniqueId uid, bool active, const rstl::string& name, const CEnti CActor::~CActor() { RemoveEmitter(); } -// TODO nonmatching https://decomp.me/scratch/hQjHM SAdvancementDeltas CActor::UpdateAnimation(float dt, CStateManager& mgr, bool advTree) { - SAdvancementDeltas result = GetModelData()->AdvanceAnimation(dt, mgr, GetAreaId(), advTree); - GetModelData()->AdvanceParticles(GetTransform(), dt, mgr); + SAdvancementDeltas result = ModelData()->AdvanceAnimation(dt, mgr, GetAreaId(), advTree); + ModelData()->AdvanceParticles(GetTransform(), dt, mgr); UpdateSfxEmitters(); if (HasAnimation()) { u16 maxVol = xd4_maxVol; @@ -101,8 +100,11 @@ SAdvancementDeltas CActor::UpdateAnimation(float dt, CStateManager& mgr, bool ad const CVector3f origin = GetTranslation(); const CVector3f toCamera = camera->GetTranslation() - origin; + const CInt32POINode* intNode = nullptr; + const CSoundPOINode* soundNode = nullptr; + const CParticlePOINode* particleNode = nullptr; + s32 soundNodeCount = 0; - const CSoundPOINode* soundNode; if (HasAnimation()) { soundNode = GetAnimationData()->GetSoundPOIList(soundNodeCount); } else { @@ -115,14 +117,12 @@ SAdvancementDeltas CActor::UpdateAnimation(float dt, CStateManager& mgr, bool ad continue; if (charIdx != -1 && GetAnimationData()->GetCharacterIndex() != charIdx) continue; - // if (soundNode->GetPoiType() == kPT_Sound && !GetMuted() && (charIdx == -1 || GetAnimationData()->GetCharacterIndex() == charIdx)) ProcessSoundEvent(soundNode->GetSoundId(), soundNode->GetWeight(), soundNode->GetFlags(), soundNode->GetFallOff(), soundNode->GetMaxDistance(), 20, maxVol, toCamera, origin, aid, mgr, true); } } s32 intNodeCount = 0; - const CInt32POINode* intNode; if (HasAnimation()) { intNode = GetAnimationData()->GetInt32POIList(intNodeCount); } else { @@ -142,7 +142,6 @@ SAdvancementDeltas CActor::UpdateAnimation(float dt, CStateManager& mgr, bool ad } s32 particleNodeCount = 0; - const CParticlePOINode* particleNode; if (HasAnimation()) { particleNode = GetAnimationData()->GetParticlePOIList(particleNodeCount); } else {