diff options
author | Jack <66967891+ASpoonPlaysGames@users.noreply.github.com> | 2024-02-05 17:01:22 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-05 18:01:22 +0100 |
commit | 73262ca616f0623a9715ceac90c17b0da4b320d7 (patch) | |
tree | 4624e5eec9329afdee0bfb67ccc64e9a935d4484 /primedev/client/debugoverlay.cpp | |
parent | edf013952ca2d110f190dc8cd16e5529846656e4 (diff) | |
download | NorthstarLauncher-73262ca616f0623a9715ceac90c17b0da4b320d7.tar.gz NorthstarLauncher-73262ca616f0623a9715ceac90c17b0da4b320d7.zip |
Port navmesh debug renderer from primedev (#626)
Adds support for rendering navmeshes in-game using debug overlay
Cherry-picked from primedev, originally written by F1F7Y
Co-authored-by: F1F7Y <filip.bartos07@proton.me>
Co-authored-by: Maya <11448698+RoyalBlue1@users.noreply.github.com>
Diffstat (limited to 'primedev/client/debugoverlay.cpp')
-rw-r--r-- | primedev/client/debugoverlay.cpp | 69 |
1 files changed, 21 insertions, 48 deletions
diff --git a/primedev/client/debugoverlay.cpp b/primedev/client/debugoverlay.cpp index 8e860218..a67b8355 100644 --- a/primedev/client/debugoverlay.cpp +++ b/primedev/client/debugoverlay.cpp @@ -1,6 +1,9 @@ +#include "debugoverlay.h" + #include "dedicated/dedicated.h" #include "core/convar/cvar.h" #include "core/math/vector.h" +#include "server/ai_helper.h" AUTOHOOK_INIT() @@ -122,48 +125,13 @@ struct OverlaySphere_t : public OverlayBase_t bool m_bWireframe; }; -typedef bool (*OverlayBase_t__IsDeadType)(OverlayBase_t* a1); -static OverlayBase_t__IsDeadType OverlayBase_t__IsDead; -typedef void (*OverlayBase_t__DestroyOverlayType)(OverlayBase_t* a1); -static OverlayBase_t__DestroyOverlayType OverlayBase_t__DestroyOverlay; +static bool (*OverlayBase_t__IsDead)(OverlayBase_t* a1); +static void (*OverlayBase_t__DestroyOverlay)(OverlayBase_t* a1); static ConVar* Cvar_enable_debug_overlays; LPCRITICAL_SECTION s_OverlayMutex; -// Render Line -typedef void (*RenderLineType)(const Vector3& v1, const Vector3& v2, Color c, bool bZBuffer); -static RenderLineType RenderLine; - -// Render box -typedef void (*RenderBoxType)( - const Vector3& vOrigin, const QAngle& angles, const Vector3& vMins, const Vector3& vMaxs, Color c, bool bZBuffer, bool bInsideOut); -static RenderBoxType RenderBox; - -// Render wireframe box -static RenderBoxType RenderWireframeBox; - -// Render swept box -typedef void (*RenderWireframeSweptBoxType)( - const Vector3& vStart, const Vector3& vEnd, const QAngle& angles, const Vector3& vMins, const Vector3& vMaxs, Color c, bool bZBuffer); -RenderWireframeSweptBoxType RenderWireframeSweptBox; - -// Render Triangle -typedef void (*RenderTriangleType)(const Vector3& p1, const Vector3& p2, const Vector3& p3, Color c, bool bZBuffer); -static RenderTriangleType RenderTriangle; - -// Render Axis -typedef void (*RenderAxisType)(const Vector3& vOrigin, float flScale, bool bZBuffer); -static RenderAxisType RenderAxis; - -// I dont know -typedef void (*RenderUnknownType)(const Vector3& vUnk, float flUnk, bool bUnk); -static RenderUnknownType RenderUnknown; - -// Render Sphere -typedef void (*RenderSphereType)(const Vector3& vCenter, float flRadius, int nTheta, int nPhi, Color c, bool bZBuffer); -static RenderSphereType RenderSphere; - OverlayBase_t** s_pOverlays; int* g_nRenderTickCount; @@ -317,6 +285,11 @@ void, __fastcall, (bool bRender)) } } + if (bRender && Cvar_enable_debug_overlays->GetBool()) + { + g_pAIHelper->DrawNavmeshPolys(); + } + LeaveCriticalSection(s_OverlayMutex); } @@ -324,17 +297,17 @@ ON_DLL_LOAD_CLIENT_RELIESON("engine.dll", DebugOverlay, ConVar, (CModule module) { AUTOHOOK_DISPATCH() - OverlayBase_t__IsDead = module.Offset(0xACAC0).RCast<OverlayBase_t__IsDeadType>(); - OverlayBase_t__DestroyOverlay = module.Offset(0xAB680).RCast<OverlayBase_t__DestroyOverlayType>(); - - RenderLine = module.Offset(0x192A70).RCast<RenderLineType>(); - RenderBox = module.Offset(0x192520).RCast<RenderBoxType>(); - RenderWireframeBox = module.Offset(0x193DA0).RCast<RenderBoxType>(); - RenderWireframeSweptBox = module.Offset(0x1945A0).RCast<RenderWireframeSweptBoxType>(); - RenderTriangle = module.Offset(0x193940).RCast<RenderTriangleType>(); - RenderAxis = module.Offset(0x1924D0).RCast<RenderAxisType>(); - RenderSphere = module.Offset(0x194170).RCast<RenderSphereType>(); - RenderUnknown = module.Offset(0x1924E0).RCast<RenderUnknownType>(); + OverlayBase_t__IsDead = module.Offset(0xACAC0).RCast<decltype(OverlayBase_t__IsDead)>(); + OverlayBase_t__DestroyOverlay = module.Offset(0xAB680).RCast<decltype(OverlayBase_t__DestroyOverlay)>(); + + RenderLine = module.Offset(0x192A70).RCast<decltype(RenderLine)>(); + RenderBox = module.Offset(0x192520).RCast<decltype(RenderBox)>(); + RenderWireframeBox = module.Offset(0x193DA0).RCast<decltype(RenderWireframeBox)>(); + RenderWireframeSweptBox = module.Offset(0x1945A0).RCast<decltype(RenderWireframeSweptBox)>(); + RenderTriangle = module.Offset(0x193940).RCast<decltype(RenderTriangle)>(); + RenderAxis = module.Offset(0x1924D0).RCast<decltype(RenderAxis)>(); + RenderSphere = module.Offset(0x194170).RCast<decltype(RenderSphere)>(); + RenderUnknown = module.Offset(0x1924E0).RCast<decltype(RenderUnknown)>(); s_OverlayMutex = module.Offset(0x10DB0A38).RCast<LPCRITICAL_SECTION>(); |