Merge pull request #307 from lioncash/constexpr7

CModel: Mark CModelFlag instances as constexpr where applicable
This commit is contained in:
Luke Street 2020-04-12 03:06:12 -04:00 committed by GitHub
commit 9f8064b4a1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 20 additions and 20 deletions

View File

@ -162,7 +162,7 @@ void CBeetle::Render(CStateManager& mgr) {
x5ac_tailModel->Render(mgr, tailXf, x90_actorLights.get(), flags); x5ac_tailModel->Render(mgr, tailXf, x90_actorLights.get(), flags);
} }
} else if (x5ac_tailModel) { } else if (x5ac_tailModel) {
CModelFlags flags(0, 0, 3, zeus::skWhite); constexpr CModelFlags flags(0, 0, 3, zeus::skWhite);
x5ac_tailModel->Render(mgr, tailXf, x90_actorLights.get(), flags); x5ac_tailModel->Render(mgr, tailXf, x90_actorLights.get(), flags);
} }
} }

View File

@ -219,14 +219,14 @@ void CDecal::RenderMdl() {
CGraphics::SetModelMatrix(worldXf); CGraphics::SetModelMatrix(worldXf);
if (desc.x5c_24_DMAB) { if (desc.x5c_24_DMAB) {
CModelFlags flags(7, 0, 1, color); const CModelFlags flags(7, 0, 1, color);
desc.x38_DMDL.m_token->Draw(flags); desc.x38_DMDL.m_token->Draw(flags);
} else { } else {
if (color.a() == 1.f) { if (color.a() == 1.f) {
CModelFlags flags(0, 0, 3, zeus::skWhite); constexpr CModelFlags flags(0, 0, 3, zeus::skWhite);
desc.x38_DMDL.m_token->Draw(flags); desc.x38_DMDL.m_token->Draw(flags);
} else { } else {
CModelFlags flags(5, 0, 1, color); const CModelFlags flags(5, 0, 1, color);
desc.x38_DMDL.m_token->Draw(flags); desc.x38_DMDL.m_token->Draw(flags);
} }
} }

View File

@ -83,7 +83,7 @@ void CGunMotion::Update(float dt, CStateManager& mgr) {
} }
void CGunMotion::Draw(const CStateManager& mgr, const zeus::CTransform& xf) const { void CGunMotion::Draw(const CStateManager& mgr, const zeus::CTransform& xf) const {
CModelFlags flags(0, 0, 3, zeus::skWhite); constexpr CModelFlags flags(0, 0, 3, zeus::skWhite);
x0_modelData.Render(mgr, xf, nullptr, flags); x0_modelData.Render(mgr, xf, nullptr, flags);
} }

View File

@ -271,17 +271,17 @@ void CGunWeapon::Draw(bool drawSuitArm, const CStateManager& mgr, const zeus::CT
if (mgr.GetThermalDrawFlag() == EThermalDrawFlag::Hot && x200_beamId != CPlayerState::EBeamId::Ice) { if (mgr.GetThermalDrawFlag() == EThermalDrawFlag::Hot && x200_beamId != CPlayerState::EBeamId::Ice) {
/* Hot Draw */ /* Hot Draw */
zeus::CColor mulColor(flags.x4_color.a(), flags.x4_color.a()); const zeus::CColor mulColor(flags.x4_color.a(), flags.x4_color.a());
zeus::CColor addColor(0.25f, 0.25f); constexpr zeus::CColor addColor(0.25f, 0.25f);
if (x218_29_drawHologram) { if (x218_29_drawHologram) {
DrawHologram(mgr, xf, flags); DrawHologram(mgr, xf, flags);
} else { } else {
CModelFlags useFlags(0, 0, 3, zeus::skWhite); constexpr CModelFlags useFlags(0, 0, 3, zeus::skWhite);
x10_solidModelData->RenderThermal(xf, mulColor, addColor, useFlags); x10_solidModelData->RenderThermal(xf, mulColor, addColor, useFlags);
} }
if (drawSuitArm && xb0_suitArmModelData) { if (drawSuitArm && xb0_suitArmModelData) {
CModelFlags useFlags(0, 0, 3, zeus::skWhite); constexpr CModelFlags useFlags(0, 0, 3, zeus::skWhite);
xb0_suitArmModelData->RenderThermal(xf, mulColor, addColor, useFlags); xb0_suitArmModelData->RenderThermal(xf, mulColor, addColor, useFlags);
} }
} else { } else {

View File

@ -109,15 +109,15 @@ constexpr std::array chargeShakeTbl{
constexpr CMaterialFilter sAimFilter = constexpr CMaterialFilter sAimFilter =
CMaterialFilter::MakeIncludeExclude({EMaterialTypes::Solid}, {EMaterialTypes::ProjectilePassthrough}); CMaterialFilter::MakeIncludeExclude({EMaterialTypes::Solid}, {EMaterialTypes::ProjectilePassthrough});
const std::array<CModelFlags, 4> kThermalFlags{{ constexpr std::array<CModelFlags, 4> kThermalFlags{{
{0, 0, 3, zeus::skWhite}, {0, 0, 3, zeus::skWhite},
{5, 0, 3, zeus::CColor(0.f, 0.5f)}, {5, 0, 3, zeus::CColor(0.f, 0.5f)},
{0, 0, 3, zeus::skWhite}, {0, 0, 3, zeus::skWhite},
{0, 0, 3, zeus::skWhite}, {0, 0, 3, zeus::skWhite},
}}; }};
const CModelFlags kHandThermalFlag = {7, 0, 3, zeus::skWhite}; constexpr CModelFlags kHandThermalFlag{7, 0, 3, zeus::skWhite};
const CModelFlags kHandHoloFlag = {1, 0, 3, zeus::CColor(0.75f, 0.5f, 0.f, 1.f)}; constexpr CModelFlags kHandHoloFlag{1, 0, 3, zeus::CColor(0.75f, 0.5f, 0.f, 1.f)};
} // Anonymous namespace } // Anonymous namespace
float CPlayerGun::CMotionState::gGunExtendDistance = 0.125f; float CPlayerGun::CMotionState::gGunExtendDistance = 0.125f;

View File

@ -235,7 +235,7 @@ void CProjectileWeapon::Render() {
std::vector<CLight> useLights; std::vector<CLight> useLights;
useLights.push_back(CLight::BuildLocalAmbient({}, xc8_ambientLightColor)); useLights.push_back(CLight::BuildLocalAmbient({}, xc8_ambientLightColor));
(**x108_model).GetInstance().ActivateLights(useLights); (**x108_model).GetInstance().ActivateLights(useLights);
CModelFlags flags(0, 0, 3, zeus::skWhite); constexpr CModelFlags flags(0, 0, 3, zeus::skWhite);
(*x108_model)->Draw(flags); (*x108_model)->Draw(flags);
} }

View File

@ -520,7 +520,7 @@ void CFishCloud::RenderBoid(int idx, const CBoid& boid, u32& drawMask,
model.GetModelInst()->SetAmbientColor(zeus::skWhite); model.GetModelInst()->SetAmbientColor(zeus::skWhite);
CGraphics::SetModelMatrix(zeus::lookAt(boid.x0_pos, boid.x0_pos + boid.xc_vel)); CGraphics::SetModelMatrix(zeus::lookAt(boid.x0_pos, boid.x0_pos + boid.xc_vel));
if (thermalHot) { if (thermalHot) {
CModelFlags thermFlags(0, 0, 3, zeus::skWhite); constexpr CModelFlags thermFlags(0, 0, 3, zeus::skWhite);
mData.RenderThermal(zeus::skWhite, zeus::CColor(0.f, 0.25f), thermFlags); mData.RenderThermal(zeus::skWhite, zeus::CColor(0.f, 0.25f), thermFlags);
} else { } else {
mData.GetAnimationData()->Render(model, flags, std::nullopt, nullptr); mData.GetAnimationData()->Render(model, flags, std::nullopt, nullptr);

View File

@ -1674,8 +1674,8 @@ void CMorphBall::Render(const CStateManager& mgr, const CActorLights* lights) co
RenderMorphBallTransitionFlash(mgr); RenderMorphBallTransitionFlash(mgr);
if (x0_player.GetFrozenState()) { if (x0_player.GetFrozenState()) {
CModelFlags fflags(0, 0, 3, zeus::skWhite); constexpr CModelFlags modelFlags(0, 0, 3, zeus::skWhite);
x70_frozenBallModel->Render(mgr, zeus::CTransform::Translate(ballToWorld.origin), lights, fflags); x70_frozenBallModel->Render(mgr, zeus::CTransform::Translate(ballToWorld.origin), lights, modelFlags);
} }
RenderIceBreakEffect(mgr); RenderIceBreakEffect(mgr);

View File

@ -1572,7 +1572,7 @@ void CPlayer::RenderReflectedPlayer(CStateManager& mgr) {
} }
CPhysicsActor::Render(mgr); CPhysicsActor::Render(mgr);
if (HasTransitionBeamModel()) { if (HasTransitionBeamModel()) {
const CModelFlags flags(0, 0, 3, zeus::skWhite); constexpr CModelFlags flags(0, 0, 3, zeus::skWhite);
x7f0_ballTransitionBeamModel->Render(mgr, x7f4_gunWorldXf, nullptr, flags); x7f0_ballTransitionBeamModel->Render(mgr, x7f4_gunWorldXf, nullptr, flags);
} }
break; break;

View File

@ -416,7 +416,7 @@ void CSnakeWeedSwarm::RenderBoid(u32 idx, const CBoid& boid, u32& posesToBuild)
auto& modelData = *x1b0_modelData[modelIdx]; auto& modelData = *x1b0_modelData[modelIdx];
auto& model = modelData.PickAnimatedModel(x1c4_which); auto& model = modelData.PickAnimatedModel(x1c4_which);
auto& animData = *modelData.GetAnimationData(); auto& animData = *modelData.GetAnimationData();
const CModelFlags useFlags(0, 0, 3, zeus::skWhite); constexpr CModelFlags useFlags(0, 0, 3, zeus::skWhite);
if (posesToBuild & 1 << modelIdx) { if (posesToBuild & 1 << modelIdx) {
posesToBuild &= ~(1 << modelIdx); posesToBuild &= ~(1 << modelIdx);
animData.BuildPose(); animData.BuildPose();

View File

@ -1062,7 +1062,7 @@ void CWallCrawlerSwarm::RenderBoid(const CBoid* boid, u32& drawMask, bool therma
model.GetModelInst()->SetAmbientColor(boid->x40_ambientLighting); model.GetModelInst()->SetAmbientColor(boid->x40_ambientLighting);
CGraphics::SetModelMatrix(boid->GetTransform()); CGraphics::SetModelMatrix(boid->GetTransform());
if (boid->x48_timeToDie > 0.f && !thermalHot) { if (boid->x48_timeToDie > 0.f && !thermalHot) {
const CModelFlags useFlags(0, 0, 3, zeus::skWhite); constexpr CModelFlags useFlags(0, 0, 3, zeus::skWhite);
mData.GetAnimationData()->Render(model, useFlags, std::nullopt, nullptr); mData.GetAnimationData()->Render(model, useFlags, std::nullopt, nullptr);
if (auto iceModel = mData.GetAnimationData()->GetIceModel()) { if (auto iceModel = mData.GetAnimationData()->GetIceModel()) {
if (!iceModel->GetModelInst()->TryLockTextures()) { if (!iceModel->GetModelInst()->TryLockTextures()) {
@ -1075,7 +1075,7 @@ void CWallCrawlerSwarm::RenderBoid(const CBoid* boid, u32& drawMask, bool therma
mData.GetAnimationData()->Render(*iceModel, iceFlags, std::nullopt, nullptr); mData.GetAnimationData()->Render(*iceModel, iceFlags, std::nullopt, nullptr);
} }
} else if (thermalHot) { } else if (thermalHot) {
const CModelFlags thermFlags(5, 0, 3, zeus::skWhite); constexpr CModelFlags thermFlags(5, 0, 3, zeus::skWhite);
mData.RenderThermal(zeus::skWhite, zeus::CColor(0.f, 0.25f), thermFlags); mData.RenderThermal(zeus::skWhite, zeus::CColor(0.f, 0.25f), thermFlags);
} else { } else {
mData.GetAnimationData()->Render(model, flags, std::nullopt, nullptr); mData.GetAnimationData()->Render(model, flags, std::nullopt, nullptr);