mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
New DebugDraw shapes in SDK
DebugDrawCapsule and DebugDrawHemiSphere. Hooked up to DrawOverlay (OverlayType_t::OVERLAY_CAPSULE).
This commit is contained in:
parent
28de4a96bf
commit
ffa9f12e2b
@ -200,7 +200,26 @@ void DrawOverlay(OverlayBase_t* pOverlay)
|
||||
}
|
||||
case OverlayType_t::OVERLAY_CAPSULE:
|
||||
{
|
||||
//printf("CAPSULE %p\n", pOverlay);
|
||||
OverlayCapsule_t* pCapsule = static_cast<OverlayCapsule_t*>(pOverlay);
|
||||
if (pCapsule->a < 1)
|
||||
{
|
||||
if (r_debug_overlay_invisible->GetBool())
|
||||
{
|
||||
pCapsule->a = 255;
|
||||
}
|
||||
else
|
||||
{
|
||||
LeaveCriticalSection(&*s_OverlayMutex);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
QAngle angles;
|
||||
|
||||
VectorAngles(pCapsule->end, pCapsule->start, angles);
|
||||
AngleInverse(angles, angles);
|
||||
|
||||
DebugDrawCapsule(pCapsule->start, angles, 100, pCapsule->start.DistTo(pCapsule->end), Color(pCapsule->r, pCapsule->g, pCapsule->b, pCapsule->a), true);
|
||||
break;
|
||||
}
|
||||
case OverlayType_t::OVERLAY_UNK0:
|
||||
|
@ -238,6 +238,8 @@ public:
|
||||
Vector3D operator-(const Vector3D& v) const;
|
||||
Vector3D operator*(const Vector3D& v) const;
|
||||
Vector3D operator/(const Vector3D& v) const;
|
||||
Vector3D operator+(float fl) const;
|
||||
Vector3D operator-(float fl) const;
|
||||
Vector3D operator*(float fl) const;
|
||||
Vector3D operator/(float fl) const;
|
||||
|
||||
@ -1241,6 +1243,15 @@ FORCEINLINE IntVector4D IntVector4D::operator*(float fl) const
|
||||
// =======================
|
||||
|
||||
|
||||
FORCEINLINE void VectorAdd(const Vector3D& a, vec_t b, Vector3D& c)
|
||||
{
|
||||
CHECK_VALID(a);
|
||||
CHECK_VALID(b);
|
||||
c.x = a.x + b;
|
||||
c.y = a.y + b;
|
||||
c.z = a.z + b;
|
||||
}
|
||||
|
||||
FORCEINLINE void VectorAdd(const Vector3D& a, const Vector3D& b, Vector3D& c)
|
||||
{
|
||||
CHECK_VALID(a);
|
||||
@ -1250,6 +1261,15 @@ FORCEINLINE void VectorAdd(const Vector3D& a, const Vector3D& b, Vector3D& c)
|
||||
c.z = a.z + b.z;
|
||||
}
|
||||
|
||||
FORCEINLINE void VectorSubtract(const Vector3D& a, vec_t b, Vector3D& c)
|
||||
{
|
||||
CHECK_VALID(a);
|
||||
CHECK_VALID(b);
|
||||
c.x = a.x - b;
|
||||
c.y = a.y - b;
|
||||
c.z = a.z - b;
|
||||
}
|
||||
|
||||
FORCEINLINE void VectorSubtract(const Vector3D& a, const Vector3D& b, Vector3D& c)
|
||||
{
|
||||
CHECK_VALID(a);
|
||||
@ -1624,6 +1644,13 @@ inline Vector3D Vector3D::operator-(void) const
|
||||
return Vector3D(-x, -y, -z);
|
||||
}
|
||||
|
||||
inline Vector3D Vector3D::operator+(float fl) const
|
||||
{
|
||||
Vector3D res;
|
||||
VectorAdd(*this, fl, res);
|
||||
return res;
|
||||
}
|
||||
|
||||
inline Vector3D Vector3D::operator+(const Vector3D& v) const
|
||||
{
|
||||
Vector3D res;
|
||||
@ -1631,6 +1658,13 @@ inline Vector3D Vector3D::operator+(const Vector3D& v) const
|
||||
return res;
|
||||
}
|
||||
|
||||
inline Vector3D Vector3D::operator-(float fl) const
|
||||
{
|
||||
Vector3D res;
|
||||
VectorSubtract(*this, fl, res);
|
||||
return res;
|
||||
}
|
||||
|
||||
inline Vector3D Vector3D::operator-(const Vector3D& v) const
|
||||
{
|
||||
Vector3D res;
|
||||
|
@ -52,18 +52,18 @@ void DebugDrawBox(const Vector3D& vOrigin, const QAngle& vAngles, const Vector3D
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: render cylinder:
|
||||
// +y _+z
|
||||
// ^ /|
|
||||
// | /
|
||||
// |.-'""'-. /
|
||||
// ( )
|
||||
// |'-.__.-'|
|
||||
// | |
|
||||
// | |
|
||||
// | <----> |--> +r
|
||||
// | |
|
||||
// | |
|
||||
// "-.__.-" --> +x
|
||||
// +y _+z
|
||||
// ^ /|
|
||||
// | /
|
||||
// |.-'"|"'-. /
|
||||
// (----|----)
|
||||
// |'-._|_.-'|
|
||||
// | | |
|
||||
// | | |
|
||||
// | <--+--> |--> +r
|
||||
// | | |
|
||||
// | | |
|
||||
// "-._|_.-" --> +x
|
||||
//-----------------------------------------------------------------------------
|
||||
void DebugDrawCylinder(const Vector3D& vOrigin, const QAngle& vAngles, float flRadius, float flHeight, Color color, int nSides, bool bZBuffer)
|
||||
{
|
||||
@ -94,6 +94,51 @@ void DebugDrawCylinder(const Vector3D& vOrigin, const QAngle& vAngles, float flR
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: render capsule:
|
||||
// +y _+z
|
||||
// ^ /|
|
||||
// | /
|
||||
// |.-'"|"'-. /
|
||||
// |----|----|
|
||||
// | | |
|
||||
// | | |
|
||||
// | <--+--> |--> +r
|
||||
// | | |
|
||||
// | | |
|
||||
// |----|----|
|
||||
// "-..|..-" --> +x
|
||||
//-----------------------------------------------------------------------------
|
||||
void DebugDrawCapsule(const Vector3D& vStart, const QAngle& vAngles, float flRadius, float flHeight, Color color, bool bZBuffer)
|
||||
{
|
||||
int nSides = 4;
|
||||
float flDegrees = 360.0 / float(nSides);
|
||||
Vector3D vUp;
|
||||
Vector3D vForward;
|
||||
QAngle vComposed;
|
||||
QAngle vHemi;
|
||||
vector<Vector3D> vvPoints;
|
||||
AngleVectors(vAngles, nullptr, nullptr, &vUp);
|
||||
|
||||
for (int i = 0; i < nSides; i++)
|
||||
{
|
||||
AngleCompose(vAngles, { 0, flDegrees * i, 0 }, vComposed);
|
||||
AngleVectors(vComposed, &vForward);
|
||||
vvPoints.push_back(vStart + (vForward * flRadius));
|
||||
}
|
||||
|
||||
for (int i = 0; i < nSides; i++)
|
||||
{
|
||||
Vector3D vStart = vvPoints[i];
|
||||
v_RenderLine(vStart, vStart + (vUp * flHeight), color, bZBuffer);
|
||||
}
|
||||
|
||||
AngleCompose(vAngles, { 180, 180, 0 }, vHemi);
|
||||
|
||||
DebugDrawHemiSphere(vStart + (vUp * flHeight), vAngles, flRadius, color, 16, bZBuffer);
|
||||
DebugDrawHemiSphere(vStart, vHemi, flRadius, color, 16, bZBuffer);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: render sphere:
|
||||
// +y _+z
|
||||
@ -116,6 +161,61 @@ void DebugDrawSphere(const Vector3D& vOrigin, float flRadius, Color color, int n
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: render hemisphere:
|
||||
// +y _+z
|
||||
// ^ /|
|
||||
// | /
|
||||
// | .--"|"--. /
|
||||
// .' | '.
|
||||
// / | \ /--> +r
|
||||
// | <----( )---->-|/ --> +x
|
||||
//-----------------------------------------------------------------------------
|
||||
void DebugDrawHemiSphere(const Vector3D& vOrigin, const QAngle& vAngles, float flRadius, Color color, int nSegments, bool bZBuffer)
|
||||
{
|
||||
bool bFirstLoop = true;
|
||||
|
||||
Vector3D vStart[4];
|
||||
Vector3D vEnd[4];
|
||||
Vector3D vForward[4];
|
||||
QAngle vComposed[4];
|
||||
|
||||
float flDegrees = 360.0 / float(nSegments);
|
||||
|
||||
for (int i = 0; i < (nSegments / 2 + 1); i++)
|
||||
{
|
||||
AngleCompose(vAngles, { -flDegrees * i, 0, 0 }, vComposed[0]);
|
||||
AngleCompose(vAngles, { 0, flDegrees * i - 90, 0 }, vComposed[1]);
|
||||
AngleCompose(vAngles, { flDegrees * i + 180, 90, 0 }, vComposed[2]);
|
||||
AngleCompose(vAngles, { 0, flDegrees * i + 90, 0 }, vComposed[3]);
|
||||
|
||||
AngleVectors(vComposed[0], &vForward[0]);
|
||||
AngleVectors(vComposed[1], &vForward[1]);
|
||||
AngleVectors(vComposed[2], &vForward[2]);
|
||||
AngleVectors(vComposed[3], &vForward[3]);
|
||||
|
||||
vEnd[0] = vOrigin + (vForward[0] * flRadius);
|
||||
vEnd[1] = vOrigin + (vForward[1] * flRadius);
|
||||
vEnd[2] = vOrigin + (vForward[2] * flRadius);
|
||||
vEnd[3] = vOrigin + (vForward[3] * flRadius);
|
||||
|
||||
if (!bFirstLoop)
|
||||
{
|
||||
v_RenderLine(vStart[0], vEnd[0], color, bZBuffer);
|
||||
v_RenderLine(vStart[1], vEnd[1], color, bZBuffer);
|
||||
v_RenderLine(vStart[2], vEnd[2], color, bZBuffer);
|
||||
v_RenderLine(vStart[3], vEnd[3], color, bZBuffer);
|
||||
}
|
||||
|
||||
vStart[0] = vEnd[0];
|
||||
vStart[1] = vEnd[1];
|
||||
vStart[2] = vEnd[2];
|
||||
vStart[3] = vEnd[3];
|
||||
|
||||
bFirstLoop = false;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: render circle:
|
||||
// +y _+z
|
||||
@ -277,8 +377,3 @@ void DebugDrawAxis(const Vector3D& vOrigin, const QAngle& vAngles, float flScale
|
||||
v_RenderLine(vOrigin, vOrigin + vUp * flScale, Color(255, 0, 0, 255), bZBuffer);
|
||||
v_RenderLine(vOrigin, vOrigin + vRight * flScale, Color(0, 0, 255, 255), bZBuffer);
|
||||
}
|
||||
|
||||
void DebugDrawCapsule(const Vector3D& vStart, const Vector3D& vEnd, const float& flRadius, Color color, bool bZBuffer)
|
||||
{
|
||||
// !FIXME:
|
||||
}
|
@ -4,7 +4,9 @@
|
||||
|
||||
void DebugDrawBox(const Vector3D& vOrigin, const QAngle& vAngles, const Vector3D& vMins, const Vector3D& vMaxs, Color color, bool bZBuffer);
|
||||
void DebugDrawCylinder(const Vector3D& vOrigin, const QAngle& vAngles, float flRadius, float flHeight, Color color, int nSides = 16, bool bZBuffer = false);
|
||||
void DebugDrawCapsule(const Vector3D& vStart, const QAngle& vAngles, float flRadius, float flHeight, Color color, bool bZBuffer = false);
|
||||
void DebugDrawSphere(const Vector3D& vOrigin, float flRadius, Color color, int nSegments = 16, bool bZBuffer = false);
|
||||
void DebugDrawHemiSphere(const Vector3D& vOrigin, const QAngle& vAngles, float flRadius, Color color, int nSegments = 16, bool bZBuffer = false);
|
||||
void DebugDrawCircle(const Vector3D& vOrigin, const QAngle& vAngles, float flRadius, Color color, int nSegments = 16, bool bZBuffer = false);
|
||||
void DebugDrawSquare(const Vector3D& vOrigin, const QAngle& vAngles, float flSquareSize, Color color, bool bZBuffer = false);
|
||||
void DebugDrawTriangle(const Vector3D& vOrigin, const QAngle& vAngles, float flTriangleSize, Color color, bool bZBuffer = false);
|
||||
@ -12,5 +14,4 @@ void DebugDrawMark(const Vector3D& vOrigin, float flRadius, const vector<int>& v
|
||||
void DrawStar(const Vector3D& vRrigin, float flRadius, bool bZBuffer = false);
|
||||
void DebugDrawArrow(const Vector3D& vOrigin, const Vector3D& vEnd, float flArraySize, Color color, bool bZBuffer = false);
|
||||
void DebugDrawAxis(const Vector3D& vOrigin, const QAngle& vAngles = { 0, 0, 0 }, float flScale = 50.f, bool bZBuffer = false);
|
||||
void DebugDrawCapsule(const Vector3D& vStart, const Vector3D& vEnd, const float& flRadius, Color color, bool bZBuffer = false);
|
||||
#endif // RENDERUTILS_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user