diff options
Diffstat (limited to 'src/game/physics/movement.cpp')
| -rw-r--r-- | src/game/physics/movement.cpp | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/src/game/physics/movement.cpp b/src/game/physics/movement.cpp index 1e2e973..fce9d73 100644 --- a/src/game/physics/movement.cpp +++ b/src/game/physics/movement.cpp @@ -257,7 +257,7 @@ F32 gmove_try_move( BSP_TRACE* t, VEC3* pos, VEC3* vel ) { F32 dot = vec_dot( *vel, t->normal ); *pos += wishmove * t->frac; // nudge player away from wall - *pos += t->normal * BSP_TRACE_EPSILON * 4.f; + *pos += t->normal * BSP_TRACE_EPSILON; // avoid clipping planes twice // in a rare edge case its possible to get stuck in the plane again after pushing away from it @@ -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 ) { @@ -435,14 +447,11 @@ void gmove_step_move( VEC3 dest, BSP_TRACE* tr ) { VEC3 up = pos, down = pos; VEC3 upvel = vel, downvel = vel; - F32 groundn = 0.f; if( gmove->ground ) { VEC3 ground = pos; ground.z += 2.f; bsp_trace( tr, gmove->bsp, gmove->aabb, pos, ground ); - if( tr->hit ) - groundn = tr->normal.z; } // try moving forward first @@ -504,9 +513,6 @@ void gmove_step_move( VEC3 dest, BSP_TRACE* tr ) { gmove->pos += delta; if( tr->normal.z < 0.99f ) gmove->pos += tr->normal * BSP_TRACE_EPSILON * 2.f; - // hack : moving to a steeper slope, move up a bit to avoid getting stuck in the edge - if( gmove->ground && tr->normal.z < groundn ) - gmove->pos.z += BSP_TRACE_EPSILON; gmove->velocity = upvel; gmove->velocity.z = downvel.z; } |
