From 22fc06498fa4c3d872b36e6da365d32c58b4ec50 Mon Sep 17 00:00:00 2001 From: Kamay Xutax Date: Mon, 15 Jul 2024 23:27:31 +0200 Subject: [PATCH] Fixed bullet diameter hitbox test --- engine/enginetrace.cpp | 8 ++------ engine/host.cpp | 4 ++-- game/client/c_baseanimating.cpp | 4 ---- public/collisionutils.cpp | 9 +++++---- 4 files changed, 9 insertions(+), 16 deletions(-) diff --git a/engine/enginetrace.cpp b/engine/enginetrace.cpp index 54ac243a14..715dc975c3 100644 --- a/engine/enginetrace.cpp +++ b/engine/enginetrace.cpp @@ -470,10 +470,6 @@ bool CEngineTrace::ClipRayToHitboxes( const Ray_t& ray, unsigned int fMask, ICol VectorAdd( ray.m_Start, ray.m_StartOffset, hitboxTrace.startpos ); VectorAdd( hitboxTrace.startpos, ray.m_Delta, hitboxTrace.endpos ); - // At the moment, it has to be a true ray to work with hitboxes - if ( !ray.m_IsRay ) - return false; - // If the hitboxes weren't even tested, then just use the original trace if (!pCollideable->TestHitboxes( ray, fMask, hitboxTrace )) return false; @@ -1348,7 +1344,7 @@ ICollideable *CEngineTraceServer::GetWorldCollideable() //----------------------------------------------------------------------------- void EngineTraceRenderRayCasts() { -#if defined _DEBUG && !defined SWDS +#if defined _DEBUG if( debugrayenable.GetBool() && s_FrameRays.Count() > debugraylimit.GetInt() && !debugrayreset.GetInt() ) { Warning( "m_FrameRays.Count() == %d\n", s_FrameRays.Count() ); @@ -1660,7 +1656,7 @@ CON_COMMAND_EXTERN( ray_bench, RayBench, "Time the rays" ) //----------------------------------------------------------------------------- void CEngineTrace::TraceRay( const Ray_t &ray, unsigned int fMask, ITraceFilter *pTraceFilter, trace_t *pTrace ) { -#if defined _DEBUG && !defined SWDS +#if defined _DEBUG if( debugrayenable.GetBool() ) { s_FrameRays.AddToTail( ray ); diff --git a/engine/host.cpp b/engine/host.cpp index 79ac7610a2..0f1aa28b6e 100644 --- a/engine/host.cpp +++ b/engine/host.cpp @@ -3350,7 +3350,7 @@ void _Host_RunFrame (float time) else { g_ClientGlobalVariables.interpolation_amount = 0.0f; - #ifdef _DEBUG + #ifdef false printf("interpolation amount was %f, corrected to " "fix interpolation issues.\n", cl.m_tickRemainder @@ -3475,7 +3475,7 @@ void _Host_RunFrame (float time) else { g_ClientGlobalVariables.interpolation_amount = 0.0f; -#ifdef _DEBUG +#ifdef false printf("interpolation amount was %f, corrected to " "fix interpolation issues.\n", cl.m_tickRemainder diff --git a/game/client/c_baseanimating.cpp b/game/client/c_baseanimating.cpp index 8fcb517532..69403fd9e5 100644 --- a/game/client/c_baseanimating.cpp +++ b/game/client/c_baseanimating.cpp @@ -5064,10 +5064,6 @@ bool C_BaseAnimating::TestHitboxes( const Ray_t &ray, unsigned int fContentsMask if ( !set || !set->numhitboxes ) return false; - // Use vcollide for box traces. - if ( !ray.m_IsRay ) - return false; - // This *has* to be true for the existing code to function correctly. Assert( ray.m_StartOffset == vec3_origin ); diff --git a/public/collisionutils.cpp b/public/collisionutils.cpp index e451c385ff..973c920dd3 100644 --- a/public/collisionutils.cpp +++ b/public/collisionutils.cpp @@ -1490,9 +1490,10 @@ bool IntersectRayWithOBB( const Ray_t &ray, const matrix3x4_t &matOBBToWorld, VectorSubtract( vecOBBMaxs, vecOBBMins, vecOBBHalfDiagonal ); vecOBBHalfDiagonal *= 0.5f; - float flRadius = vecOBBHalfDiagonal.Length() + ray.m_Extents.Length(); - if ( !IsRayIntersectingSphere( ray.m_Start, ray.m_Delta, vecOBBCenter, flRadius, flTolerance ) ) - return false; + // TODO_ENHANCED: make sphere hitboxes. + // float flRadius = vecOBBHalfDiagonal.Length() + ray.m_Extents.Length(); + // if ( !IsRayIntersectingSphere( ray.m_Start, ray.m_Delta, vecOBBCenter, flRadius, flTolerance ) ) + // return false; // Ok, we passed the trivial reject, so lets do the dirty deed. // Basically we're going to do the GJK thing explicitly. We'll shrink the ray down @@ -1670,7 +1671,7 @@ bool IntersectRayWithOBB( const Ray_t &ray, const matrix3x4_t &matOBBToWorld, } temp.type = 3; - MatrixITransformPlane( matOBBToWorld, temp, pTrace->plane ); + MatrixTransformPlane( matOBBToWorld, temp, pTrace->plane ); return true; }