summaryrefslogtreecommitdiff
path: root/src/game/world/trace.cpp
diff options
context:
space:
mode:
authoraura <nw@moneybot.cc>2026-02-27 10:08:07 +0100
committeraura <nw@moneybot.cc>2026-02-27 10:08:07 +0100
commit66561ea2fb7f76c408c08e21132e58914329faba (patch)
treee02e5c7ff51563a35417bdfe70af568db53896f1 /src/game/world/trace.cpp
parentb24f37279bcc4b3abd92b697eadcec1feba8d276 (diff)
more movement
Diffstat (limited to 'src/game/world/trace.cpp')
-rw-r--r--src/game/world/trace.cpp19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/game/world/trace.cpp b/src/game/world/trace.cpp
index ba945f0..1c28d78 100644
--- a/src/game/world/trace.cpp
+++ b/src/game/world/trace.cpp
@@ -1,5 +1,3 @@
-#include <cfloat>
-
#include "trace.h"
#include "../../util/math.h"
#include "bsp.h"
@@ -205,7 +203,7 @@ inline U8 point_in_inflated_poly(
F32 dist = vec_dot( point - a, in );
F32 expand = aabb_support_radius( hull, in );
- if( dist < -( expand - BSP_TRACE_EPSILON * 4.f ) )
+ if( dist < -( expand - BSP_EDGE_TOLERANCE ) )
return 0;
}
return 1;
@@ -393,17 +391,22 @@ U8 bsp_trace( BSP_TRACE* trace, BSP* bsp, AABB hull ) {
VEC3 start = trace->in_start;
VEC3 end = trace->in_end;
- // start hull at origin rather than in middle
- trace->in_start.z += ( hull.max.z - hull.min.z );
- trace->in_end.z += ( hull.max.z - hull.min.z );
+ // move trace up by half of the hull - extend at feet instead of center
+ VEC3 off = VEC3{ 0, 0, hull.max.z - hull.min.z } * 0.5f;
+
+ trace->in_start += off;
+ trace->in_end += off;
U8 ret = bsp_trace_sweep_aabb( trace, bsp, hull, trace->in_start, trace->in_end, bsp->root );
- trace->in_start = start;
- trace->in_end = end;
+ trace->in_start -= off;
+ trace->in_end -= off;
if( !ret )
trace->point = trace->in_end;
+ else
+ trace->point -= off;
+
return ret;
}