From f4ea846284b7e01b3b9efd658cec11f57b5d9359 Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Tue, 12 Jul 2022 21:02:10 +0200 Subject: [PATCH] RenderUtils cleanup. --- r5dev/tier2/renderutils.cpp | 49 ++++++++++++------------------------- 1 file changed, 16 insertions(+), 33 deletions(-) diff --git a/r5dev/tier2/renderutils.cpp b/r5dev/tier2/renderutils.cpp index 000343d1..fdc32978 100644 --- a/r5dev/tier2/renderutils.cpp +++ b/r5dev/tier2/renderutils.cpp @@ -68,9 +68,9 @@ void DebugDrawBox(const Vector3D& vOrigin, const QAngle& vAngles, const Vector3D void DebugDrawCylinder(const Vector3D& vOrigin, const QAngle& vAngles, float flRadius, float flHeight, Color color, int nSides, bool bZBuffer) { float flDegrees = 360.f / float(nSides); - vector vvPoints; - Vector3D vForward; QAngle vComposed; + Vector3D vForward; + vector vvPoints; AngleVectors(vAngles, &vForward); @@ -111,29 +111,19 @@ void DebugDrawCylinder(const Vector3D& vOrigin, const QAngle& vAngles, float flR //----------------------------------------------------------------------------- void DebugDrawCapsule(const Vector3D& vStart, const QAngle& vAngles, const Vector3D& vRadius, float flHeight, Color color, bool bZBuffer) { - int nSides = 4; - float flDegrees = 360.0 / float(nSides); - Vector3D vUp; - Vector3D vForward; - QAngle vComposed; - QAngle vHemi; - vector vvPoints; + Vector3D vForward, vUp; + QAngle vHemi, vComposed; + AngleVectors(vAngles, nullptr, nullptr, &vUp); - for (int i = 0; i < nSides; i++) + for (int i = 0; i < 4; i++) { - AngleCompose(vAngles, { 0, flDegrees * i, 0 }, vComposed); + AngleCompose(vAngles, { 0.f, 90.f * i, 0.f }, vComposed); AngleVectors(vComposed, &vForward); - vvPoints.push_back(vStart + (vForward * vRadius)); + v_RenderLine(vStart + (vForward * vRadius), vStart + (vForward * vRadius) + (vUp * flHeight), color, bZBuffer); } - 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); + AngleCompose(vAngles, { 180.f, 180.f, 0.f }, vHemi); DebugDrawHemiSphere(vStart + (vUp * flHeight), vAngles, vRadius, color, 8, bZBuffer); DebugDrawHemiSphere(vStart, vHemi, vRadius, color, 8, bZBuffer); @@ -172,14 +162,11 @@ void DebugDrawSphere(const Vector3D& vOrigin, float flRadius, Color color, int n void DebugDrawHemiSphere(const Vector3D& vOrigin, const QAngle& vAngles, const Vector3D& vRadius, 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 * 2); + Vector3D vStart[4], vEnd[4], vForward[4]; + QAngle vComposed[4]; + for (int i = 0; i < (nSegments + 1); i++) { AngleCompose(vAngles, { flDegrees * i - 180, 0, 0 }, vComposed[0]); @@ -230,13 +217,11 @@ void DebugDrawHemiSphere(const Vector3D& vOrigin, const QAngle& vAngles, const V void DebugDrawCircle(const Vector3D& vOrigin, const QAngle& vAngles, float flRadius, Color color, int nSegments, bool bZBuffer) { bool bFirstLoop = true; - Vector3D vStart; - Vector3D vEnd; - Vector3D vFirstend; - Vector3D vForward; - QAngle vComposed; float flDegrees = 360.f / float(nSegments); + Vector3D vStart, vEnd, vFirstend, vForward; + QAngle vComposed; + for (int i = 0; i < nSegments; i++) { AngleCompose(vAngles, { 0.f, flDegrees * i, 0.f }, vComposed); @@ -366,9 +351,7 @@ void DebugDrawArrow(const Vector3D& vOrigin, const Vector3D& vEnd, float flArray //----------------------------------------------------------------------------- void DebugDrawAxis(const Vector3D& vOrigin, const QAngle& vAngles, float flScale, bool bZBuffer) { - Vector3D vForward; - Vector3D vRight; - Vector3D vUp; + Vector3D vForward, vRight, vUp; AngleVectors(vAngles, &vForward, &vRight, &vUp); v_RenderLine(vOrigin, vOrigin + vForward * flScale, Color(0, 255, 0, 255), bZBuffer);