aboutsummaryrefslogtreecommitdiff
path: root/primedev/client
diff options
context:
space:
mode:
authorJack <66967891+ASpoonPlaysGames@users.noreply.github.com>2024-02-05 17:01:22 +0000
committerGitHub <noreply@github.com>2024-02-05 18:01:22 +0100
commit73262ca616f0623a9715ceac90c17b0da4b320d7 (patch)
tree4624e5eec9329afdee0bfb67ccc64e9a935d4484 /primedev/client
parentedf013952ca2d110f190dc8cd16e5529846656e4 (diff)
downloadNorthstarLauncher-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')
-rw-r--r--primedev/client/cdll_client_int.h5
-rw-r--r--primedev/client/debugoverlay.cpp69
-rw-r--r--primedev/client/debugoverlay.h28
-rw-r--r--primedev/client/entity_client_tools.cpp13
4 files changed, 67 insertions, 48 deletions
diff --git a/primedev/client/cdll_client_int.h b/primedev/client/cdll_client_int.h
new file mode 100644
index 00000000..a32ccbeb
--- /dev/null
+++ b/primedev/client/cdll_client_int.h
@@ -0,0 +1,5 @@
+#pragma once
+
+#include "toolframework/itoolentity.h"
+
+inline IClientTools* g_pClientTools = nullptr;
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>();
diff --git a/primedev/client/debugoverlay.h b/primedev/client/debugoverlay.h
new file mode 100644
index 00000000..498bfafd
--- /dev/null
+++ b/primedev/client/debugoverlay.h
@@ -0,0 +1,28 @@
+#pragma once
+
+// Render Line
+inline void (*RenderLine)(const Vector3& v1, const Vector3& v2, Color c, bool bZBuffer);
+
+// Render box
+inline void (*RenderBox)(
+ const Vector3& vOrigin, const QAngle& angles, const Vector3& vMins, const Vector3& vMaxs, Color c, bool bZBuffer, bool bInsideOut);
+
+// Render wireframe box
+inline void (*RenderWireframeBox)(
+ const Vector3& vOrigin, const QAngle& angles, const Vector3& vMins, const Vector3& vMaxs, Color c, bool bZBuffer, bool bInsideOut);
+
+// Render swept box
+inline void (*RenderWireframeSweptBox)(
+ const Vector3& vStart, const Vector3& vEnd, const QAngle& angles, const Vector3& vMins, const Vector3& vMaxs, Color c, bool bZBuffer);
+
+// Render Triangle
+inline void (*RenderTriangle)(const Vector3& p1, const Vector3& p2, const Vector3& p3, Color c, bool bZBuffer);
+
+// Render Axis
+inline void (*RenderAxis)(const Vector3& vOrigin, float flScale, bool bZBuffer);
+
+// I dont know
+inline void (*RenderUnknown)(const Vector3& vUnk, float flUnk, bool bUnk);
+
+// Render Sphere
+inline void (*RenderSphere)(const Vector3& vCenter, float flRadius, int nTheta, int nPhi, Color c, bool bZBuffer);
diff --git a/primedev/client/entity_client_tools.cpp b/primedev/client/entity_client_tools.cpp
new file mode 100644
index 00000000..d6f0be11
--- /dev/null
+++ b/primedev/client/entity_client_tools.cpp
@@ -0,0 +1,13 @@
+#include "toolframework/itoolentity.h"
+#include "client/cdll_client_int.h"
+#include "core/tier1.h"
+
+class CClientTools : public IClientTools
+{
+public:
+};
+
+ON_DLL_LOAD("client.dll", ClientClientTools, (CModule module))
+{
+ g_pClientTools = Sys_GetFactoryPtr("client.dll", "VCLIENTTOOLS001").RCast<IClientTools*>();
+}