From 31e7721fbfa811294e55bdd6ca38a1a7d4e60a58 Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Thu, 27 May 2021 01:30:40 -0700 Subject: [PATCH] Add trigger visualization to inspecter --- Runtime/CStateManager.cpp | 2 ++ Runtime/ImGuiConsole.cpp | 7 ++++++- Runtime/ImGuiEntitySupport.cpp | 20 +++++++++++++++++++- Runtime/World/CScriptTrigger.cpp | 10 +++++++++- Runtime/World/CScriptTrigger.hpp | 4 +++- 5 files changed, 39 insertions(+), 4 deletions(-) diff --git a/Runtime/CStateManager.cpp b/Runtime/CStateManager.cpp index 09622272e..b88c24bb8 100644 --- a/Runtime/CStateManager.cpp +++ b/Runtime/CStateManager.cpp @@ -580,6 +580,8 @@ void CStateManager::DrawDebugStuff() const { if (debugToolDrawPlatformCollision->toBoolean() && plat->GetActive()) { plat->DebugDraw(); } + } else if (const TCastToPtr tr = ent) { + tr->DebugDraw(); } } diff --git a/Runtime/ImGuiConsole.cpp b/Runtime/ImGuiConsole.cpp index d598c4a38..f8bf67afe 100644 --- a/Runtime/ImGuiConsole.cpp +++ b/Runtime/ImGuiConsole.cpp @@ -125,6 +125,11 @@ void ImGuiConsole::ShowMenuGame() { } void ImGuiConsole::LerpDebugColor(CActor* act) { + if (!act->m_debugSelected && !act->m_debugHovered) { + act->m_debugAddColorTime = 0.f; + act->m_debugAddColor = zeus::skClear; + return; + } act->m_debugAddColorTime += 1.f / 60.f; float lerp = act->m_debugAddColorTime; if (lerp > 2.f) { @@ -151,7 +156,7 @@ void ImGuiConsole::UpdateEntityEntries() { } else { entry.active = entry.ent->GetActive(); } - if (entry.isActor && (entry.ent->m_debugSelected || entry.ent->m_debugHovered)) { + if (entry.isActor) { LerpDebugColor(entry.AsActor()); } uid = list.GetNextObjectIndex(uid); diff --git a/Runtime/ImGuiEntitySupport.cpp b/Runtime/ImGuiEntitySupport.cpp index de8f42880..e96fc79d4 100644 --- a/Runtime/ImGuiEntitySupport.cpp +++ b/Runtime/ImGuiEntitySupport.cpp @@ -283,7 +283,25 @@ IMGUI_ENTITY_INSPECT(MP1::CFireFlea::CDeathCameraEffect, CEntity, FireFleaDeathC IMGUI_ENTITY_INSPECT(MP1::CMetroidPrimeRelay, CEntity, MetroidPrimeRelay, {}) IMGUI_ENTITY_INSPECT(CScriptActorKeyframe, CEntity, ScriptActorKeyframe, {}) IMGUI_ENTITY_INSPECT(CScriptActorRotate, CEntity, ScriptActorRotate, {}) -IMGUI_ENTITY_INSPECT(CScriptAreaAttributes, CEntity, ScriptAreaAttributes, {}) + +IMGUI_ENTITY_INSPECT(CScriptAreaAttributes, CEntity, ScriptAreaAttributes, { + BITFIELD_CHECKBOX("Show Skybox", x34_24_showSkybox); + ImGui::Text("Skybox Asset: 0x%08X", int(x4c_skybox.Value())); + ImGui::Text("Environment FX:"); + int fx = int(x38_envFx); + if (ImGui::Combo("Type", &fx, "None\0Snow\0Rain\0UnderwaterFlake\0", 4)) { + x38_envFx = EEnvFxType(fx); + } + ImGui::SameLine(); + ImGui::SliderFloat("Density", &x3c_envFxDensity, 0.f, 1.f); + ImGui::SliderFloat("Thermal Heat", &x40_thermalHeat, 0.f, 1.f); + ImGui::SliderFloat("XRay Fog Distance", &x44_xrayFogDistance, 0.f, 1.f); + ImGui::SliderFloat("World Lighting Level", &x48_worldLightingLevel, 0.f, 1.f); + int ph = int(x50_phazon); + if (ImGui::Combo("Phazon Type", &ph, "None\0Blue\0Orange\0", 3)) { + x50_phazon = EPhazonType(ph); + } +}) IMGUI_ENTITY_INSPECT(CScriptCameraBlurKeyframe, CEntity, ScriptCameraBlurKeyframe, {}) IMGUI_ENTITY_INSPECT(CScriptCameraFilterKeyframe, CEntity, ScriptCameraFilterKeyframe, {}) IMGUI_ENTITY_INSPECT(CScriptCameraShaker, CEntity, ScriptCameraShaker, {}) diff --git a/Runtime/World/CScriptTrigger.cpp b/Runtime/World/CScriptTrigger.cpp index af21a1f8f..a1c9ce45e 100644 --- a/Runtime/World/CScriptTrigger.cpp +++ b/Runtime/World/CScriptTrigger.cpp @@ -30,7 +30,8 @@ CScriptTrigger::CScriptTrigger(TUniqueId uid, std::string_view name, const CEnti // FIXME: HACK This fixes the HotE softlock, definitely need to look into the morphball's collision codepath and // FIXME: determine the proper fix if (GetEditorId() == 0x0034004B) { - Log.report(logvisor::Warning, FMT_STRING("BUG THIS!: Overriding forceField.x() for trigger {} in area {}"), GetEditorId(), GetAreaIdAlways()); + Log.report(logvisor::Warning, FMT_STRING("BUG THIS!: Overriding forceField.x() for trigger {} in area {}"), + GetEditorId(), GetAreaIdAlways()); x11c_forceField.x() = 0.f; } #endif @@ -307,4 +308,11 @@ void CScriptTrigger::Touch(CActor& act, CStateManager& mgr) { zeus::CAABox CScriptTrigger::GetTriggerBoundsWR() const { return {x130_bounds.min + x34_transform.origin, x130_bounds.max + x34_transform.origin}; } + +void CScriptTrigger::DebugDraw() { + if (m_debugSelected || m_debugHovered) { + m_debugBox.setAABB(GetTriggerBoundsWR()); + m_debugBox.draw(m_debugAddColor); + } +} } // namespace metaforce diff --git a/Runtime/World/CScriptTrigger.hpp b/Runtime/World/CScriptTrigger.hpp index fa864ba7b..0b3f14bd7 100644 --- a/Runtime/World/CScriptTrigger.hpp +++ b/Runtime/World/CScriptTrigger.hpp @@ -5,12 +5,12 @@ #include "Runtime/World/CActor.hpp" #include "Runtime/World/CDamageInfo.hpp" +#include "Runtime/Graphics/Shaders/CAABoxShader.hpp" #include #include namespace metaforce { - // TODO - Phil: Figure out what each of the DetectProjectiles actually mean enum class ETriggerFlags : u32 { None = 0, @@ -61,6 +61,7 @@ protected: bool x148_28_playerTriggerProc : 1 = false; bool x148_29_didPhazonDamage : 1 = false; + CAABoxShader m_debugBox; public: DEFINE_ENTITY CScriptTrigger(TUniqueId, std::string_view name, const CEntityInfo& info, const zeus::CVector3f& pos, @@ -90,5 +91,6 @@ public: x128_forceMagnitude = x11c_forceField.magnitude(); } bool IsPlayerTriggerProc() const { return x148_28_playerTriggerProc; } + void DebugDraw(); }; } // namespace metaforce