From 1fff5401024a3437cd5d56d4e240d80021044c42 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sat, 11 Apr 2020 20:49:56 -0400 Subject: [PATCH] CAnimPlaybackParms: Make class constexpr constructible Allows for removal of some trivial runtime initializers. --- Runtime/Character/CAnimPlaybackParms.hpp | 33 ++++++++++++------------ Runtime/MP1/CSamusDoll.cpp | 4 +-- Runtime/MP1/CSamusFaceReflection.cpp | 2 +- Runtime/Weapon/CGrappleArm.cpp | 12 ++++----- Runtime/World/CMorphBall.cpp | 8 +++--- Runtime/World/CPlayer.cpp | 2 +- 6 files changed, 31 insertions(+), 30 deletions(-) diff --git a/Runtime/Character/CAnimPlaybackParms.hpp b/Runtime/Character/CAnimPlaybackParms.hpp index 988e55242..0515185d1 100644 --- a/Runtime/Character/CAnimPlaybackParms.hpp +++ b/Runtime/Character/CAnimPlaybackParms.hpp @@ -20,28 +20,29 @@ class CAnimPlaybackParms { const zeus::CVector3f* x24_objectScale = nullptr; public: - CAnimPlaybackParms() = default; - CAnimPlaybackParms(s32 animA, s32 animB, float blendWeight, bool animating) + constexpr CAnimPlaybackParms() = default; + constexpr CAnimPlaybackParms(s32 animA, s32 animB, float blendWeight, bool animating) : x0_animA(animA), x4_animB(animB), x8_blendWeight(blendWeight), xc_animating(animating) {} - CAnimPlaybackParms(s32 anim, const zeus::CQuaternion* deltaOrient, const zeus::CVector3f* targetPos, - const zeus::CTransform* xf, const zeus::CVector3f* scale, bool useLocator) + constexpr CAnimPlaybackParms(s32 anim, const zeus::CQuaternion* deltaOrient, const zeus::CVector3f* targetPos, + const zeus::CTransform* xf, const zeus::CVector3f* scale, bool useLocator) : x0_animA(anim) , x14_targetPos(targetPos) , x18_useLocator(useLocator) , x1c_deltaOrient(deltaOrient) , x20_objectXf(xf) , x24_objectScale(scale) {} - const zeus::CTransform* GetObjectXform() const { return x20_objectXf; } - const zeus::CQuaternion* GetDeltaOrient() const { return x1c_deltaOrient; } - const zeus::CVector3f* GetTargetPos() const { return x14_targetPos; } - bool GetIsUseLocator() const { return x18_useLocator; } - const zeus::CVector3f* GetObjectScale() const { return x24_objectScale; } - s32 GetAnimationId() const { return x0_animA; } - s32 GetSecondAnimationId() const { return x4_animB; } - float GetBlendFactor() const { return x8_blendWeight; } - void SetAnimationId(s32 id) { x0_animA = id; } - void SetSecondAnimationId(s32 id) { x4_animB = id; } - void SetBlendFactor(float f) { x8_blendWeight = f; } - bool GetIsPlayAnimation() const { return xc_animating; } + + constexpr const zeus::CTransform* GetObjectXform() const { return x20_objectXf; } + constexpr const zeus::CQuaternion* GetDeltaOrient() const { return x1c_deltaOrient; } + constexpr const zeus::CVector3f* GetTargetPos() const { return x14_targetPos; } + constexpr bool GetIsUseLocator() const { return x18_useLocator; } + constexpr const zeus::CVector3f* GetObjectScale() const { return x24_objectScale; } + constexpr s32 GetAnimationId() const { return x0_animA; } + constexpr s32 GetSecondAnimationId() const { return x4_animB; } + constexpr float GetBlendFactor() const { return x8_blendWeight; } + constexpr void SetAnimationId(s32 id) { x0_animA = id; } + constexpr void SetSecondAnimationId(s32 id) { x4_animB = id; } + constexpr void SetBlendFactor(float f) { x8_blendWeight = f; } + constexpr bool GetIsPlayAnimation() const { return xc_animating; } }; } // namespace urde diff --git a/Runtime/MP1/CSamusDoll.cpp b/Runtime/MP1/CSamusDoll.cpp index 74fbbd177..01c6673d8 100644 --- a/Runtime/MP1/CSamusDoll.cpp +++ b/Runtime/MP1/CSamusDoll.cpp @@ -156,7 +156,7 @@ bool CSamusDoll::IsLoaded() const { CModelData CSamusDoll::BuildSuitModelData1(CPlayerState::EPlayerSuit suit) { CModelData ret(CAnimRes(g_ResFactory->GetResourceIdByName("ANCS_ItemScreenSamus")->id, Character1Idxs[size_t(suit)], zeus::skOne3f, 2, true)); - CAnimPlaybackParms parms(2, -1, 1.f, true); + constexpr CAnimPlaybackParms parms(2, -1, 1.f, true); ret.GetAnimationData()->SetAnimation(parms, false); return ret; } @@ -164,7 +164,7 @@ CModelData CSamusDoll::BuildSuitModelData1(CPlayerState::EPlayerSuit suit) { CModelData CSamusDoll::BuildSuitModelDataBoots(CPlayerState::EPlayerSuit suit) { CModelData ret(CAnimRes(g_ResFactory->GetResourceIdByName("ANCS_ItemScreenSamus")->id, CharacterBootsIdxs[size_t(suit)], zeus::skOne3f, 2, true)); - CAnimPlaybackParms parms(2, -1, 1.f, true); + constexpr CAnimPlaybackParms parms(2, -1, 1.f, true); ret.GetAnimationData()->SetAnimation(parms, false); return ret; } diff --git a/Runtime/MP1/CSamusFaceReflection.cpp b/Runtime/MP1/CSamusFaceReflection.cpp index 84ca37816..8a8e2c5af 100644 --- a/Runtime/MP1/CSamusFaceReflection.cpp +++ b/Runtime/MP1/CSamusFaceReflection.cpp @@ -16,7 +16,7 @@ CSamusFaceReflection::CSamusFaceReflection(CStateManager& stateMgr) : x0_modelData(CAnimRes(g_ResFactory->GetResourceIdByName("ACS_SamusFace")->id, 0, zeus::skOne3f, 0, true)) , x4c_lights(std::make_unique(8, zeus::skZero3f, 4, 4, false, false, false, 0.1f)) { x60_lookDir = zeus::skForward; - CAnimPlaybackParms parms(0, -1, 1.f, true); + constexpr CAnimPlaybackParms parms(0, -1, 1.f, true); x0_modelData.GetAnimationData()->SetAnimation(parms, false); } diff --git a/Runtime/Weapon/CGrappleArm.cpp b/Runtime/Weapon/CGrappleArm.cpp index 2f1d90efa..e6aca556e 100644 --- a/Runtime/Weapon/CGrappleArm.cpp +++ b/Runtime/Weapon/CGrappleArm.cpp @@ -131,35 +131,35 @@ void CGrappleArm::SetAnimState(EArmState state) { switch (state) { case EArmState::IntoGrapple: { ResetAuxParams(true); - CAnimPlaybackParms parms(0, -1, 1.f, true); + constexpr CAnimPlaybackParms parms(0, -1, 1.f, true); x0_grappleArmModel->GetAnimationData()->SetAnimation(parms, false); x3b2_25_beamActive = false; x3b2_24_active = true; break; } case EArmState::IntoGrappleIdle: { - CAnimPlaybackParms parms(1, -1, 1.f, true); + constexpr CAnimPlaybackParms parms(1, -1, 1.f, true); x0_grappleArmModel->GetAnimationData()->EnableLooping(true); x0_grappleArmModel->GetAnimationData()->SetAnimation(parms, false); break; } case EArmState::FireGrapple: { - CAnimPlaybackParms parms(2, -1, 1.f, true); + constexpr CAnimPlaybackParms parms(2, -1, 1.f, true); x0_grappleArmModel->GetAnimationData()->SetAnimation(parms, false); break; } case EArmState::ConnectGrapple: { - CAnimPlaybackParms parms(3, -1, 1.f, true); + constexpr CAnimPlaybackParms parms(3, -1, 1.f, true); x0_grappleArmModel->GetAnimationData()->SetAnimation(parms, false); break; } case EArmState::Connected: { - CAnimPlaybackParms parms(3, -1, 1.f, true); + constexpr CAnimPlaybackParms parms(3, -1, 1.f, true); x0_grappleArmModel->GetAnimationData()->SetAnimation(parms, false); break; } case EArmState::OutOfGrapple: { - CAnimPlaybackParms parms(4, -1, 1.f, true); + constexpr CAnimPlaybackParms parms(4, -1, 1.f, true); x0_grappleArmModel->GetAnimationData()->SetAnimation(parms, false); DisconnectGrappleBeam(); break; diff --git a/Runtime/World/CMorphBall.cpp b/Runtime/World/CMorphBall.cpp index d00d29429..6dce23b1d 100644 --- a/Runtime/World/CMorphBall.cpp +++ b/Runtime/World/CMorphBall.cpp @@ -1129,7 +1129,7 @@ void CMorphBall::EnterMorphBallState(CStateManager& mgr) { x1c20_tireFactor = 0.f; UpdateEffects(0.f, mgr); x187c_spiderBallState = ESpiderBallState::Inactive; - CAnimPlaybackParms parms(0, -1, 1.f, true); + constexpr CAnimPlaybackParms parms(0, -1, 1.f, true); x58_ballModel->GetAnimationData()->SetAnimation(parms, false); x1e20_ballAnimIdx = 0; StopEffects(); @@ -1288,7 +1288,7 @@ void CMorphBall::ComputeBoostBallMovement(const CFinalInput& input, CStateManage if (ControlMapper::GetDigitalInput(ControlMapper::ECommands::JumpOrBoost, input) && x187c_spiderBallState != ESpiderBallState::Active) { if (x1e20_ballAnimIdx == 0) { - CAnimPlaybackParms parms(1, -1, 1.f, true); + constexpr CAnimPlaybackParms parms(1, -1, 1.f, true); x58_ballModel->GetAnimationData()->SetAnimation(parms, false); x1e20_ballAnimIdx = 1; x1e24_boostSfxHandle = CSfxManager::SfxStart(SFXsam_ball_charge_lp, 1.f, 0.f, true, 0x7f, true, kInvalidAreaId); @@ -1298,7 +1298,7 @@ void CMorphBall::ComputeBoostBallMovement(const CFinalInput& input, CStateManage x1de8_boostChargeTime = g_tweakBall->GetBoostBallMaxChargeTime(); } else { if (x1e20_ballAnimIdx == 1) { - CAnimPlaybackParms parms(0, -1, 1.f, true); + constexpr CAnimPlaybackParms parms(0, -1, 1.f, true); x58_ballModel->GetAnimationData()->SetAnimation(parms, false); x1e20_ballAnimIdx = 0; CSfxManager::RemoveEmitter(x1e24_boostSfxHandle); @@ -1399,7 +1399,7 @@ void CMorphBall::CancelBoosting() { x1de8_boostChargeTime = 0.f; x1df4_boostDrainTime = 0.f; if (x1e20_ballAnimIdx == 1) { - CAnimPlaybackParms parms(0, -1, 1.f, true); + constexpr CAnimPlaybackParms parms(0, -1, 1.f, true); x58_ballModel->GetAnimationData()->SetAnimation(parms, false); x1e20_ballAnimIdx = 0; CSfxManager::SfxStop(x1e24_boostSfxHandle); diff --git a/Runtime/World/CPlayer.cpp b/Runtime/World/CPlayer.cpp index ea281b5e8..d01aac161 100644 --- a/Runtime/World/CPlayer.cpp +++ b/Runtime/World/CPlayer.cpp @@ -5859,7 +5859,7 @@ void CPlayer::SetHudDisable(float staticTimer, float outSpeed, float inSpeed) { } void CPlayer::SetIntoBallReadyAnimation(CStateManager& mgr) { - const CAnimPlaybackParms parms(2, -1, 1.f, true); + constexpr CAnimPlaybackParms parms(2, -1, 1.f, true); x64_modelData->GetAnimationData()->SetAnimation(parms, false); x64_modelData->GetAnimationData()->EnableLooping(false); x64_modelData->AdvanceAnimation(0.f, mgr, kInvalidAreaId, true);