Improve debug draw depth test toggle logic

* Add box depth test cvar from engine for 'CBaseAnimating::DrawServerHitboxes'.
* Use noDepthTest field from OverlayBox_t instead of the cvar.
This commit is contained in:
Kawe Mazidjatari 2023-01-24 12:05:09 +01:00
parent 5a9824d30c
commit 19447f1122
7 changed files with 30 additions and 23 deletions

View File

@ -135,7 +135,7 @@ void DrawOverlay(OverlayBase_t* pOverlay)
}
}
v_RenderBox(pBox->transforms.mat, pBox->mins, pBox->maxs, Color(pBox->r, pBox->g, pBox->b, pBox->a), r_debug_overlay_zbuffer->GetBool());
v_RenderBox(pBox->transforms.mat, pBox->mins, pBox->maxs, Color(pBox->r, pBox->g, pBox->b, pBox->a), !pBox->noDepthTest);
break;
}
case OverlayType_t::OVERLAY_SPHERE:
@ -157,11 +157,11 @@ 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), r_debug_overlay_zbuffer->GetBool());
Color(pSphere->r, pSphere->g, pSphere->b, pSphere->a), r_debug_draw_depth_test->GetBool());
}
else
{
DebugDrawSphere(pSphere->vOrigin, pSphere->flRadius, Color(pSphere->r, pSphere->g, pSphere->b, pSphere->a), 16, r_debug_overlay_zbuffer->GetBool());
DebugDrawSphere(pSphere->vOrigin, pSphere->flRadius, Color(pSphere->r, pSphere->g, pSphere->b, pSphere->a), 16, r_debug_draw_depth_test->GetBool());
}
break;
}
@ -222,7 +222,7 @@ void DrawOverlay(OverlayBase_t* pOverlay)
AngleInverse(angles, angles);
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());
Color(pCapsule->r, pCapsule->g, pCapsule->b, pCapsule->a), r_debug_draw_depth_test->GetBool());
break;
}
case OverlayType_t::OVERLAY_UNK0:

View File

@ -4,6 +4,7 @@
//
//===========================================================================//
#include "core/stdafx.h"
#include "tier1/cvar.h"
#include "baseanimating.h"
#include "engine/modelinfo.h"
#include "public/idebugoverlay.h"
@ -40,6 +41,7 @@ void CBaseAnimating::DrawServerHitboxes(float duration /*= 0.0f*/)
int r = 0;
int g = 0;
int b = 255;
bool bDepthTest = !debug_draw_box_depth_test->GetBool();
for (int i = 0; i < pSet->numhitboxes; i++)
{
@ -52,7 +54,7 @@ void CBaseAnimating::DrawServerHitboxes(float duration /*= 0.0f*/)
b = static_cast<int>(255.0f * s_HullColor[j][2]);
HitboxToWorldTransforms(pBox->bone, &transforms);
g_pDebugOverlay->AddBoxOverlay(transforms, pBox->bbmin, pBox->bbmax, r, g, b, 0, true, duration);
g_pDebugOverlay->AddBoxOverlay(transforms, pBox->bbmin, pBox->bbmax, r, g, b, 0, bDepthTest, duration);
}
}

View File

@ -38,7 +38,7 @@ void CAI_Utility::DrawAIScriptNetwork(const CAI_Network* pNetwork) const
if (!pNetwork)
return; // AI Network not build or loaded.
const bool bUseDepthBuffer = r_debug_overlay_zbuffer->GetBool();
const bool bUseDepthBuffer = r_debug_draw_depth_test->GetBool();
const bool bDrawNearest = ai_script_nodes_draw_nearest->GetBool();
const int nNodeRange = ai_script_nodes_draw_range->GetInt();
const float flCameraRange = navmesh_debug_camera_range->GetFloat();
@ -109,7 +109,7 @@ void CAI_Utility::DrawNavMeshBVTree(dtNavMesh* pMesh) const
return; // NavMesh for hull not loaded.
const Vector3D vCamera = MainViewOrigin();
const bool bDepthBuffer = r_debug_overlay_zbuffer->GetBool();
const bool bDepthBuffer = r_debug_draw_depth_test->GetBool();
const int nTileRange = navmesh_debug_tile_range->GetInt();
const float flCameraRange = navmesh_debug_camera_range->GetFloat();
@ -172,7 +172,7 @@ void CAI_Utility::DrawNavMeshPortals(dtNavMesh* pMesh) const
return; // NavMesh for hull not loaded.
const Vector3D vCamera = MainViewOrigin();
const bool bDepthBuffer = r_debug_overlay_zbuffer->GetBool();
const bool bDepthBuffer = r_debug_draw_depth_test->GetBool();
const int nTileRange = navmesh_debug_tile_range->GetInt();
const float flCameraRange = navmesh_debug_camera_range->GetFloat();
@ -290,7 +290,7 @@ void CAI_Utility::DrawNavMeshPolys(dtNavMesh* pMesh) const
return; // NavMesh for hull not loaded.
const Vector3D vCamera = MainViewOrigin();
const bool bDepthBuffer = r_debug_overlay_zbuffer->GetBool();
const bool bDepthBuffer = r_debug_draw_depth_test->GetBool();
const int nTileRange = navmesh_debug_tile_range->GetInt();
const float flCameraRange = navmesh_debug_camera_range->GetFloat();
@ -374,7 +374,7 @@ void CAI_Utility::DrawNavMeshPolyBoundaries(dtNavMesh* pMesh) const
return; // NavMesh for hull not loaded.
const Vector3D vCamera = MainViewOrigin();
const bool bDepthBuffer = r_debug_overlay_zbuffer->GetBool();
const bool bDepthBuffer = r_debug_draw_depth_test->GetBool();
const bool bDrawInner = navmesh_draw_poly_bounds_inner->GetBool();
const int nTileRange = navmesh_debug_tile_range->GetInt();
const float flCameraRange = navmesh_debug_camera_range->GetFloat();

View File

@ -78,7 +78,7 @@ void ConVar::Init(void)
r_debug_overlay_nodecay = ConVar::Create("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 = ConVar::Create("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 = ConVar::Create("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 = ConVar::Create("r_debug_overlay_zbuffer" , "1", FCVAR_DEVELOPMENTONLY | FCVAR_CHEAT, "Use z-buffer for debug overlay.", false, 0.f, false, 0.f, nullptr, nullptr);
r_debug_draw_depth_test = ConVar::Create("r_debug_draw_depth_test" , "1", FCVAR_DEVELOPMENTONLY | FCVAR_CHEAT, "Toggle depth test for other debug draw functionality.", false, 0.f, false, 0.f, nullptr, nullptr);
r_drawWorldMeshes = ConVar::Create("r_drawWorldMeshes" , "1", FCVAR_DEVELOPMENTONLY | FCVAR_CHEAT, "Render world meshes.", false, 0.f, false, 0.f, nullptr, nullptr);
r_drawWorldMeshesDepthOnly = ConVar::Create("r_drawWorldMeshesDepthOnly" , "1", FCVAR_DEVELOPMENTONLY | FCVAR_CHEAT, "Render world meshes (depth only).", false, 0.f, false, 0.f, nullptr, nullptr);
r_drawWorldMeshesDepthAtTheEnd = ConVar::Create("r_drawWorldMeshesDepthAtTheEnd", "1", FCVAR_DEVELOPMENTONLY | FCVAR_CHEAT, "Render world meshes (depth at the end).", false, 0.f, false, 0.f, nullptr, nullptr);
@ -120,7 +120,7 @@ void ConVar::Init(void)
#endif // DEDICATED
#endif // !CLIENT_DLL
#if !defined (GAMEDLL_S0) && !defined (GAMEDLL_S1)
bhit_zbuffer = ConVar::Create("bhit_zbuffer" , "0", FCVAR_DEVELOPMENTONLY | FCVAR_REPLICATED, "Use z-buffer for bullet ray trace overlay.", false, 0.f, false, 0.f, nullptr, nullptr);
bhit_depth_test = ConVar::Create("bhit_depth_test", "0", FCVAR_DEVELOPMENTONLY | FCVAR_REPLICATED, "Use depth test for bullet ray trace overlay.", false, 0.f, false, 0.f, nullptr, nullptr);
bhit_abs_origin = ConVar::Create("bhit_abs_origin", "1", FCVAR_DEVELOPMENTONLY | FCVAR_REPLICATED, "Draw entity's predicted abs origin upon bullet impact for trajectory debugging (requires 'r_visualizetraces' to be set!).", false, 0.f, false, 0.f, nullptr, nullptr);
#endif // !GAMEDLL_S0 && !GAMEDLL_S1
//-------------------------------------------------------------------------
@ -251,6 +251,7 @@ void ConVar::InitShipped(void)
#endif // !DEDICATED
single_frame_shutdown_for_reload = g_pCVar->FindVar("single_frame_shutdown_for_reload");
enable_debug_overlays = g_pCVar->FindVar("enable_debug_overlays");
debug_draw_box_depth_test = g_pCVar->FindVar("debug_draw_box_depth_test");
model_defaultFadeDistScale = g_pCVar->FindVar("model_defaultFadeDistScale");
model_defaultFadeDistMin = g_pCVar->FindVar("model_defaultFadeDistMin");
#ifndef DEDICATED

View File

@ -11,9 +11,11 @@
ConVar* sdk_fixedframe_tickinterval = nullptr;
ConVar* single_frame_shutdown_for_reload = nullptr;
ConVar* old_gather_props = nullptr;
ConVar* enable_debug_overlays = nullptr;
ConVar* cm_unset_all_cmdquery = nullptr;
ConVar* enable_debug_overlays = nullptr;
ConVar* debug_draw_box_depth_test = nullptr;
ConVar* developer = nullptr;
ConVar* staticProp_defaultBuildFrustum = nullptr;
@ -36,14 +38,14 @@ 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_debug_draw_depth_test = nullptr;
ConVar* r_drawWorldMeshes = nullptr;
ConVar* r_drawWorldMeshesDepthOnly = nullptr;
ConVar* r_drawWorldMeshesDepthAtTheEnd = nullptr;
#ifndef DEDICATED
ConVar* r_visualizetraces = nullptr;
ConVar* r_visualizetraces_duration = nullptr;
ConVar* r_visualizetraces = nullptr;
ConVar* r_visualizetraces_duration = nullptr;
#endif // !DEDICATED
ConVar* stream_overlay = nullptr;
@ -96,7 +98,7 @@ ConVar* sv_visualizetraces = nullptr;
ConVar* sv_visualizetraces_duration = nullptr;
#if !defined (GAMEDLL_S0) && !defined (GAMEDLL_S1)
ConVar* bhit_enable = nullptr;
ConVar* bhit_zbuffer = nullptr;
ConVar* bhit_depth_test = nullptr;
ConVar* bhit_abs_origin = nullptr;
#endif // !GAMEDLL_S0 && !GAMEDLL_S1
//-----------------------------------------------------------------------------

View File

@ -7,9 +7,11 @@
extern ConVar* sdk_fixedframe_tickinterval;
extern ConVar* single_frame_shutdown_for_reload;
extern ConVar* old_gather_props;
extern ConVar* enable_debug_overlays;
extern ConVar* cm_unset_all_cmdquery;
extern ConVar* enable_debug_overlays;
extern ConVar* debug_draw_box_depth_test;
extern ConVar* developer;
extern ConVar* staticProp_defaultBuildFrustum;
@ -33,7 +35,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_debug_draw_depth_test;
extern ConVar* r_drawWorldMeshes;
extern ConVar* r_drawWorldMeshesDepthOnly;
extern ConVar* r_drawWorldMeshesDepthAtTheEnd;
@ -92,7 +94,7 @@ extern ConVar* sv_visualizetraces;
extern ConVar* sv_visualizetraces_duration;
#if !defined (GAMEDLL_S0) && !defined (GAMEDLL_S1)
extern ConVar* bhit_enable;
extern ConVar* bhit_zbuffer;
extern ConVar* bhit_depth_test;
extern ConVar* bhit_abs_origin;
#endif // !GAMEDLL_S0 && !GAMEDLL_S1
//-------------------------------------------------------------------------

View File

@ -1075,7 +1075,7 @@ void Line_f(const CCommand& args)
end[i] = atof(args[i + 4]);
}
g_pDebugOverlay->AddLineOverlay(start, end, 255, 255, 0, r_debug_overlay_zbuffer->GetBool(), 100);
g_pDebugOverlay->AddLineOverlay(start, end, 255, 255, 0, !r_debug_draw_depth_test->GetBool(), 100);
}
/*
@ -1173,8 +1173,8 @@ void BHit_f(const CCommand& args)
g_pEngineTraceServer->TraceRay(ray, TRACE_MASK_NPCWORLDSTATIC, &trace);
g_pDebugOverlay->AddLineOverlay(trace.startpos, trace.endpos, 0, 255, 0, !bhit_zbuffer->GetBool(), sv_visualizetraces_duration->GetFloat());
g_pDebugOverlay->AddLineOverlay(trace.endpos, vecAbsEnd, 255, 0, 0, !bhit_zbuffer->GetBool(), sv_visualizetraces_duration->GetFloat());
g_pDebugOverlay->AddLineOverlay(trace.startpos, trace.endpos, 0, 255, 0, !bhit_depth_test->GetBool(), sv_visualizetraces_duration->GetFloat());
g_pDebugOverlay->AddLineOverlay(trace.endpos, vecAbsEnd, 255, 0, 0, !bhit_depth_test->GetBool(), sv_visualizetraces_duration->GetFloat());
}
if (bhit_abs_origin->GetBool() && r_visualizetraces->GetBool())