From e8a0c5e752059f242525b1f77f549d0e36313039 Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Mon, 11 Jul 2022 21:23:26 +0200 Subject: [PATCH] Add cvar for debug overlay z-buffer. Only OverlayLine_t has a field to determine whether or not to ignore the z-buffer. Added ConVar 'r_debug_overlay_zbuffer' to allow setting z-buffer for all overlays. --- r5dev/engine/debugoverlay.cpp | 16 +++++++++------- r5dev/engine/debugoverlay.h | 2 +- r5dev/tier1/IConVar.cpp | 7 ++++--- r5dev/tier1/cvar.cpp | 1 + r5dev/tier1/cvar.h | 1 + 5 files changed, 16 insertions(+), 11 deletions(-) diff --git a/r5dev/engine/debugoverlay.cpp b/r5dev/engine/debugoverlay.cpp index 84fc611f..bce648bd 100644 --- a/r5dev/engine/debugoverlay.cpp +++ b/r5dev/engine/debugoverlay.cpp @@ -135,7 +135,7 @@ void DrawOverlay(OverlayBase_t* pOverlay) } } - v_RenderBox(pBox->transforms, pBox->mins, pBox->maxs, Color(pBox->r, pBox->g, pBox->b, pBox->a), false); + v_RenderBox(pBox->transforms, pBox->mins, pBox->maxs, Color(pBox->r, pBox->g, pBox->b, pBox->a), r_debug_overlay_zbuffer->GetBool()); break; } case OverlayType_t::OVERLAY_SPHERE: @@ -156,11 +156,12 @@ void DrawOverlay(OverlayBase_t* pOverlay) if (r_debug_overlay_wireframe->GetBool()) { - v_RenderWireframeSphere(pSphere->vOrigin, pSphere->flRadius, pSphere->nTheta, pSphere->nPhi, Color(pSphere->r, pSphere->g, pSphere->b, pSphere->a), false); + v_RenderWireframeSphere(pSphere->vOrigin, pSphere->flRadius, pSphere->nTheta, pSphere->nPhi, + Color(pSphere->r, pSphere->g, pSphere->b, pSphere->a), r_debug_overlay_zbuffer->GetBool()); } else { - DebugDrawSphere(pSphere->vOrigin, pSphere->flRadius, Color(pSphere->r, pSphere->g, pSphere->b, pSphere->a), 16); + DebugDrawSphere(pSphere->vOrigin, pSphere->flRadius, Color(pSphere->r, pSphere->g, pSphere->b, pSphere->a), 16, r_debug_overlay_zbuffer->GetBool()); } break; } @@ -180,7 +181,7 @@ void DrawOverlay(OverlayBase_t* pOverlay) } } - v_RenderLine(pLine->origin, pLine->dest, Color(pLine->r, pLine->g, pLine->b, pLine->a), pLine->noDepthTest); + v_RenderLine(pLine->origin, pLine->dest, Color(pLine->r, pLine->g, pLine->b, pLine->a), !pLine->noDepthTest); break; } case OverlayType_t::OVERLAY_TRIANGLE: @@ -219,7 +220,8 @@ void DrawOverlay(OverlayBase_t* pOverlay) VectorAngles(pCapsule->end, pCapsule->start, angles); AngleInverse(angles, angles); - DebugDrawCapsule(pCapsule->start, angles, pCapsule->radius, pCapsule->start.DistTo(pCapsule->end), Color(pCapsule->r, pCapsule->g, pCapsule->b, pCapsule->a), true); + DebugDrawCapsule(pCapsule->start, angles, pCapsule->radius, pCapsule->start.DistTo(pCapsule->end), + Color(pCapsule->r, pCapsule->g, pCapsule->b, pCapsule->a), r_debug_overlay_zbuffer->GetBool()); break; } case OverlayType_t::OVERLAY_UNK0: @@ -259,11 +261,11 @@ void DrawAIScriptNodes() pTransforms[1] = _mm_set_ps((*g_pAINetwork)->m_ScriptNode[i].m_vOrigin.y - 50.f, 0.0f, 1.0f, 0.0f); pTransforms[2] = _mm_set_ps((*g_pAINetwork)->m_ScriptNode[i].m_vOrigin.z - 50.f, 1.0f, 0.0f, 0.0f); - v_RenderBox(vTransforms, {0, 0, 0}, {100, 100, 100}, Color(0, 255, 0, 255), true); + v_RenderBox(vTransforms, {0, 0, 0}, {100, 100, 100}, Color(0, 255, 0, 255), r_debug_overlay_zbuffer->GetBool()); if (i > 0) { - v_RenderLine((*g_pAINetwork)->m_ScriptNode[i - 1].m_vOrigin, (*g_pAINetwork)->m_ScriptNode[i].m_vOrigin, Color(255, 0, 0, 255), true); + v_RenderLine((*g_pAINetwork)->m_ScriptNode[i - 1].m_vOrigin, (*g_pAINetwork)->m_ScriptNode[i].m_vOrigin, Color(255, 0, 0, 255), r_debug_overlay_zbuffer->GetBool()); } } } diff --git a/r5dev/engine/debugoverlay.h b/r5dev/engine/debugoverlay.h index f1293789..f62828a5 100644 --- a/r5dev/engine/debugoverlay.h +++ b/r5dev/engine/debugoverlay.h @@ -58,7 +58,7 @@ struct OverlayLine_t : public OverlayBase_t { OverlayLine_t(void) { m_Type = OverlayType_t::OVERLAY_LINE; } - Vector3D origin{}; + Vector3D origin{}; Vector3D dest{}; int r{}; int g{}; diff --git a/r5dev/tier1/IConVar.cpp b/r5dev/tier1/IConVar.cpp index 9ba3dfab..988d0e9f 100644 --- a/r5dev/tier1/IConVar.cpp +++ b/r5dev/tier1/IConVar.cpp @@ -54,7 +54,8 @@ void ConVar::Init(void) const r_debug_overlay_nodecay = new ConVar("r_debug_overlay_nodecay" , "0", FCVAR_DEVELOPMENTONLY | FCVAR_CHEAT, "Keeps all debug overlays alive regardless of their lifetime. Use command 'clear_debug_overlays' to clear everything.", false, 0.f, false, 0.f, nullptr, nullptr); r_debug_overlay_invisible = new ConVar("r_debug_overlay_invisible" , "1", FCVAR_DEVELOPMENTONLY | FCVAR_CHEAT, "Show invisible debug overlays (alpha < 1 = 255).", false, 0.f, false, 0.f, nullptr, nullptr); - r_debug_overlay_wireframe = new ConVar("r_debug_overlay_wireframe" , "1", FCVAR_DEVELOPMENTONLY | FCVAR_CHEAT, "Use of wireframe in debug overlays.", false, 0.f, false, 0.f, nullptr, nullptr); + r_debug_overlay_wireframe = new ConVar("r_debug_overlay_wireframe" , "1", FCVAR_DEVELOPMENTONLY | FCVAR_CHEAT, "Use wireframe in debug overlay.", false, 0.f, false, 0.f, nullptr, nullptr); + r_debug_overlay_zbuffer = new ConVar("r_debug_overlay_zbuffer" , "1", FCVAR_DEVELOPMENTONLY | FCVAR_CHEAT, "Use z-buffer for debug overlay.", false, 0.f, false, 0.f, nullptr, nullptr); r_drawWorldMeshes = new ConVar("r_drawWorldMeshes" , "1", FCVAR_DEVELOPMENTONLY | FCVAR_CHEAT, "Render world meshes.", false, 0.f, false, 0.f, nullptr, nullptr); r_drawWorldMeshesDepthOnly = new ConVar("r_drawWorldMeshesDepthOnly" , "1", FCVAR_DEVELOPMENTONLY | FCVAR_CHEAT, "Render world meshes (depth only).", false, 0.f, false, 0.f, nullptr, nullptr); r_drawWorldMeshesDepthAtTheEnd = new ConVar("r_drawWorldMeshesDepthAtTheEnd", "1", FCVAR_DEVELOPMENTONLY | FCVAR_CHEAT, "Render world meshes (depth at the end).", false, 0.f, false, 0.f, nullptr, nullptr); @@ -122,8 +123,8 @@ void ConVar::Init(void) const cl_gpustats_offset_x = new ConVar("cl_gpustats_offset_x" , "650", FCVAR_DEVELOPMENTONLY, "X offset for texture streaming debug overlay.", false, 0.f, false, 0.f, nullptr, nullptr); cl_gpustats_offset_y = new ConVar("cl_gpustats_offset_y" , "105", FCVAR_DEVELOPMENTONLY, "Y offset for texture streaming debug overlay.", false, 0.f, false, 0.f, nullptr, nullptr); - cl_showmaterialinfo = new ConVar("cl_showmaterialinfo", "0", FCVAR_DEVELOPMENTONLY, "Draw info for the material under the crosshair on screen.", false, 0.f, false, 0.f, nullptr, nullptr); - cl_materialinfo_offset_x = new ConVar("cl_materialinfo_offset_x", "0", FCVAR_DEVELOPMENTONLY, "X offset for material debug info overlay.", false, 0.f, false, 0.f, nullptr, nullptr); + cl_showmaterialinfo = new ConVar("cl_showmaterialinfo" , "0" , FCVAR_DEVELOPMENTONLY, "Draw info for the material under the crosshair on screen.", false, 0.f, false, 0.f, nullptr, nullptr); + cl_materialinfo_offset_x = new ConVar("cl_materialinfo_offset_x", "0" , FCVAR_DEVELOPMENTONLY, "X offset for material debug info overlay.", false, 0.f, false, 0.f, nullptr, nullptr); cl_materialinfo_offset_y = new ConVar("cl_materialinfo_offset_y", "420", FCVAR_DEVELOPMENTONLY, "Y offset for material debug info overlay.", false, 0.f, false, 0.f, nullptr, nullptr); con_max_size_logvector = new ConVar("con_max_size_logvector" , "1000", FCVAR_DEVELOPMENTONLY, "Maximum number of logs in the console until cleanup starts.", false, 0.f, false, 0.f, nullptr, nullptr); diff --git a/r5dev/tier1/cvar.cpp b/r5dev/tier1/cvar.cpp index 30f1e505..8a7d9046 100644 --- a/r5dev/tier1/cvar.cpp +++ b/r5dev/tier1/cvar.cpp @@ -34,6 +34,7 @@ ConVar* rcon_password = nullptr; ConVar* r_debug_overlay_nodecay = nullptr; ConVar* r_debug_overlay_invisible = nullptr; ConVar* r_debug_overlay_wireframe = nullptr; +ConVar* r_debug_overlay_zbuffer = nullptr; ConVar* r_drawWorldMeshes = nullptr; ConVar* r_drawWorldMeshesDepthOnly = nullptr; ConVar* r_drawWorldMeshesDepthAtTheEnd = nullptr; diff --git a/r5dev/tier1/cvar.h b/r5dev/tier1/cvar.h index 468c1dfe..dbb34bf9 100644 --- a/r5dev/tier1/cvar.h +++ b/r5dev/tier1/cvar.h @@ -33,6 +33,7 @@ extern ConVar* rcon_password; extern ConVar* r_debug_overlay_nodecay; extern ConVar* r_debug_overlay_invisible; extern ConVar* r_debug_overlay_wireframe; +extern ConVar* r_debug_overlay_zbuffer; extern ConVar* r_drawWorldMeshes; extern ConVar* r_drawWorldMeshesDepthOnly; extern ConVar* r_drawWorldMeshesDepthAtTheEnd;