Add debug rendering for CScriptPlatform (CVar: debugTool.drawPlatformCollision)

This commit is contained in:
Phillip Stephens 2021-01-16 19:33:03 -08:00
parent dc270ced7e
commit 0781307c49
5 changed files with 34 additions and 14 deletions

View File

@ -75,19 +75,21 @@ void ViewManager::TestGameView::think() {
auto pt = std::div(igt, 3600);
overlayText +=
fmt::format(FMT_STRING("PlayTime: {:02d}:{:02d}:{:02d}.{:03d}\n"), pt.quot, pt.rem / 60, pt.rem % 60, ms);
if (g_StateManager->GetCurrentArea() != nullptr) {
if (m_currentRoom != g_StateManager->GetCurrentArea()) {
m_currentRoom = static_cast<const void*>(g_StateManager->GetCurrentArea());
m_lastRoomTime = igt - m_currentRoomStart;
m_currentRoomStart = igt;
}
double currentRoomTime = igt - m_currentRoomStart;
u32 curFrames = std::round(u32(currentRoomTime * 60));
u32 lastFrames = std::round(u32(m_lastRoomTime * 60));
overlayText += fmt::format(FMT_STRING("Room Time:{:8.3f}/{:6d}| Last Room:{:8.3f}/{:6d}\n"),
currentRoomTime, curFrames,
m_lastRoomTime, lastFrames);
}
if (g_StateManager->GetCurrentArea() != nullptr && m_cvarCommons.m_debugOverlayShowRoomTimer->toBoolean()) {
double igt = g_GameState->GetTotalPlayTime();
if (m_currentRoom != g_StateManager->GetCurrentArea()) {
m_currentRoom = static_cast<const void*>(g_StateManager->GetCurrentArea());
m_lastRoomTime = igt - m_currentRoomStart;
m_currentRoomStart = igt;
}
double currentRoomTime = igt - m_currentRoomStart;
u32 curFrames = std::round(u32(currentRoomTime * 60));
u32 lastFrames = std::round(u32(m_lastRoomTime * 60));
overlayText += fmt::format(FMT_STRING("Room Time:{:8.3f}/{:6d}| Last Room:{:8.3f}/{:6d}\n"),
currentRoomTime, curFrames,
m_lastRoomTime, lastFrames);
}
if (g_StateManager->Player() && m_cvarCommons.m_debugOverlayPlayerInfo->toBoolean()) {

View File

@ -58,6 +58,7 @@ hecl::CVar* debugToolDrawAiPath = nullptr;
hecl::CVar* debugToolDrawLighting = nullptr;
hecl::CVar* debugToolDrawCollisionActors = nullptr;
hecl::CVar* debugToolDrawMazePath = nullptr;
hecl::CVar* debugToolDrawPlatformCollision = nullptr;
hecl::CVar* sm_logScripting = nullptr;
} // namespace
logvisor::Module LogModule("urde::CStateManager");
@ -547,11 +548,12 @@ void CStateManager::DrawDebugStuff() const {
// FIXME: Add proper globals for CVars
if (debugToolDrawAiPath == nullptr || debugToolDrawCollisionActors == nullptr || debugToolDrawLighting == nullptr ||
debugToolDrawMazePath == nullptr) {
debugToolDrawMazePath == nullptr || debugToolDrawPlatformCollision == 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");
debugToolDrawPlatformCollision = hecl::CVarManager::instance()->findCVar("debugTool.drawPlatformCollision");
return;
}
@ -574,6 +576,10 @@ void CStateManager::DrawDebugStuff() const {
if (debugToolDrawCollisionActors->toBoolean()) {
colAct->DebugDraw();
}
} else if (const TCastToPtr<CScriptPlatform> plat = ent) {
if (debugToolDrawPlatformCollision->toBoolean() && plat->GetActive()) {
plat->DebugDraw();
}
}
}

View File

@ -560,4 +560,12 @@ zeus::CQuaternion CScriptPlatform::Move(float dt, CStateManager& mgr) {
return zeus::CQuaternion();
}
void CScriptPlatform::DebugDraw() {
if (!m_boxFilter) {
m_boxFilter = {CAABoxShader()};
}
m_boxFilter->setAABB(*GetTouchBounds());
m_boxFilter->draw({1.f, 0.f, 1.f, .5f});
}
} // namespace urde

View File

@ -12,6 +12,7 @@
#include "Runtime/World/CDamageVulnerability.hpp"
#include "Runtime/World/CHealthInfo.hpp"
#include "Runtime/World/CPhysicsActor.hpp"
#include "Runtime/Graphics/Shaders/CAABoxShader.hpp"
#include <zeus/CQuaternion.hpp>
#include <zeus/CTransform.hpp>
@ -72,6 +73,7 @@ class CScriptPlatform : public CPhysicsActor {
static rstl::reserved_vector<TUniqueId, 1024> BuildNearListFromRiders(CStateManager& mgr,
const std::vector<SRiders>& movedRiders);
std::optional<CAABoxShader> m_boxFilter;
public:
CScriptPlatform(TUniqueId uid, std::string_view name, const CEntityInfo& info, const zeus::CTransform& xf,
CModelData&& mData, const CActorParameters& actParms, const zeus::CAABox& aabb, float speed,
@ -114,5 +116,7 @@ public:
virtual void SplashThink(const zeus::CAABox&, const CFluidPlane&, float, CStateManager&) const;
virtual zeus::CQuaternion Move(float, CStateManager&);
void DebugDraw();
};
} // namespace urde

2
hecl

@ -1 +1 @@
Subproject commit 892bc4a196aeea96bf9ba836126914d2d44667a2
Subproject commit 4b30bc1ffe6499755b2d1c219cee01ef3e18848d