diff --git a/Runtime/MP1/CSamusDoll.cpp b/Runtime/MP1/CSamusDoll.cpp index c5f715b43..a4ca9f2cb 100644 --- a/Runtime/MP1/CSamusDoll.cpp +++ b/Runtime/MP1/CSamusDoll.cpp @@ -8,6 +8,7 @@ #include "Runtime/World/CMorphBall.hpp" #include +#include #include #include #include @@ -16,46 +17,81 @@ #include namespace urde::MP1 { +namespace { +constexpr std::array, 8> SpiderBallGlassModels{{ + {"SamusSpiderBallGlassCMDL", 0}, + {"SamusSpiderBallGlassCMDL", 0}, + {"SamusSpiderBallGlassCMDL", 1}, + {"SamusPhazonBallGlassCMDL", 0}, + {"SamusSpiderBallGlassCMDL", 0}, + {"SamusSpiderBallGlassCMDL", 0}, + {"SamusSpiderBallGlassCMDL", 1}, + {"SamusPhazonBallGlassCMDL", 0}, +}}; -const zeus::CVector3f CSamusDoll::skInitialOffset = {0.f, 0.f, 0.8f}; +constexpr std::array, 8> SpiderBallCharacters{{ + {"SamusSpiderBallANCS", 0}, + {"SamusSpiderBallANCS", 0}, + {"SamusSpiderBallANCS", 1}, + {"SamusPhazonBallANCS", 0}, + {"SamusFusionBallANCS", 0}, + {"SamusFusionBallANCS", 2}, + {"SamusFusionBallANCS", 1}, + {"SamusFusionBallANCS", 3}, +}}; -static const std::pair SpiderBallGlassModels[] = { - {"SamusSpiderBallGlassCMDL", 0}, {"SamusSpiderBallGlassCMDL", 0}, {"SamusSpiderBallGlassCMDL", 1}, - {"SamusPhazonBallGlassCMDL", 0}, {"SamusSpiderBallGlassCMDL", 0}, {"SamusSpiderBallGlassCMDL", 0}, - {"SamusSpiderBallGlassCMDL", 1}, {"SamusPhazonBallGlassCMDL", 0}, +constexpr std::array, 8> BallCharacters{{ + {"SamusBallANCS", 0}, + {"SamusBallANCS", 0}, + {"SamusBallANCS", 1}, + {"SamusBallANCS", 0}, + {"SamusFusionBallANCS", 0}, + {"SamusFusionBallANCS", 2}, + {"SamusFusionBallANCS", 1}, + {"SamusFusionBallANCS", 3}, +}}; + +constexpr std::array SpiderBallGlowColorIdxs{ + 3, 3, 2, 4, 5, 7, 6, 8, }; -static const std::pair SpiderBallCharacters[] = { - {"SamusSpiderBallANCS", 0}, {"SamusSpiderBallANCS", 0}, {"SamusSpiderBallANCS", 1}, {"SamusPhazonBallANCS", 0}, - {"SamusFusionBallANCS", 0}, {"SamusFusionBallANCS", 2}, {"SamusFusionBallANCS", 1}, {"SamusFusionBallANCS", 3}, +constexpr std::array BallGlowColorIdxs{ + 0, 0, 1, 0, 5, 7, 6, 8, }; -static const std::pair BallCharacters[] = { - {"SamusBallANCS", 0}, {"SamusBallANCS", 0}, {"SamusBallANCS", 1}, {"SamusBallANCS", 0}, - {"SamusFusionBallANCS", 0}, {"SamusFusionBallANCS", 2}, {"SamusFusionBallANCS", 1}, {"SamusFusionBallANCS", 3}, +constexpr std::array BeamModels{ + "CMDL_InvPowerBeam", "CMDL_InvIceBeam", "CMDL_InvWaveBeam", "CMDL_InvPlasmaBeam", "CMDL_InvPowerBeam", }; -static const u32 SpiderBallGlowColorIdxs[] = {3, 3, 2, 4, 5, 7, 6, 8}; +constexpr std::array VisorModels{ + "CMDL_InvVisor", "CMDL_InvGravityVisor", "CMDL_InvVisor", "CMDL_InvPhazonVisor", + "CMDL_InvFusionVisor", "CMDL_InvFusionVisor", "CMDL_InvFusionVisor", "CMDL_InvFusionVisor", +}; -static const u32 BallGlowColorIdxs[] = {0, 0, 1, 0, 5, 7, 6, 8}; +constexpr std::array FinModels{ + "CMDL_InvPowerFins", "CMDL_InvPowerFins", "CMDL_InvPowerFins", "CMDL_InvPowerFins", + "CMDL_InvPowerFins", "CMDL_InvVariaFins", "CMDL_InvGravityFins", "CMDL_InvPhazonFins", +}; -static const char* BeamModels[] = {"CMDL_InvPowerBeam", "CMDL_InvIceBeam", "CMDL_InvWaveBeam", "CMDL_InvPlasmaBeam", - "CMDL_InvPowerBeam"}; +constexpr std::array Character1Idxs{ + 0, 6, 2, 10, 16, 24, 20, 28, +}; -static const char* VisorModels[] = {"CMDL_InvVisor", "CMDL_InvGravityVisor", "CMDL_InvVisor", - "CMDL_InvPhazonVisor", "CMDL_InvFusionVisor", "CMDL_InvFusionVisor", - "CMDL_InvFusionVisor", "CMDL_InvFusionVisor"}; +constexpr std::array CharacterBootsIdxs{ + 1, 7, 3, 11, 17, 25, 21, 29, +}; -static const char* FinModels[] = {"CMDL_InvPowerFins", "CMDL_InvPowerFins", "CMDL_InvPowerFins", - "CMDL_InvPowerFins", "CMDL_InvPowerFins", "CMDL_InvVariaFins", - "CMDL_InvGravityFins", "CMDL_InvPhazonFins"}; - -static const u32 Character1Idxs[8] = {0, 6, 2, 10, 16, 24, 20, 28}; - -static const u32 CharacterBootsIdxs[8] = {1, 7, 3, 11, 17, 25, 21, 29}; - -static const u32 Character2and3Idxs[8][2] = {{14, 15}, {8, 9}, {4, 5}, {12, 13}, - {18, 19}, {26, 27}, {22, 23}, {30, 31}}; +constexpr std::array, 8> Character2and3Idxs{{ + {14, 15}, + {8, 9}, + {4, 5}, + {12, 13}, + {18, 19}, + {26, 27}, + {22, 23}, + {30, 31}, +}}; +} // Anonymous namespace CSamusDoll::CSamusDoll(const CDependencyGroup& suitDgrp, const CDependencyGroup& ballDgrp, CPlayerState::EPlayerSuit suit, CPlayerState::EBeamId beam, bool hasSpiderBall, @@ -65,15 +101,15 @@ CSamusDoll::CSamusDoll(const CDependencyGroup& suitDgrp, const CDependencyGroup& , x48_beam(beam) { x70_fixedRot.rotateZ(M_PIF); x90_userInterpRot = xb0_userRot = x70_fixedRot; - x1d4_spiderBallGlass = g_SimplePool->GetObj(SpiderBallGlassModels[int(suit)].first); - x1e0_ballMatIdx = hasSpiderBall ? SpiderBallCharacters[int(suit)].second : BallCharacters[int(suit)].second; - x1e4_glassMatIdx = SpiderBallGlassModels[int(suit)].second; - x1e8_ballGlowColorIdx = hasSpiderBall ? SpiderBallGlowColorIdxs[int(suit)] : BallGlowColorIdxs[int(suit)]; + x1d4_spiderBallGlass = g_SimplePool->GetObj(SpiderBallGlassModels[size_t(suit)].first); + x1e0_ballMatIdx = hasSpiderBall ? SpiderBallCharacters[size_t(suit)].second : BallCharacters[size_t(suit)].second; + x1e4_glassMatIdx = SpiderBallGlassModels[size_t(suit)].second; + x1e8_ballGlowColorIdx = hasSpiderBall ? SpiderBallGlowColorIdxs[size_t(suit)] : BallGlowColorIdxs[size_t(suit)]; x1ec_itemScreenSamus = g_SimplePool->GetObj("ANCS_ItemScreenSamus"); - x1f4_invBeam = g_SimplePool->GetObj(BeamModels[int(beam)]); - x200_invVisor = g_SimplePool->GetObj(VisorModels[int(suit)]); + x1f4_invBeam = g_SimplePool->GetObj(BeamModels[size_t(beam)]); + x200_invVisor = g_SimplePool->GetObj(VisorModels[size_t(suit)]); x20c_invGrappleBeam = g_SimplePool->GetObj("CMDL_InvGrappleBeam"); - x218_invFins = g_SimplePool->GetObj(FinModels[int(suit)]); + x218_invFins = g_SimplePool->GetObj(FinModels[size_t(suit)]); x224_ballInnerGlow = g_SimplePool->GetObj("BallInnerGlow"); x22c_ballInnerGlowGen = std::make_unique(x224_ballInnerGlow); x230_ballTransitionFlash = g_SimplePool->GetObj("MorphBallTransitionFlash"); @@ -112,7 +148,7 @@ bool CSamusDoll::IsLoaded() const { } CModelData CSamusDoll::BuildSuitModelData1(CPlayerState::EPlayerSuit suit) { - CModelData ret(CAnimRes(g_ResFactory->GetResourceIdByName("ANCS_ItemScreenSamus")->id, Character1Idxs[int(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); ret.GetAnimationData()->SetAnimation(parms, false); @@ -120,8 +156,8 @@ CModelData CSamusDoll::BuildSuitModelData1(CPlayerState::EPlayerSuit suit) { } CModelData CSamusDoll::BuildSuitModelDataBoots(CPlayerState::EPlayerSuit suit) { - CModelData ret(CAnimRes(g_ResFactory->GetResourceIdByName("ANCS_ItemScreenSamus")->id, CharacterBootsIdxs[int(suit)], - zeus::skOne3f, 2, true)); + CModelData ret(CAnimRes(g_ResFactory->GetResourceIdByName("ANCS_ItemScreenSamus")->id, + CharacterBootsIdxs[size_t(suit)], zeus::skOne3f, 2, true)); CAnimPlaybackParms parms(2, -1, 1.f, true); ret.GetAnimationData()->SetAnimation(parms, false); return ret; @@ -137,7 +173,7 @@ bool CSamusDoll::CheckLoadComplete() { xc8_suitModel0.emplace(BuildSuitModelData1(x44_suit)); for (int i = 0; i < 2; ++i) { - CAnimRes res(g_ResFactory->GetResourceIdByName("ANCS_ItemScreenSamus")->id, Character2and3Idxs[int(x44_suit)][i], + CAnimRes res(g_ResFactory->GetResourceIdByName("ANCS_ItemScreenSamus")->id, Character2and3Idxs[size_t(x44_suit)][i], zeus::skOne3f, 2, true); CModelData mData(res); x118_suitModel1and2.push_back(mData.GetAnimationData()->GetModelData()); @@ -146,13 +182,13 @@ bool CSamusDoll::CheckLoadComplete() { x134_suitModelBoots.emplace(BuildSuitModelDataBoots(x44_suit)); CAnimRes res(g_ResFactory - ->GetResourceIdByName(x270_24_hasSpiderBall ? SpiderBallCharacters[int(x44_suit)].first - : BallCharacters[int(x44_suit)].first) + ->GetResourceIdByName(x270_24_hasSpiderBall ? SpiderBallCharacters[size_t(x44_suit)].first + : BallCharacters[size_t(x44_suit)].first) ->id, 0, zeus::skOne3f, 0, true); x184_ballModelData.emplace(res); x1e0_ballMatIdx = - x270_24_hasSpiderBall ? SpiderBallCharacters[int(x44_suit)].second : BallCharacters[int(x44_suit)].second; + x270_24_hasSpiderBall ? SpiderBallCharacters[size_t(x44_suit)].second : BallCharacters[size_t(x44_suit)].second; x270_31_loaded = true; return true; } @@ -512,23 +548,23 @@ void CSamusDoll::Draw(const CStateManager& mgr, float alpha) { if (x270_24_hasSpiderBall) { CGraphics::SetModelMatrix(x10_ballXf); - CModelFlags flags = {}; - flags.x1_matSetIdx = x1e4_glassMatIdx; + CModelFlags spiderBallGlassFlags = {}; + spiderBallGlassFlags.x1_matSetIdx = x1e4_glassMatIdx; x1d4_spiderBallGlass->GetInstance().ActivateLights(x23c_lights); - flags.m_extendedShader = EExtendedShader::SolidColorBackfaceCullLEqualAlphaOnly; - flags.x4_color = zeus::skWhite; - x1d4_spiderBallGlass->Draw(flags); + spiderBallGlassFlags.m_extendedShader = EExtendedShader::SolidColorBackfaceCullLEqualAlphaOnly; + spiderBallGlassFlags.x4_color = zeus::skWhite; + x1d4_spiderBallGlass->Draw(spiderBallGlassFlags); - flags.m_extendedShader = EExtendedShader::ForcedAlpha; - flags.x4_color = zeus::skWhite; - flags.x4_color.a() = alpha; - x1d4_spiderBallGlass->Draw(flags); + spiderBallGlassFlags.m_extendedShader = EExtendedShader::ForcedAlpha; + spiderBallGlassFlags.x4_color = zeus::skWhite; + spiderBallGlassFlags.x4_color.a() = alpha; + x1d4_spiderBallGlass->Draw(spiderBallGlassFlags); - flags.m_extendedShader = EExtendedShader::ForcedAdditive; - flags.x4_color = zeus::skWhite; - flags.x4_color.a() = x6c_ballPulseFactor * alpha * itemPulse; - x1d4_spiderBallGlass->Draw(flags); + spiderBallGlassFlags.m_extendedShader = EExtendedShader::ForcedAdditive; + spiderBallGlassFlags.x4_color = zeus::skWhite; + spiderBallGlassFlags.x4_color.a() = x6c_ballPulseFactor * alpha * itemPulse; + x1d4_spiderBallGlass->Draw(spiderBallGlassFlags); } } diff --git a/Runtime/MP1/CSamusDoll.hpp b/Runtime/MP1/CSamusDoll.hpp index ad85d8481..ac0ddd645 100644 --- a/Runtime/MP1/CSamusDoll.hpp +++ b/Runtime/MP1/CSamusDoll.hpp @@ -85,7 +85,7 @@ class CSamusDoll { u32 _dummy = 0; }; - static const zeus::CVector3f skInitialOffset; + static constexpr zeus::CVector3f skInitialOffset{0.0f, 0.0f, 0.8f}; static CModelData BuildSuitModelData1(CPlayerState::EPlayerSuit suit); static CModelData BuildSuitModelDataBoots(CPlayerState::EPlayerSuit suit); void SetupLights();