mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-12-10 06:27:43 +00:00
Add light visualization (requires custom models)
This commit is contained in:
@@ -306,9 +306,9 @@ CDummyGameArea::CDummyGameArea(CInputStream& in, int idx, int mlvlVersion) {
|
||||
aabb.readBoundingBoxBig(in);
|
||||
xc_mrea = in.readUint32Big();
|
||||
if (mlvlVersion > 15) {
|
||||
x10_areaId = in.readUint32Big();
|
||||
x10_areaId = in.readUint32Big();
|
||||
} else {
|
||||
x10_areaId = -1;
|
||||
x10_areaId = -1;
|
||||
}
|
||||
|
||||
u32 attachAreaCount = in.readUint32Big();
|
||||
@@ -1199,10 +1199,69 @@ void CGameArea::SetAreaAttributes(const CScriptAreaAttributes* areaAttributes) {
|
||||
x12c_postConstructed->x1128_worldLightingLevel = areaAttributes->GetWorldLightingLevel();
|
||||
}
|
||||
|
||||
bool CGameArea::CAreaObjectList::IsQualified(const CEntity& ent) const { return (ent.GetAreaIdAlways() == x200c_areaIdx); }
|
||||
bool CGameArea::CAreaObjectList::IsQualified(const CEntity& ent) const {
|
||||
return (ent.GetAreaIdAlways() == x200c_areaIdx);
|
||||
}
|
||||
void CGameArea::WarmupShaders(const SObjectTag& mreaTag) {
|
||||
// Calling this version of the constructor performs warmup implicitly
|
||||
[[maybe_unused]] CGameArea area(mreaTag.id);
|
||||
}
|
||||
|
||||
void CGameArea::DebugDraw() {
|
||||
if (!m_debugSphereRes) {
|
||||
const auto* tok = g_ResFactory->GetResourceIdByName("CMDL_DebugSphere");
|
||||
if (tok != nullptr && tok->type == FOURCC('CMDL')) {
|
||||
m_debugSphereRes = CStaticRes(tok->id, zeus::skOne3f);
|
||||
}
|
||||
}
|
||||
|
||||
if (m_debugSphereRes && !m_debugSphereModel) {
|
||||
m_debugSphereModel = std::make_unique<CModelData>(*m_debugSphereRes);
|
||||
}
|
||||
|
||||
if (!m_debugConeRes) {
|
||||
const auto* tok = g_ResFactory->GetResourceIdByName("CMDL_DebugLightCone");
|
||||
if (tok != nullptr && tok->type == FOURCC('CMDL')) {
|
||||
m_debugConeRes = CStaticRes(tok->id, zeus::skOne3f);
|
||||
}
|
||||
}
|
||||
|
||||
if (m_debugConeRes && !m_debugConeModel) {
|
||||
m_debugConeModel = std::make_unique<CModelData>(*m_debugConeRes);
|
||||
}
|
||||
|
||||
if (IsPostConstructed()) {
|
||||
for (const auto& light : x12c_postConstructed->x70_gfxLightsA) {
|
||||
DebugDrawLight(light);
|
||||
}
|
||||
for (const auto& light : x12c_postConstructed->x90_gfxLightsB) {
|
||||
DebugDrawLight(light);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CGameArea::DebugDrawLight(const CLight& light) {
|
||||
if (light.GetType() == ELightType::LocalAmbient) {
|
||||
return;
|
||||
}
|
||||
g_Renderer->SetGXRegister1Color(light.GetColor());
|
||||
CModelFlags modelFlags;
|
||||
modelFlags.x0_blendMode = 5;
|
||||
modelFlags.x4_color = zeus::skWhite;
|
||||
modelFlags.x4_color.a() = 0.5f;
|
||||
if ((light.GetType() == ELightType::Spot || light.GetType() == ELightType::Directional) && m_debugConeModel) {
|
||||
m_debugConeModel->Render(CModelData::EWhichModel::Normal,
|
||||
zeus::lookAt(light.GetPosition(), light.GetPosition() + light.GetDirection()) *
|
||||
zeus::CTransform::Scale(zeus::clamp(-90.f, light.GetRadius(), 90.f)),
|
||||
nullptr, modelFlags);
|
||||
} else if (m_debugSphereModel) {
|
||||
m_debugSphereModel->Render(CModelData::EWhichModel::Normal, zeus::CTransform::Translate(light.GetPosition()),
|
||||
nullptr, modelFlags);
|
||||
m_debugSphereModel->Render(CModelData::EWhichModel::Normal,
|
||||
zeus::CTransform::Translate(light.GetPosition()) *
|
||||
zeus::CTransform::Scale(light.GetRadius()),
|
||||
nullptr, modelFlags);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace urde
|
||||
|
||||
Reference in New Issue
Block a user