2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-12-14 10:06:10 +00:00

CGuiFrame & Model fixes; CModel::Draw impl; Document CModelFlags bits

This commit is contained in:
2022-03-05 19:26:52 -05:00
parent b3daf4a527
commit 6c3e74b93e
25 changed files with 135 additions and 192 deletions

View File

@@ -502,7 +502,7 @@ void CCompoundTargetReticle::Draw(const CStateManager& mgr, bool hideLockon) {
}
void CCompoundTargetReticle::DrawGrapplePoint(const CScriptGrapplePoint& point, float t, const CStateManager& mgr,
const zeus::CMatrix3f& rot, bool zEqual) const {
const zeus::CMatrix3f& rot, bool zEqual) {
zeus::CVector3f orbitPos = point.GetOrbitPosition(mgr);
zeus::CColor color;
@@ -524,7 +524,7 @@ void CCompoundTargetReticle::DrawGrapplePoint(const CScriptGrapplePoint& point,
}
void CCompoundTargetReticle::DrawGrappleGroup(const zeus::CMatrix3f& rot, const CStateManager& mgr,
bool hideLockon) const {
bool hideLockon) {
if (x28_noDrawTicks > 0) {
return;
}
@@ -569,7 +569,7 @@ void CCompoundTargetReticle::DrawGrappleGroup(const zeus::CMatrix3f& rot, const
}
}
void CCompoundTargetReticle::DrawCurrLockOnGroup(const zeus::CMatrix3f& rot, const CStateManager& mgr) const {
void CCompoundTargetReticle::DrawCurrLockOnGroup(const zeus::CMatrix3f& rot, const CStateManager& mgr) {
if (x28_noDrawTicks > 0) {
return;
}
@@ -677,7 +677,7 @@ void CCompoundTargetReticle::DrawCurrLockOnGroup(const zeus::CMatrix3f& rot, con
1.f / x10c_currGroupInterp.GetFactor() * g_tweakTargeting->GetOuterBeamSquaresScale());
zeus::CMatrix3f outerBeamXf = rot * scale;
for (int i = 0; i < 9; ++i) {
const SOuterItemInfo& info = xe0_outerBeamIconSquares[i];
SOuterItemInfo& info = xe0_outerBeamIconSquares[i];
if (info.x0_model.IsLoaded()) {
zeus::CTransform modelXf(lockBreakXf * outerBeamXf * zeus::CMatrix3f::RotateY(info.x10_rotAng),
x10c_currGroupInterp.GetTargetPositionWorld());
@@ -925,7 +925,7 @@ void CCompoundTargetReticle::DrawNextLockOnGroup(const zeus::CMatrix3f& rot, con
}
}
void CCompoundTargetReticle::DrawOrbitZoneGroup(const zeus::CMatrix3f& rot, const CStateManager& mgr) const {
void CCompoundTargetReticle::DrawOrbitZoneGroup(const zeus::CMatrix3f& rot, const CStateManager& mgr) {
if (x28_noDrawTicks > 0) {
return;
}

View File

@@ -133,7 +133,7 @@ private:
SScanReticuleRenderer m_scanRetRenderer;
void DrawGrapplePoint(const CScriptGrapplePoint& point, float t, const CStateManager& mgr, const zeus::CMatrix3f& rot,
bool zEqual) const;
bool zEqual);
public:
explicit CCompoundTargetReticle(const CStateManager&);
@@ -146,10 +146,10 @@ public:
void UpdateNextLockOnGroup(float, const CStateManager&);
void UpdateOrbitZoneGroup(float, const CStateManager&);
void Draw(const CStateManager&, bool hideLockon);
void DrawGrappleGroup(const zeus::CMatrix3f& rot, const CStateManager&, bool) const;
void DrawCurrLockOnGroup(const zeus::CMatrix3f& rot, const CStateManager&) const;
void DrawGrappleGroup(const zeus::CMatrix3f& rot, const CStateManager&, bool);
void DrawCurrLockOnGroup(const zeus::CMatrix3f& rot, const CStateManager&);
void DrawNextLockOnGroup(const zeus::CMatrix3f& rot, const CStateManager&);
void DrawOrbitZoneGroup(const zeus::CMatrix3f& rot, const CStateManager&) const;
void DrawOrbitZoneGroup(const zeus::CMatrix3f& rot, const CStateManager&);
void UpdateTargetParameters(CTargetReticleRenderState&, const CStateManager&);
float CalculateRadiusWorld(const CActor&, const CStateManager&) const;
zeus::CVector3f CalculatePositionWorld(const CActor&, const CStateManager&) const;

View File

@@ -45,42 +45,36 @@ void CGuiFrame::SortDrawOrder() {
}
void CGuiFrame::EnableLights(u32 lights) const {
std::vector<CLight> lightsOut;
lightsOut.reserve(m_indexedLights.size() + 1);
CGraphics::DisableAllLights();
zeus::CColor ambColor(zeus::skBlack);
ERglLight lightId = ERglLight::Zero;
int idx = 0;
int enabledLights = 0;
for (CGuiLight* light : m_indexedLights) {
if (!light || !light->GetIsVisible()) {
if (light == nullptr || !light->GetIsVisible()) {
++reinterpret_cast<std::underlying_type_t<ERglLight>&>(lightId);
++idx;
continue;
}
if ((lights & (1 << idx)) != 0) {
// const zeus::CColor& geomCol = light->GetGeometryColor();
// if (geomCol.r || geomCol.g || geomCol.b)
//{
// CGraphics::LoadLight(lightId, light->BuildLight());
lightsOut.push_back(light->BuildLight());
CGraphics::EnableLight(lightId);
//}
const zeus::CColor& geomCol = light->GetGeometryColor();
if (geomCol.r() != 0.f || geomCol.g() != 0.f || geomCol.b() != 0.f) {
CGraphics::LoadLight(lightId, light->BuildLight());
CGraphics::EnableLight(lightId);
}
// accumulate ambient color
ambColor += light->GetAmbientLightColor();
++enabledLights;
}
++reinterpret_cast<std::underlying_type_t<ERglLight>&>(lightId);
++idx;
}
if (lightsOut.empty()) {
// CGraphics::SetAmbientColor(zeus::skWhite);
lightsOut.push_back(CLight::BuildLocalAmbient(zeus::skZero3f, zeus::skWhite));
if (enabledLights == 0) {
CGraphics::SetAmbientColor(zeus::skWhite);
} else {
// CGraphics::SetAmbientColor(ambColor);
lightsOut.push_back(CLight::BuildLocalAmbient(zeus::skZero3f, ambColor));
CGraphics::SetAmbientColor(ambColor);
}
// TODO model.ActivateLights(lightsOut);
}
void CGuiFrame::DisableLights() const { CGraphics::DisableAllLights(); }

View File

@@ -10,9 +10,9 @@ namespace metaforce {
CGuiModel::CGuiModel(const CGuiWidgetParms& parms, CSimplePool* sp, CAssetId modelId, u32 lightMask, bool flag)
: CGuiWidget(parms), xc8_modelId(modelId), xcc_lightMask(lightMask) {
if (!flag || !modelId.IsValid() || parms.x0_frame->GetGuiSys().GetUsageMode() == CGuiSys::EUsageMode::Two)
if (!flag || !modelId.IsValid() || parms.x0_frame->GetGuiSys().GetUsageMode() == CGuiSys::EUsageMode::Two) {
return;
}
xb8_model = sp->GetObj({SBIG('CMDL'), modelId});
}
@@ -23,23 +23,17 @@ bool CGuiModel::GetIsFinishedLoadingWidgetSpecific() {
if (!xb8_model.IsLoaded()) {
return false;
}
//xb8_model->GetInstance().Touch(0);
return true; //xb8_model->IsLoaded(0);
xb8_model->Touch(0);
return xb8_model->IsLoaded(0);
}
void CGuiModel::Touch() {
return;
CModel* const model = xb8_model.GetObj();
if (model == nullptr) {
return;
if (CModel* const model = xb8_model.GetObj()) {
model->Touch(0);
}
model->Touch(0);
}
void CGuiModel::Draw(const CGuiWidgetDrawParms& parms) {
return;
CGraphics::SetModelMatrix(x34_worldXF);
if (!xb8_model) {
return;
@@ -48,7 +42,7 @@ void CGuiModel::Draw(const CGuiWidgetDrawParms& parms) {
return;
}
CModel* const model = xb8_model.GetObj();
if (!model) {
if (model == nullptr) {
return;
}
@@ -56,58 +50,48 @@ void CGuiModel::Draw(const CGuiWidgetDrawParms& parms) {
SCOPED_GRAPHICS_DEBUG_GROUP(fmt::format(FMT_STRING("CGuiModel::Draw {}"), m_name).c_str(), zeus::skCyan);
zeus::CColor moduCol = xa8_color2;
moduCol.a() *= parms.x0_alphaMod;
// TODO xb0_frame->EnableLights(xcc_lightMask, model->GetInstance());
// if (xb6_29_cullFaces)
// CGraphics::SetCullMode(ERglCullMode::Front);
xb0_frame->EnableLights(xcc_lightMask);
if (xb6_29_cullFaces) {
CGraphics::SetCullMode(ERglCullMode::Front);
}
switch (xac_drawFlags) {
case EGuiModelDrawFlags::Shadeless: {
CModelFlags flags(0, 0, 3, zeus::skWhite);
// flags.m_extendedShader = EExtendedShader::Flat;
constexpr CModelFlags flags(0, 0, 3, zeus::skWhite);
model->Draw(flags);
break;
}
case EGuiModelDrawFlags::Opaque: {
CModelFlags flags(1, 0, 3, moduCol);
// flags.m_extendedShader = EExtendedShader::Lighting;
model->Draw(flags);
break;
}
case EGuiModelDrawFlags::Alpha: {
CModelFlags flags(5, 0, (u32(xb7_24_depthWrite) << 1) | u32(xb6_31_depthTest), moduCol);
// flags.m_noCull = !xb6_29_cullFaces;
// flags.m_noZWrite = !xb7_24_depthWrite;
model->Draw(flags);
break;
}
case EGuiModelDrawFlags::Additive: {
CModelFlags flags(7, 0, (u32(xb7_24_depthWrite) << 1) | u32(xb6_31_depthTest), moduCol);
// flags.m_noCull = !xb6_29_cullFaces;
// flags.m_noZWrite = !xb7_24_depthWrite;
// flags.m_depthGreater = xb6_30_depthGreater;
model->Draw(flags);
break;
}
case EGuiModelDrawFlags::AlphaAdditiveOverdraw: {
CModelFlags flags(5, 0, xb6_31_depthTest, moduCol);
// flags.m_noCull = !xb6_29_cullFaces;
// flags.m_noZWrite = !xb7_24_depthWrite;
const CModelFlags flags(5, 0, (u32(xb6_30_depthGreater) << 4) | u32(xb6_31_depthTest), moduCol);
model->Draw(flags);
flags.x0_blendMode = 7;
flags.x1_matSetIdx = 0;
flags.x2_flags = (u32(xb7_24_depthWrite) << 1) | u32(xb6_31_depthTest);
flags.x4_color = moduCol;
// flags.m_noCull = !xb6_29_cullFaces;
model->Draw(flags);
const CModelFlags overdrawFlags(
8, 0, (u32(xb6_30_depthGreater) << 4) | (u32(xb7_24_depthWrite) << 1) | u32(xb6_31_depthTest), moduCol);
model->Draw(overdrawFlags);
break;
}
default:
break;
}
// if (xb6_29_cullFaces)
// CGraphics::SetCullMode(ERglCullMode::None);
if (xb6_29_cullFaces) {
CGraphics::SetCullMode(ERglCullMode::None);
}
xb0_frame->DisableLights();
}
@@ -115,15 +99,16 @@ void CGuiModel::Draw(const CGuiWidgetDrawParms& parms) {
}
bool CGuiModel::TestCursorHit(const zeus::CMatrix4f& vp, const zeus::CVector2f& point) const {
if (!xb8_model || !xb8_model.IsLoaded())
if (!xb8_model || !xb8_model.IsLoaded()) {
return false;
}
return xb8_model->GetAABB().projectedPointTest(vp * x34_worldXF.toMatrix4f(), point);
}
std::shared_ptr<CGuiWidget> CGuiModel::Create(CGuiFrame* frame, CInputStream& in, CSimplePool* sp) {
CGuiWidgetParms parms = ReadWidgetHeader(frame, in);
CAssetId model = in.Get<CAssetId>();
auto model = in.Get<CAssetId>();
in.ReadLong();
u32 lightMask = in.ReadLong();

View File

@@ -66,7 +66,7 @@ void COrbitPointMarker::Update(float dt, const CStateManager& mgr) {
}
}
void COrbitPointMarker::Draw(const CStateManager& mgr) const {
void COrbitPointMarker::Draw(const CStateManager& mgr) {
if ((x1c_lastFreeOrbit || x20_interpTimer > 0.f) && g_tweakTargeting->DrawOrbitPoint() &&
x28_orbitPointModel.IsLoaded()) {
SCOPED_GRAPHICS_DEBUG_GROUP("COrbitPointMarker::Draw", zeus::skCyan);

View File

@@ -24,6 +24,6 @@ public:
COrbitPointMarker();
bool CheckLoadComplete() const;
void Update(float dt, const CStateManager& mgr);
void Draw(const CStateManager& mgr) const;
void Draw(const CStateManager& mgr);
};
} // namespace metaforce