From e8a5bbcb9ffcd5c4df889e4c9014d6081a3beea3 Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Sun, 22 Jan 2023 12:12:06 +0100 Subject: [PATCH] BHit_f: split server and client rendering --- r5dev/tier1/IConVar.cpp | 2 +- r5dev/vstdlib/callback.cpp | 36 ++++++++++++++++++++---------------- 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/r5dev/tier1/IConVar.cpp b/r5dev/tier1/IConVar.cpp index 5bc31e02..128d5c91 100644 --- a/r5dev/tier1/IConVar.cpp +++ b/r5dev/tier1/IConVar.cpp @@ -120,7 +120,7 @@ void ConVar::Init(void) #endif // !CLIENT_DLL #if !defined (GAMEDLL_S0) && !defined (GAMEDLL_S1) bhit_zbuffer = ConVar::Create("bhit_zbuffer" , "1", FCVAR_DEVELOPMENTONLY | FCVAR_REPLICATED, "Use z-buffer 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.", 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 //------------------------------------------------------------------------- // CLIENT | diff --git a/r5dev/vstdlib/callback.cpp b/r5dev/vstdlib/callback.cpp index ef85352a..21ec43bd 100644 --- a/r5dev/vstdlib/callback.cpp +++ b/r5dev/vstdlib/callback.cpp @@ -1148,31 +1148,35 @@ void BHit_f(const CCommand& args) if (args.ArgC() != 9) return; - if (!bhit_enable->GetBool() && !sv_visualizetraces->GetBool()) + if (!bhit_enable->GetBool()) return; - Vector3D vecAbsStart; - Vector3D vecAbsEnd; + if (sv_visualizetraces->GetBool()) + { + Vector3D vecAbsStart; + Vector3D vecAbsEnd; - for (int i = 0; i < 3; ++i) - vecAbsStart[i] = atof(args[i + 4]); + for (int i = 0; i < 3; ++i) + vecAbsStart[i] = atof(args[i + 4]); - QAngle vecBulletAngles; - for (int i = 0; i < 2; ++i) - vecBulletAngles[i] = atof(args[i + 7]); + QAngle vecBulletAngles; + for (int i = 0; i < 2; ++i) + vecBulletAngles[i] = atof(args[i + 7]); - vecBulletAngles.z = 180.f; // Flipped axis. - AngleVectors(vecBulletAngles, &vecAbsEnd); + vecBulletAngles.z = 180.f; // Flipped axis. + AngleVectors(vecBulletAngles, &vecAbsEnd); - vecAbsEnd.MulAdd(vecAbsStart, vecAbsEnd, MAX_COORD_RANGE); + vecAbsEnd.MulAdd(vecAbsStart, vecAbsEnd, MAX_COORD_RANGE); - Ray_t ray(vecAbsStart, vecAbsEnd); - trace_t trace; + Ray_t ray(vecAbsStart, vecAbsEnd); + trace_t trace; - g_pEngineTraceServer->TraceRay(ray, TRACE_MASK_NPCWORLDSTATIC, &trace); + 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_zbuffer->GetBool(), sv_visualizetraces_duration->GetFloat()); + g_pDebugOverlay->AddLineOverlay(trace.endpos, vecAbsEnd, 255, 0, 0, bhit_zbuffer->GetBool(), sv_visualizetraces_duration->GetFloat()); + + } if (bhit_abs_origin->GetBool() && r_visualizetraces->GetBool()) {