CAnimPlaybackParms: Make class constexpr constructible

Allows for removal of some trivial runtime initializers.
This commit is contained in:
Lioncash 2020-04-11 20:49:56 -04:00
parent 1b42bda711
commit 1fff540102
6 changed files with 31 additions and 30 deletions

View File

@ -20,28 +20,29 @@ class CAnimPlaybackParms {
const zeus::CVector3f* x24_objectScale = nullptr; const zeus::CVector3f* x24_objectScale = nullptr;
public: public:
CAnimPlaybackParms() = default; constexpr CAnimPlaybackParms() = default;
CAnimPlaybackParms(s32 animA, s32 animB, float blendWeight, bool animating) constexpr CAnimPlaybackParms(s32 animA, s32 animB, float blendWeight, bool animating)
: x0_animA(animA), x4_animB(animB), x8_blendWeight(blendWeight), xc_animating(animating) {} : x0_animA(animA), x4_animB(animB), x8_blendWeight(blendWeight), xc_animating(animating) {}
CAnimPlaybackParms(s32 anim, const zeus::CQuaternion* deltaOrient, const zeus::CVector3f* targetPos, constexpr CAnimPlaybackParms(s32 anim, const zeus::CQuaternion* deltaOrient, const zeus::CVector3f* targetPos,
const zeus::CTransform* xf, const zeus::CVector3f* scale, bool useLocator) const zeus::CTransform* xf, const zeus::CVector3f* scale, bool useLocator)
: x0_animA(anim) : x0_animA(anim)
, x14_targetPos(targetPos) , x14_targetPos(targetPos)
, x18_useLocator(useLocator) , x18_useLocator(useLocator)
, x1c_deltaOrient(deltaOrient) , x1c_deltaOrient(deltaOrient)
, x20_objectXf(xf) , x20_objectXf(xf)
, x24_objectScale(scale) {} , x24_objectScale(scale) {}
const zeus::CTransform* GetObjectXform() const { return x20_objectXf; }
const zeus::CQuaternion* GetDeltaOrient() const { return x1c_deltaOrient; } constexpr const zeus::CTransform* GetObjectXform() const { return x20_objectXf; }
const zeus::CVector3f* GetTargetPos() const { return x14_targetPos; } constexpr const zeus::CQuaternion* GetDeltaOrient() const { return x1c_deltaOrient; }
bool GetIsUseLocator() const { return x18_useLocator; } constexpr const zeus::CVector3f* GetTargetPos() const { return x14_targetPos; }
const zeus::CVector3f* GetObjectScale() const { return x24_objectScale; } constexpr bool GetIsUseLocator() const { return x18_useLocator; }
s32 GetAnimationId() const { return x0_animA; } constexpr const zeus::CVector3f* GetObjectScale() const { return x24_objectScale; }
s32 GetSecondAnimationId() const { return x4_animB; } constexpr s32 GetAnimationId() const { return x0_animA; }
float GetBlendFactor() const { return x8_blendWeight; } constexpr s32 GetSecondAnimationId() const { return x4_animB; }
void SetAnimationId(s32 id) { x0_animA = id; } constexpr float GetBlendFactor() const { return x8_blendWeight; }
void SetSecondAnimationId(s32 id) { x4_animB = id; } constexpr void SetAnimationId(s32 id) { x0_animA = id; }
void SetBlendFactor(float f) { x8_blendWeight = f; } constexpr void SetSecondAnimationId(s32 id) { x4_animB = id; }
bool GetIsPlayAnimation() const { return xc_animating; } constexpr void SetBlendFactor(float f) { x8_blendWeight = f; }
constexpr bool GetIsPlayAnimation() const { return xc_animating; }
}; };
} // namespace urde } // namespace urde

View File

@ -156,7 +156,7 @@ bool CSamusDoll::IsLoaded() const {
CModelData CSamusDoll::BuildSuitModelData1(CPlayerState::EPlayerSuit suit) { CModelData CSamusDoll::BuildSuitModelData1(CPlayerState::EPlayerSuit suit) {
CModelData ret(CAnimRes(g_ResFactory->GetResourceIdByName("ANCS_ItemScreenSamus")->id, Character1Idxs[size_t(suit)], CModelData ret(CAnimRes(g_ResFactory->GetResourceIdByName("ANCS_ItemScreenSamus")->id, Character1Idxs[size_t(suit)],
zeus::skOne3f, 2, true)); zeus::skOne3f, 2, true));
CAnimPlaybackParms parms(2, -1, 1.f, true); constexpr CAnimPlaybackParms parms(2, -1, 1.f, true);
ret.GetAnimationData()->SetAnimation(parms, false); ret.GetAnimationData()->SetAnimation(parms, false);
return ret; return ret;
} }
@ -164,7 +164,7 @@ CModelData CSamusDoll::BuildSuitModelData1(CPlayerState::EPlayerSuit suit) {
CModelData CSamusDoll::BuildSuitModelDataBoots(CPlayerState::EPlayerSuit suit) { CModelData CSamusDoll::BuildSuitModelDataBoots(CPlayerState::EPlayerSuit suit) {
CModelData ret(CAnimRes(g_ResFactory->GetResourceIdByName("ANCS_ItemScreenSamus")->id, CModelData ret(CAnimRes(g_ResFactory->GetResourceIdByName("ANCS_ItemScreenSamus")->id,
CharacterBootsIdxs[size_t(suit)], zeus::skOne3f, 2, true)); 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); ret.GetAnimationData()->SetAnimation(parms, false);
return ret; return ret;
} }

View File

@ -16,7 +16,7 @@ CSamusFaceReflection::CSamusFaceReflection(CStateManager& stateMgr)
: x0_modelData(CAnimRes(g_ResFactory->GetResourceIdByName("ACS_SamusFace")->id, 0, zeus::skOne3f, 0, true)) : x0_modelData(CAnimRes(g_ResFactory->GetResourceIdByName("ACS_SamusFace")->id, 0, zeus::skOne3f, 0, true))
, x4c_lights(std::make_unique<CActorLights>(8, zeus::skZero3f, 4, 4, false, false, false, 0.1f)) { , x4c_lights(std::make_unique<CActorLights>(8, zeus::skZero3f, 4, 4, false, false, false, 0.1f)) {
x60_lookDir = zeus::skForward; 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); x0_modelData.GetAnimationData()->SetAnimation(parms, false);
} }

View File

@ -131,35 +131,35 @@ void CGrappleArm::SetAnimState(EArmState state) {
switch (state) { switch (state) {
case EArmState::IntoGrapple: { case EArmState::IntoGrapple: {
ResetAuxParams(true); ResetAuxParams(true);
CAnimPlaybackParms parms(0, -1, 1.f, true); constexpr CAnimPlaybackParms parms(0, -1, 1.f, true);
x0_grappleArmModel->GetAnimationData()->SetAnimation(parms, false); x0_grappleArmModel->GetAnimationData()->SetAnimation(parms, false);
x3b2_25_beamActive = false; x3b2_25_beamActive = false;
x3b2_24_active = true; x3b2_24_active = true;
break; break;
} }
case EArmState::IntoGrappleIdle: { 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()->EnableLooping(true);
x0_grappleArmModel->GetAnimationData()->SetAnimation(parms, false); x0_grappleArmModel->GetAnimationData()->SetAnimation(parms, false);
break; break;
} }
case EArmState::FireGrapple: { case EArmState::FireGrapple: {
CAnimPlaybackParms parms(2, -1, 1.f, true); constexpr CAnimPlaybackParms parms(2, -1, 1.f, true);
x0_grappleArmModel->GetAnimationData()->SetAnimation(parms, false); x0_grappleArmModel->GetAnimationData()->SetAnimation(parms, false);
break; break;
} }
case EArmState::ConnectGrapple: { case EArmState::ConnectGrapple: {
CAnimPlaybackParms parms(3, -1, 1.f, true); constexpr CAnimPlaybackParms parms(3, -1, 1.f, true);
x0_grappleArmModel->GetAnimationData()->SetAnimation(parms, false); x0_grappleArmModel->GetAnimationData()->SetAnimation(parms, false);
break; break;
} }
case EArmState::Connected: { case EArmState::Connected: {
CAnimPlaybackParms parms(3, -1, 1.f, true); constexpr CAnimPlaybackParms parms(3, -1, 1.f, true);
x0_grappleArmModel->GetAnimationData()->SetAnimation(parms, false); x0_grappleArmModel->GetAnimationData()->SetAnimation(parms, false);
break; break;
} }
case EArmState::OutOfGrapple: { case EArmState::OutOfGrapple: {
CAnimPlaybackParms parms(4, -1, 1.f, true); constexpr CAnimPlaybackParms parms(4, -1, 1.f, true);
x0_grappleArmModel->GetAnimationData()->SetAnimation(parms, false); x0_grappleArmModel->GetAnimationData()->SetAnimation(parms, false);
DisconnectGrappleBeam(); DisconnectGrappleBeam();
break; break;

View File

@ -1129,7 +1129,7 @@ void CMorphBall::EnterMorphBallState(CStateManager& mgr) {
x1c20_tireFactor = 0.f; x1c20_tireFactor = 0.f;
UpdateEffects(0.f, mgr); UpdateEffects(0.f, mgr);
x187c_spiderBallState = ESpiderBallState::Inactive; 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); x58_ballModel->GetAnimationData()->SetAnimation(parms, false);
x1e20_ballAnimIdx = 0; x1e20_ballAnimIdx = 0;
StopEffects(); StopEffects();
@ -1288,7 +1288,7 @@ void CMorphBall::ComputeBoostBallMovement(const CFinalInput& input, CStateManage
if (ControlMapper::GetDigitalInput(ControlMapper::ECommands::JumpOrBoost, input) && if (ControlMapper::GetDigitalInput(ControlMapper::ECommands::JumpOrBoost, input) &&
x187c_spiderBallState != ESpiderBallState::Active) { x187c_spiderBallState != ESpiderBallState::Active) {
if (x1e20_ballAnimIdx == 0) { 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); x58_ballModel->GetAnimationData()->SetAnimation(parms, false);
x1e20_ballAnimIdx = 1; x1e20_ballAnimIdx = 1;
x1e24_boostSfxHandle = CSfxManager::SfxStart(SFXsam_ball_charge_lp, 1.f, 0.f, true, 0x7f, true, kInvalidAreaId); 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(); x1de8_boostChargeTime = g_tweakBall->GetBoostBallMaxChargeTime();
} else { } else {
if (x1e20_ballAnimIdx == 1) { 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); x58_ballModel->GetAnimationData()->SetAnimation(parms, false);
x1e20_ballAnimIdx = 0; x1e20_ballAnimIdx = 0;
CSfxManager::RemoveEmitter(x1e24_boostSfxHandle); CSfxManager::RemoveEmitter(x1e24_boostSfxHandle);
@ -1399,7 +1399,7 @@ void CMorphBall::CancelBoosting() {
x1de8_boostChargeTime = 0.f; x1de8_boostChargeTime = 0.f;
x1df4_boostDrainTime = 0.f; x1df4_boostDrainTime = 0.f;
if (x1e20_ballAnimIdx == 1) { 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); x58_ballModel->GetAnimationData()->SetAnimation(parms, false);
x1e20_ballAnimIdx = 0; x1e20_ballAnimIdx = 0;
CSfxManager::SfxStop(x1e24_boostSfxHandle); CSfxManager::SfxStop(x1e24_boostSfxHandle);

View File

@ -5859,7 +5859,7 @@ void CPlayer::SetHudDisable(float staticTimer, float outSpeed, float inSpeed) {
} }
void CPlayer::SetIntoBallReadyAnimation(CStateManager& mgr) { 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()->SetAnimation(parms, false);
x64_modelData->GetAnimationData()->EnableLooping(false); x64_modelData->GetAnimationData()->EnableLooping(false);
x64_modelData->AdvanceAnimation(0.f, mgr, kInvalidAreaId, true); x64_modelData->AdvanceAnimation(0.f, mgr, kInvalidAreaId, true);