summaryrefslogtreecommitdiff
path: root/src/game
diff options
context:
space:
mode:
Diffstat (limited to 'src/game')
-rw-r--r--src/game/physics/movement.cpp14
-rw-r--r--src/game/world/trace.cpp13
2 files changed, 23 insertions, 4 deletions
diff --git a/src/game/physics/movement.cpp b/src/game/physics/movement.cpp
index 61b1cc4..fce9d73 100644
--- a/src/game/physics/movement.cpp
+++ b/src/game/physics/movement.cpp
@@ -291,7 +291,7 @@ void gmove_check_stuck( VEC3* in_pos ) {
gmove->unstuck_vel = { 0, 0, 1.f };
bsp_trace( &t, gmove->bsp, gmove->aabb, pos, pos );
- if( !t.hit ) {
+ if( !t.hit || !t.startsolid ) {
if( vec_len( gmove->velocity ) > 1.f ) {
gmove->unstuck_pos = pos;
gmove->unstuck_vel = gmove->velocity;
@@ -299,6 +299,18 @@ void gmove_check_stuck( VEC3* in_pos ) {
return;
}
+ for( U32 i = 0; i < 3; ++i ) {
+ VEC3 dir = vec3_axis[i];
+ VEC3 nudge = pos + dir;
+ bsp_trace( &t, gmove->bsp, gmove->aabb, pos, nudge );
+ if( !t.hit || !t.startsolid )
+ return; // not actually stuck, just somewhat inside a solid
+
+ nudge = pos + dir * -1.f;
+ if( !t.hit || !t.startsolid )
+ return;
+ }
+
VEC3 p1 = pos;
defer( {
if( !t.hit ) {
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 )