mirror of https://github.com/AxioDL/metaforce.git
Add debugging tool CVars
This commit is contained in:
parent
386d6ef527
commit
cede47be4d
|
@ -53,7 +53,13 @@
|
||||||
#include <zeus/CMRay.hpp>
|
#include <zeus/CMRay.hpp>
|
||||||
|
|
||||||
namespace urde {
|
namespace urde {
|
||||||
|
namespace {
|
||||||
|
hecl::CVar* debugToolDrawAiPath = nullptr;
|
||||||
|
hecl::CVar* debugToolDrawLighting = nullptr;
|
||||||
|
hecl::CVar* debugToolDrawCollisionActors = nullptr;
|
||||||
|
hecl::CVar* debugToolDrawMazePath = nullptr;
|
||||||
hecl::CVar* sm_logScripting = nullptr;
|
hecl::CVar* sm_logScripting = nullptr;
|
||||||
|
} // namespace
|
||||||
logvisor::Module LogModule("urde::CStateManager");
|
logvisor::Module LogModule("urde::CStateManager");
|
||||||
CStateManager::CStateManager(const std::weak_ptr<CRelayTracker>& relayTracker,
|
CStateManager::CStateManager(const std::weak_ptr<CRelayTracker>& relayTracker,
|
||||||
const std::weak_ptr<CMapWorldInfo>& mwInfo, const std::weak_ptr<CPlayerState>& playerState,
|
const std::weak_ptr<CMapWorldInfo>& mwInfo, const std::weak_ptr<CPlayerState>& playerState,
|
||||||
|
@ -118,7 +124,8 @@ CStateManager::CStateManager(const std::weak_ptr<CRelayTracker>& relayTracker,
|
||||||
x90c_loaderFuncs[size_t(EScriptObjectType::GrapplePoint)] = ScriptLoader::LoadGrapplePoint;
|
x90c_loaderFuncs[size_t(EScriptObjectType::GrapplePoint)] = ScriptLoader::LoadGrapplePoint;
|
||||||
x90c_loaderFuncs[size_t(EScriptObjectType::PuddleSpore)] = ScriptLoader::LoadPuddleSpore;
|
x90c_loaderFuncs[size_t(EScriptObjectType::PuddleSpore)] = ScriptLoader::LoadPuddleSpore;
|
||||||
x90c_loaderFuncs[size_t(EScriptObjectType::DebugCameraWaypoint)] = ScriptLoader::LoadDebugCameraWaypoint;
|
x90c_loaderFuncs[size_t(EScriptObjectType::DebugCameraWaypoint)] = ScriptLoader::LoadDebugCameraWaypoint;
|
||||||
x90c_loaderFuncs[size_t(EScriptObjectType::SpiderBallAttractionSurface)] = ScriptLoader::LoadSpiderBallAttractionSurface;
|
x90c_loaderFuncs[size_t(EScriptObjectType::SpiderBallAttractionSurface)] =
|
||||||
|
ScriptLoader::LoadSpiderBallAttractionSurface;
|
||||||
x90c_loaderFuncs[size_t(EScriptObjectType::PuddleToadGamma)] = ScriptLoader::LoadPuddleToadGamma;
|
x90c_loaderFuncs[size_t(EScriptObjectType::PuddleToadGamma)] = ScriptLoader::LoadPuddleToadGamma;
|
||||||
x90c_loaderFuncs[size_t(EScriptObjectType::DistanceFog)] = ScriptLoader::LoadDistanceFog;
|
x90c_loaderFuncs[size_t(EScriptObjectType::DistanceFog)] = ScriptLoader::LoadDistanceFog;
|
||||||
x90c_loaderFuncs[size_t(EScriptObjectType::FireFlea)] = ScriptLoader::LoadFireFlea;
|
x90c_loaderFuncs[size_t(EScriptObjectType::FireFlea)] = ScriptLoader::LoadFireFlea;
|
||||||
|
@ -428,9 +435,7 @@ void CStateManager::SetupParticleHook(const CActor& actor) const {
|
||||||
|
|
||||||
void CStateManager::MurderScriptInstanceNames() { xb40_uniqueInstanceNames.clear(); }
|
void CStateManager::MurderScriptInstanceNames() { xb40_uniqueInstanceNames.clear(); }
|
||||||
|
|
||||||
std::string CStateManager::HashInstanceName(CInputStream& in) {
|
std::string CStateManager::HashInstanceName(CInputStream& in) { return in.readString(); }
|
||||||
return in.readString();
|
|
||||||
}
|
|
||||||
|
|
||||||
void CStateManager::SetActorAreaId(CActor& actor, TAreaId aid) {
|
void CStateManager::SetActorAreaId(CActor& actor, TAreaId aid) {
|
||||||
const TAreaId actorAid = actor.GetAreaIdAlways();
|
const TAreaId actorAid = actor.GetAreaIdAlways();
|
||||||
|
@ -535,42 +540,51 @@ void CStateManager::BuildDynamicLightListForWorld() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CStateManager::DrawDebugStuff() const {
|
void CStateManager::DrawDebugStuff() const {
|
||||||
|
if (hecl::com_developer != nullptr && !hecl::com_developer->toBoolean()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// FIXME: Add proper globals for CVars
|
||||||
|
if (debugToolDrawAiPath == nullptr || debugToolDrawCollisionActors == nullptr || debugToolDrawLighting == nullptr ||
|
||||||
|
debugToolDrawMazePath == nullptr) {
|
||||||
|
debugToolDrawAiPath = hecl::CVarManager::instance()->findCVar("debugTool.drawAiPath");
|
||||||
|
debugToolDrawMazePath = hecl::CVarManager::instance()->findCVar("debugTool.drawMazePath");
|
||||||
|
debugToolDrawCollisionActors = hecl::CVarManager::instance()->findCVar("debugTool.drawCollisionActors");
|
||||||
|
debugToolDrawLighting = hecl::CVarManager::instance()->findCVar("debugTool.drawLighting");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
CGraphics::SetModelMatrix(zeus::CTransform());
|
CGraphics::SetModelMatrix(zeus::CTransform());
|
||||||
#ifndef NDEBUG
|
|
||||||
for (CEntity* ent : GetActorObjectList()) {
|
for (CEntity* ent : GetActorObjectList()) {
|
||||||
if (const TCastToPtr<CPatterned> ai = ent) {
|
if (const TCastToPtr<CPatterned> ai = ent) {
|
||||||
if (CPathFindSearch* path = ai->GetSearchPath()) {
|
if (CPathFindSearch* path = ai->GetSearchPath()) {
|
||||||
|
if (debugToolDrawAiPath->toBoolean()) {
|
||||||
path->DebugDraw();
|
path->DebugDraw();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else if (const TCastToPtr<CGameLight> light = ent) {
|
} else if (const TCastToPtr<CGameLight> light = ent) {
|
||||||
|
if (debugToolDrawLighting->toBoolean()) {
|
||||||
light->DebugDraw();
|
light->DebugDraw();
|
||||||
|
}
|
||||||
} else if (const TCastToPtr<CCollisionActor> colAct = ent) {
|
} else if (const TCastToPtr<CCollisionActor> colAct = ent) {
|
||||||
if (colAct->GetUniqueId() == x870_cameraManager->GetBallCamera()->GetCollisionActorId()) {
|
if (colAct->GetUniqueId() == x870_cameraManager->GetBallCamera()->GetCollisionActorId()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (debugToolDrawCollisionActors->toBoolean()) {
|
||||||
colAct->DebugDraw();
|
colAct->DebugDraw();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
auto* gameArea = x850_world->GetArea(x850_world->GetCurrentAreaId());
|
auto* gameArea = x850_world->GetArea(x850_world->GetCurrentAreaId());
|
||||||
if (gameArea != nullptr) {
|
if (gameArea != nullptr && debugToolDrawLighting->toBoolean()) {
|
||||||
gameArea->DebugDraw();
|
gameArea->DebugDraw();
|
||||||
}
|
}
|
||||||
if (xf70_currentMaze) {
|
|
||||||
|
if (xf70_currentMaze && debugToolDrawMazePath->toBoolean()) {
|
||||||
xf70_currentMaze->DebugRender();
|
xf70_currentMaze->DebugRender();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (CEntity* ent : GetActorObjectList()) {
|
|
||||||
if (const TCastToPtr<CCollisionActor> colAct = ent) {
|
|
||||||
if (colAct->GetUniqueId() == x870_cameraManager->GetBallCamera()->GetCollisionActorId()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
colAct->DebugDraw();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CStateManager::RenderCamerasAndAreaLights() {
|
void CStateManager::RenderCamerasAndAreaLights() {
|
||||||
|
@ -1507,7 +1521,9 @@ std::pair<TEditorId, TUniqueId> CStateManager::LoadScriptObject(TAreaId aid, ESc
|
||||||
ScriptObjectTypeToStr(type), name);
|
ScriptObjectTypeToStr(type), name);
|
||||||
return {kInvalidEditorId, kInvalidUniqueId};
|
return {kInvalidEditorId, kInvalidUniqueId};
|
||||||
} else {
|
} else {
|
||||||
|
#ifndef NDEBUG
|
||||||
LogModule.report(logvisor::Info, FMT_STRING("Loaded {} in area {}"), ent->GetName(), ent->GetAreaIdAlways());
|
LogModule.report(logvisor::Info, FMT_STRING("Loaded {} in area {}"), ent->GetName(), ent->GetAreaIdAlways());
|
||||||
|
#endif
|
||||||
return {id, ent->GetUniqueId()};
|
return {id, ent->GetUniqueId()};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1610,7 +1626,8 @@ void CStateManager::KnockBackPlayer(CPlayer& player, const zeus::CVector3f& pos,
|
||||||
usePower = power * 1000.f;
|
usePower = power * 1000.f;
|
||||||
const auto surface =
|
const auto surface =
|
||||||
player.x2b0_outOfWaterTicks == 2 ? player.x2ac_surfaceRestraint : CPlayer::ESurfaceRestraints::Water;
|
player.x2b0_outOfWaterTicks == 2 ? player.x2ac_surfaceRestraint : CPlayer::ESurfaceRestraints::Water;
|
||||||
if (surface != CPlayer::ESurfaceRestraints::Normal && player.GetOrbitState() == CPlayer::EPlayerOrbitState::NoOrbit) {
|
if (surface != CPlayer::ESurfaceRestraints::Normal &&
|
||||||
|
player.GetOrbitState() == CPlayer::EPlayerOrbitState::NoOrbit) {
|
||||||
usePower /= 7.f;
|
usePower /= 7.f;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -1722,7 +1739,8 @@ void CStateManager::ApplyRadiusDamage(const CActor& a1, const zeus::CVector3f& p
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const CDamageVulnerability* vuln = rad > 0.f ? a2.GetDamageVulnerability(pos, delta, info) : a2.GetDamageVulnerability();
|
const CDamageVulnerability* vuln =
|
||||||
|
rad > 0.f ? a2.GetDamageVulnerability(pos, delta, info) : a2.GetDamageVulnerability();
|
||||||
|
|
||||||
if (vuln->WeaponHurts(info.GetWeaponMode(), true)) {
|
if (vuln->WeaponHurts(info.GetWeaponMode(), true)) {
|
||||||
const float dam = info.GetRadiusDamage(*vuln);
|
const float dam = info.GetRadiusDamage(*vuln);
|
||||||
|
|
|
@ -1956,7 +1956,7 @@ void CMorphBall::CollidedWith(TUniqueId id, const CCollisionInfoList& list, CSta
|
||||||
|
|
||||||
if (wakeMaterial == EMaterialTypes::NoStepLogic) {
|
if (wakeMaterial == EMaterialTypes::NoStepLogic) {
|
||||||
if (info.GetMaterialLeft().HasMaterial(EMaterialTypes::Floor)) {
|
if (info.GetMaterialLeft().HasMaterial(EMaterialTypes::Floor)) {
|
||||||
EMaterialTypes tmpMaterial;
|
EMaterialTypes tmpMaterial = EMaterialTypes::NoStepLogic;
|
||||||
if (info.GetMaterialLeft().HasMaterial(EMaterialTypes::Dirt)) {
|
if (info.GetMaterialLeft().HasMaterial(EMaterialTypes::Dirt)) {
|
||||||
tmpMaterial = EMaterialTypes::Dirt;
|
tmpMaterial = EMaterialTypes::Dirt;
|
||||||
} else {
|
} else {
|
||||||
|
@ -2169,12 +2169,11 @@ float CMorphBall::CalculateSurfaceFriction() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMorphBall::ApplyGravity(const CStateManager& mgr) {
|
void CMorphBall::ApplyGravity(const CStateManager& mgr) {
|
||||||
const float mass = x0_player.GetMass();
|
if (!x0_player.CheckSubmerged() || mgr.GetPlayerState()->HasPowerUp(CPlayerState::EItemType::GravitySuit)) {
|
||||||
const bool hasGravitySuit = mgr.GetPlayerState()->HasPowerUp(CPlayerState::EItemType::GravitySuit);
|
x0_player.SetMomentumWR({0.f, 0.f, x0_player.GetMass() * g_tweakBall->GetBallGravity()});
|
||||||
const bool useWaterGravity = x0_player.CheckSubmerged() && !hasGravitySuit;
|
} else {
|
||||||
const float gravity = useWaterGravity ? g_tweakBall->GetBallWaterGravity() : g_tweakBall->GetBallGravity();
|
x0_player.SetMomentumWR({0.f, 0.f, x0_player.GetMass() * g_tweakBall->GetBallWaterGravity()});
|
||||||
|
}
|
||||||
x0_player.SetMomentumWR(zeus::CVector3f(0.f, 0.f, gravity * mass));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMorphBall::SpinToSpeed(float holdMag, const zeus::CVector3f& torque, float mag) {
|
void CMorphBall::SpinToSpeed(float holdMag, const zeus::CVector3f& torque, float mag) {
|
||||||
|
|
|
@ -11,9 +11,7 @@ namespace urde {
|
||||||
|
|
||||||
std::array<s32, 300> sMazeSeeds;
|
std::array<s32, 300> sMazeSeeds;
|
||||||
|
|
||||||
#ifndef NDEBUG
|
|
||||||
std::array<zeus::CVector3f, skMazeRows * skMazeCols> sDebugCellPos;
|
std::array<zeus::CVector3f, skMazeRows * skMazeCols> sDebugCellPos;
|
||||||
#endif
|
|
||||||
|
|
||||||
CScriptMazeNode::CScriptMazeNode(TUniqueId uid, std::string_view name, const CEntityInfo& info,
|
CScriptMazeNode::CScriptMazeNode(TUniqueId uid, std::string_view name, const CEntityInfo& info,
|
||||||
const zeus::CTransform& xf, bool active, s32 col, s32 row, s32 side,
|
const zeus::CTransform& xf, bool active, s32 col, s32 row, s32 side,
|
||||||
|
@ -163,14 +161,12 @@ void CScriptMazeNode::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, C
|
||||||
maze->GenerateObstacles();
|
maze->GenerateObstacles();
|
||||||
mgr.SetCurrentMaze(std::move(maze));
|
mgr.SetCurrentMaze(std::move(maze));
|
||||||
}
|
}
|
||||||
#ifndef NDEBUG
|
|
||||||
if (xf0_side == ESide::Right) {
|
if (xf0_side == ESide::Right) {
|
||||||
sDebugCellPos[xe8_col + xec_row * skMazeCols] = GetTranslation();
|
sDebugCellPos[xe8_col + xec_row * skMazeCols] = GetTranslation();
|
||||||
} else if (xe8_col == skMazeCols - 1) {
|
} else if (xe8_col == skMazeCols - 1) {
|
||||||
// Last column does not have right nodes, but we can infer the position
|
// Last column does not have right nodes, but we can infer the position
|
||||||
sDebugCellPos[xe8_col + xec_row * skMazeCols] = GetTranslation() - zeus::CVector3f{1.1875f, -0.1215f, 1.2187f};
|
sDebugCellPos[xe8_col + xec_row * skMazeCols] = GetTranslation() - zeus::CVector3f{1.1875f, -0.1215f, 1.2187f};
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// URDE change: used to be in the above if branch
|
// URDE change: used to be in the above if branch
|
||||||
|
@ -356,11 +352,9 @@ void CMazeState::Initialize() {
|
||||||
auto& cell = GetCell(*idx);
|
auto& cell = GetCell(*idx);
|
||||||
if (cell.x1_26_checked) {
|
if (cell.x1_26_checked) {
|
||||||
cell.x1_25_onPath = true;
|
cell.x1_25_onPath = true;
|
||||||
#ifndef NDEBUG
|
|
||||||
if (pathLength > 0) {
|
if (pathLength > 0) {
|
||||||
m_path.push_back(*idx);
|
m_path.push_back(*idx);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
x94_24_initialized = true;
|
x94_24_initialized = true;
|
||||||
|
@ -467,7 +461,6 @@ void CMazeState::GenerateObstacles() {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef NDEBUG
|
|
||||||
void CMazeState::DebugRender() {
|
void CMazeState::DebugRender() {
|
||||||
m_renderer.Reset();
|
m_renderer.Reset();
|
||||||
m_renderer.AddVertex(sDebugCellPos[skEnterCol + skEnterRow * skMazeCols], zeus::skBlue, 2.f);
|
m_renderer.AddVertex(sDebugCellPos[skEnterCol + skEnterRow * skMazeCols], zeus::skBlue, 2.f);
|
||||||
|
@ -484,5 +477,4 @@ void CMazeState::DebugRender() {
|
||||||
}
|
}
|
||||||
m_renderer.Render();
|
m_renderer.Render();
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
} // namespace urde
|
} // namespace urde
|
||||||
|
|
|
@ -54,10 +54,8 @@ class CMazeState {
|
||||||
s32 x90_targetRow;
|
s32 x90_targetRow;
|
||||||
bool x94_24_initialized : 1 = false;
|
bool x94_24_initialized : 1 = false;
|
||||||
|
|
||||||
#ifndef NDEBUG
|
|
||||||
std::vector<s32> m_path;
|
std::vector<s32> m_path;
|
||||||
CLineRenderer m_renderer = {CLineRenderer::EPrimitiveMode::LineStrip, skMazeRows * skMazeCols, {}, true};
|
CLineRenderer m_renderer = {CLineRenderer::EPrimitiveMode::LineStrip, skMazeRows * skMazeCols, {}, true};
|
||||||
#endif
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CMazeState(s32 enterCol, s32 enterRow, s32 targetCol, s32 targetRow)
|
CMazeState(s32 enterCol, s32 enterRow, s32 targetCol, s32 targetRow)
|
||||||
|
@ -66,9 +64,7 @@ public:
|
||||||
void Initialize();
|
void Initialize();
|
||||||
void GenerateObstacles();
|
void GenerateObstacles();
|
||||||
|
|
||||||
#ifndef NDEBUG
|
|
||||||
void DebugRender();
|
void DebugRender();
|
||||||
#endif
|
|
||||||
|
|
||||||
[[nodiscard]] SMazeCell& GetCell(u32 col, u32 row) {
|
[[nodiscard]] SMazeCell& GetCell(u32 col, u32 row) {
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
|
|
|
@ -54,7 +54,7 @@ void CScriptTrigger::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CS
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CEntity::AcceptScriptMsg(msg, uid, mgr);
|
CActor::AcceptScriptMsg(msg, uid, mgr);
|
||||||
}
|
}
|
||||||
|
|
||||||
CScriptTrigger::CObjectTracker* CScriptTrigger::FindObject(TUniqueId id) {
|
CScriptTrigger::CObjectTracker* CScriptTrigger::FindObject(TUniqueId id) {
|
||||||
|
|
2
hecl
2
hecl
|
@ -1 +1 @@
|
||||||
Subproject commit 660e2f3b3feb6eb3b7529dfdc0c3bdcee2a134eb
|
Subproject commit 892bc4a196aeea96bf9ba836126914d2d44667a2
|
Loading…
Reference in New Issue