mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
Public IVDebugOverlay VFTable interface.
New public interface to add debug overlays on the go (memory is managed by the game module). 3 new commands: * line. * sphere. * capsule.
This commit is contained in:
parent
7de9dfd2d9
commit
bd3fe5b445
@ -100,6 +100,7 @@
|
|||||||
#include "public/include/edict.h"
|
#include "public/include/edict.h"
|
||||||
#endif // !CLIENT_DLL
|
#endif // !CLIENT_DLL
|
||||||
#ifndef DEDICATED
|
#ifndef DEDICATED
|
||||||
|
#include "public/include/idebugoverlay.h"
|
||||||
#include "inputsystem/inputsystem.h"
|
#include "inputsystem/inputsystem.h"
|
||||||
#include "windows/id3dx.h"
|
#include "windows/id3dx.h"
|
||||||
#endif // !DEDICATED
|
#endif // !DEDICATED
|
||||||
|
65
r5dev/public/include/idebugoverlay.h
Normal file
65
r5dev/public/include/idebugoverlay.h
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
//===== Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ======//
|
||||||
|
//
|
||||||
|
// Purpose: Debug overlay engine interface.
|
||||||
|
//
|
||||||
|
//===========================================================================//
|
||||||
|
//
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
#ifndef IDEBUGOVERLAY_H
|
||||||
|
#define IDEBUGOVERLAY_H
|
||||||
|
|
||||||
|
#include "mathlib/vector.h"
|
||||||
|
class IVDebugOverlay
|
||||||
|
{
|
||||||
|
void* __vftable /*VFT*/;
|
||||||
|
};
|
||||||
|
|
||||||
|
class CIVDebugOverlay : public IVDebugOverlay
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
void AddBoxOverlay(__m128i& vTransforms, const Vector3D& vMins, const Vector3D& vMaxs, int r, int g, int b, int a, bool bZBuffer, float flDuration)
|
||||||
|
{
|
||||||
|
static int index = 1;
|
||||||
|
CallVFunc<void>(index, this, vTransforms, vMins, vMaxs, r, g, b, a, bZBuffer, flDuration);
|
||||||
|
}
|
||||||
|
void AddSphereOverlay(const Vector3D& vOrigin, float flRadius, int nTheta, int nPhi, int r, int g, int b, int a, float flDuration)
|
||||||
|
{
|
||||||
|
static int index = 3;
|
||||||
|
CallVFunc<void>(index, this, vOrigin, flRadius, nTheta, nPhi, r, g, b, a, flDuration);
|
||||||
|
}
|
||||||
|
void AddLineOverlay(const Vector3D& vStart, const Vector3D& vEnd, int r, int g, int b, char bZBuffer, float flDuration)
|
||||||
|
{
|
||||||
|
static int index = 5;
|
||||||
|
CallVFunc<void>(index, this, vStart, vEnd, r, g, b, bZBuffer, flDuration);
|
||||||
|
}
|
||||||
|
void AddCapsuleOverlay(const Vector3D& vStart, const Vector3D& vEnd, const Vector3D& vRadius, const Vector3D& vTop, const Vector3D& vBottom, int r, int g, int b, int a, float flDuration)
|
||||||
|
{
|
||||||
|
static int index = 12;
|
||||||
|
CallVFunc<void>(index, this, vStart, vEnd, vRadius, vTop, vBottom, r, g, b, a, flDuration);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
inline CIVDebugOverlay* g_pDebugOverlay = nullptr;
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
class VDebugOverlayBase : public IDetour
|
||||||
|
{
|
||||||
|
virtual void GetAdr(void) const
|
||||||
|
{
|
||||||
|
spdlog::debug("| VAR: g_pDebugOverlay : {:#18x} |\n", reinterpret_cast<uintptr_t>(g_pDebugOverlay));
|
||||||
|
spdlog::debug("+----------------------------------------------------------------+\n");
|
||||||
|
}
|
||||||
|
virtual void GetFun(void) const { }
|
||||||
|
virtual void GetVar(void) const
|
||||||
|
{
|
||||||
|
g_pDebugOverlay = g_mGameDll.FindPatternSIMD(reinterpret_cast<rsig_t>("\x48\x8D\x05\x00\x00\x00\x00\xC3\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\x48\x8D\x05\x00\x00\x00\x00\xC3\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\x48\x83\xEC\x28\xF3\x0F\x10\x41\x00"), "xxx????xxxxxxxxxxxx????xxxxxxxxxxxxxxxxx?")
|
||||||
|
.ResolveRelativeAddressSelf(0x3, 0x7).RCast<CIVDebugOverlay*>();
|
||||||
|
}
|
||||||
|
virtual void GetCon(void) const { }
|
||||||
|
virtual void Attach(void) const { }
|
||||||
|
virtual void Detach(void) const { }
|
||||||
|
};
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
REGISTER(VDebugOverlayBase);
|
||||||
|
#endif // IDEBUGOVERLAY_H
|
@ -124,6 +124,13 @@ ConCommand::ConCommand(const char* pszName, const char* pszHelpString, int nFlag
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void ConCommand::Init(void)
|
void ConCommand::Init(void)
|
||||||
{
|
{
|
||||||
|
//-------------------------------------------------------------------------
|
||||||
|
// ENGINE DLL |
|
||||||
|
#ifndef DEDICATED
|
||||||
|
new ConCommand("line", "Draw a debug line.", FCVAR_GAMEDLL | FCVAR_CHEAT, Line_f, nullptr);
|
||||||
|
new ConCommand("sphere", "Draw a debug sphere.", FCVAR_GAMEDLL | FCVAR_CHEAT, Sphere_f, nullptr);
|
||||||
|
new ConCommand("capsule", "Draw a debug capsule.", FCVAR_GAMEDLL | FCVAR_CHEAT, Capsule_f, nullptr);
|
||||||
|
#endif //!DEDICATED
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
// SERVER DLL |
|
// SERVER DLL |
|
||||||
new ConCommand("script", "Run input code as SERVER script on the VM.", FCVAR_GAMEDLL | FCVAR_CHEAT, SQVM_ServerScript_f, nullptr);
|
new ConCommand("script", "Run input code as SERVER script on the VM.", FCVAR_GAMEDLL | FCVAR_CHEAT, SQVM_ServerScript_f, nullptr);
|
||||||
|
@ -236,6 +236,7 @@
|
|||||||
<ClInclude Include="..\public\include\edict.h" />
|
<ClInclude Include="..\public\include\edict.h" />
|
||||||
<ClInclude Include="..\public\include\globalvars_base.h" />
|
<ClInclude Include="..\public\include\globalvars_base.h" />
|
||||||
<ClInclude Include="..\public\include\icommandline.h" />
|
<ClInclude Include="..\public\include\icommandline.h" />
|
||||||
|
<ClInclude Include="..\public\include\idebugoverlay.h" />
|
||||||
<ClInclude Include="..\public\include\inetchannel.h" />
|
<ClInclude Include="..\public\include\inetchannel.h" />
|
||||||
<ClInclude Include="..\public\include\inetmsghandler.h" />
|
<ClInclude Include="..\public\include\inetmsghandler.h" />
|
||||||
<ClInclude Include="..\public\include\ivrenderview.h" />
|
<ClInclude Include="..\public\include\ivrenderview.h" />
|
||||||
|
@ -1616,6 +1616,9 @@
|
|||||||
<ClInclude Include="..\mathlib\transform.h">
|
<ClInclude Include="..\mathlib\transform.h">
|
||||||
<Filter>sdk\mathlib</Filter>
|
<Filter>sdk\mathlib</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\public\include\idebugoverlay.h">
|
||||||
|
<Filter>sdk\public\include</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Image Include="..\shared\resource\lockedserver.png">
|
<Image Include="..\shared\resource\lockedserver.png">
|
||||||
|
@ -257,6 +257,7 @@
|
|||||||
<ClInclude Include="..\public\include\globalvars_base.h" />
|
<ClInclude Include="..\public\include\globalvars_base.h" />
|
||||||
<ClInclude Include="..\public\include\icliententitylist.h" />
|
<ClInclude Include="..\public\include\icliententitylist.h" />
|
||||||
<ClInclude Include="..\public\include\icommandline.h" />
|
<ClInclude Include="..\public\include\icommandline.h" />
|
||||||
|
<ClInclude Include="..\public\include\idebugoverlay.h" />
|
||||||
<ClInclude Include="..\public\include\inetchannel.h" />
|
<ClInclude Include="..\public\include\inetchannel.h" />
|
||||||
<ClInclude Include="..\public\include\inetmsghandler.h" />
|
<ClInclude Include="..\public\include\inetmsghandler.h" />
|
||||||
<ClInclude Include="..\public\include\iserver.h" />
|
<ClInclude Include="..\public\include\iserver.h" />
|
||||||
|
@ -1694,6 +1694,9 @@
|
|||||||
<ClInclude Include="..\server\persistence.h">
|
<ClInclude Include="..\server\persistence.h">
|
||||||
<Filter>sdk\server</Filter>
|
<Filter>sdk\server</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\public\include\idebugoverlay.h">
|
||||||
|
<Filter>sdk\public\include</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Image Include="..\shared\resource\lockedserver.png">
|
<Image Include="..\shared\resource\lockedserver.png">
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
#include "vstdlib/callback.h"
|
#include "vstdlib/callback.h"
|
||||||
#ifndef DEDICATED
|
#ifndef DEDICATED
|
||||||
#include "materialsystem/cmaterialglue.h"
|
#include "materialsystem/cmaterialglue.h"
|
||||||
|
#include "public/include/idebugoverlay.h"
|
||||||
#endif // !DEDICATED
|
#endif // !DEDICATED
|
||||||
|
|
||||||
|
|
||||||
@ -897,4 +898,85 @@ void Mat_CrossHair_f(const CCommand& args)
|
|||||||
DevMsg(eDLL_T::MS, "%s - No Material found >:(\n", __FUNCTION__);
|
DevMsg(eDLL_T::MS, "%s - No Material found >:(\n", __FUNCTION__);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif // !DEDICATED
|
|
||||||
|
/*
|
||||||
|
=====================
|
||||||
|
Line_f
|
||||||
|
|
||||||
|
Draws a line at
|
||||||
|
start<x1 y1 z1> end<x2 y2 z2>.
|
||||||
|
=====================
|
||||||
|
*/
|
||||||
|
void Line_f(const CCommand& args)
|
||||||
|
{
|
||||||
|
if (args.ArgC() != 7)
|
||||||
|
{
|
||||||
|
DevMsg(eDLL_T::CLIENT, "Usage 'line': start(vector) end(vector)\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Vector3D start, end;
|
||||||
|
for (int i = 0; i < 3; ++i)
|
||||||
|
{
|
||||||
|
start[i] = atof(args[i + 1]);
|
||||||
|
end[i] = atof(args[i + 4]);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_pDebugOverlay->AddLineOverlay(start, end, 255, 255, 0, r_debug_overlay_zbuffer->GetBool(), 100);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
=====================
|
||||||
|
Sphere_f
|
||||||
|
|
||||||
|
Draws a sphere at origin(x1 y1 z1)
|
||||||
|
radius(float) theta(int) phi(int).
|
||||||
|
=====================
|
||||||
|
*/
|
||||||
|
void Sphere_f(const CCommand& args)
|
||||||
|
{
|
||||||
|
if (args.ArgC() != 7)
|
||||||
|
{
|
||||||
|
DevMsg(eDLL_T::CLIENT, "Usage 'sphere': origin(vector) radius(float) theta(int) phi(int)\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Vector3D start;
|
||||||
|
for (int i = 0; i < 3; ++i)
|
||||||
|
{
|
||||||
|
start[i] = atof(args[i + 1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
float radius = atof(args[4]);
|
||||||
|
int theta = atoi(args[5]);
|
||||||
|
int phi = atoi(args[6]);
|
||||||
|
|
||||||
|
g_pDebugOverlay->AddSphereOverlay(start, radius, theta, phi, 20, 210, 255, 0, 100);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
=====================
|
||||||
|
Capsule_f
|
||||||
|
|
||||||
|
Draws a capsule at start<x1 y1 z1>
|
||||||
|
end<x2 y2 z2> radius <x3 y3 z3>.
|
||||||
|
=====================
|
||||||
|
*/
|
||||||
|
void Capsule_f(const CCommand& args)
|
||||||
|
{
|
||||||
|
if (args.ArgC() != 10)
|
||||||
|
{
|
||||||
|
DevMsg(eDLL_T::CLIENT, "Usage 'capsule': start(vector) end(vector) radius(vector)\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Vector3D start, end, radius;
|
||||||
|
for (int i = 0; i < 3; ++i)
|
||||||
|
{
|
||||||
|
start[i] = atof(args[i + 1]);
|
||||||
|
end[i] = atof(args[i + 4]);
|
||||||
|
radius[i] = atof(args[i + 7]);
|
||||||
|
}
|
||||||
|
g_pDebugOverlay->AddCapsuleOverlay(start, end, radius, { 0,0,0 }, { 0,0,0 }, 141, 233, 135, 0, 100);
|
||||||
|
}
|
||||||
|
#endif // !DEDICATED
|
||||||
|
@ -43,6 +43,9 @@ void SQVM_ServerScript_f(const CCommand& args);
|
|||||||
void SQVM_ClientScript_f(const CCommand& args);
|
void SQVM_ClientScript_f(const CCommand& args);
|
||||||
void SQVM_UIScript_f(const CCommand& args);
|
void SQVM_UIScript_f(const CCommand& args);
|
||||||
void Mat_CrossHair_f(const CCommand& args);
|
void Mat_CrossHair_f(const CCommand& args);
|
||||||
|
void Line_f(const CCommand& args);
|
||||||
|
void Sphere_f(const CCommand& args);
|
||||||
|
void Capsule_f(const CCommand& args);
|
||||||
#endif // !DEDICATED
|
#endif // !DEDICATED
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
class VCallback : public IDetour
|
class VCallback : public IDetour
|
||||||
|
Loading…
x
Reference in New Issue
Block a user