Add trigger visualization to inspecter

This commit is contained in:
Phillip Stephens 2021-05-27 01:30:40 -07:00 committed by Luke Street
parent acb827a3b5
commit 0a76ee1ae2
5 changed files with 39 additions and 4 deletions

View File

@ -580,6 +580,8 @@ void CStateManager::DrawDebugStuff() const {
if (debugToolDrawPlatformCollision->toBoolean() && plat->GetActive()) {
plat->DebugDraw();
}
} else if (const TCastToPtr<CScriptTrigger> tr = ent) {
tr->DebugDraw();
}
}

View File

@ -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);

View File

@ -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, {})

View File

@ -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

View File

@ -5,12 +5,12 @@
#include "Runtime/World/CActor.hpp"
#include "Runtime/World/CDamageInfo.hpp"
#include "Runtime/Graphics/Shaders/CAABoxShader.hpp"
#include <zeus/CAABox.hpp>
#include <zeus/CVector3f.hpp>
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