summaryrefslogtreecommitdiff
path: root/src/game/world
diff options
context:
space:
mode:
authoraura <nw@moneybot.cc>2026-03-04 00:08:05 +0100
committeraura <nw@moneybot.cc>2026-03-04 00:08:05 +0100
commit333b457d30966fceb50fd420a559ae7d0aa3dad6 (patch)
tree3dd81979a101d6d53f19bc2d75ad721dbee51b2c /src/game/world
parent7466c0415415052cda55f02befb720d2a348b6c9 (diff)
minor fix
Diffstat (limited to 'src/game/world')
-rw-r--r--src/game/world/trace.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/game/world/trace.cpp b/src/game/world/trace.cpp
index d962ba3..56d0a4b 100644
--- a/src/game/world/trace.cpp
+++ b/src/game/world/trace.cpp
@@ -236,6 +236,7 @@ U8 bsp_trace_sweep_aabb_to_face(
VEC3 hullv = hull.max - hull.min;
AABB fhull = { face->mins - hullv, face->maxs + hullv };
+ AABB fhullh = { face->mins - hullv * 0.5f, face->maxs + hullv * 0.5f };
VEC3 norm = bsp_face_get_normal( face );
F32 d = vec_dot( norm, face->verts[0].pos );
F32 radius = aabb_support_radius( hull, norm );
@@ -246,15 +247,18 @@ U8 bsp_trace_sweep_aabb_to_face(
VEC3 dirn = vec_normalize( dir );
F32 tdot = vec_dot( dirn, norm );
- if( tdot >= 0 ) // dont collide with rear side
+ if( !isnan( tdot ) && tdot >= 0 ) // dont collide with rear side
return 0;
if( fabsf( s0 ) <= radius + BSP_TRACE_EPSILON ) {
- if( aabb_contains_point( fhull, start ) && point_in_inflated_poly( start, face, hull, norm ) ) {
+ if( aabb_contains_point( fhullh, start ) && point_in_inflated_poly( start, face, hull, norm ) ) {
trace->hit = 1;
trace->frac = 0.f;
trace->startsolid = 1;
trace->point = start;
+ trace->point.x = m_clamp( trace->point.x, fhullh.min.x, fhullh.max.x );
+ trace->point.y = m_clamp( trace->point.y, fhullh.min.y, fhullh.max.y );
+ trace->point.z = m_clamp( trace->point.z, fhullh.min.z, fhullh.max.z );
trace->normal = norm;
trace->propid = face->propid;
trace->faceid = face_idx;
@@ -280,6 +284,10 @@ U8 bsp_trace_sweep_aabb_to_face(
if( !point_in_inflated_poly( step, face, hull, norm ) )
return 0;
+ step.x = m_clamp( step.x, fhullh.min.x, fhullh.max.x );
+ step.y = m_clamp( step.y, fhullh.min.y, fhullh.max.y );
+ step.z = m_clamp( step.z, fhullh.min.z, fhullh.max.z );
+
trace->hit = 1;
trace->frac = t;
trace->point = step;
@@ -340,7 +348,6 @@ U8 bsp_trace_sweep_aabb_to_leaf_edges(
VEC3 proj = e->v1 + edir * m_clamp( along, 0.f, elen );
F32 dist = vec_dist( proj, step );
-
F32 expand = aabb_support_radius( hull, n );
if( dist > BSP_TRACE_EPSILON ) {
if( dist > expand - BSP_EDGE_TOLERANCE )