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