summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author/dev/humancontroller <devhc@example.com>2014-07-13 19:30:20 +0200
committer/dev/humancontroller <devhc@example.com>2017-03-09 13:51:14 +0100
commit070a12bff30c69b104edb0e9586df4eff9a75fc1 (patch)
treea985f381927d803d2bfc640ee754ed31fa98cd0c
parent11dd8874c42785feaf020679320ae9de7e226adb (diff)
do not overclip
-rw-r--r--src/game/bg_local.h4
-rw-r--r--src/game/bg_pmove.c48
-rw-r--r--src/game/bg_slidemove.c13
3 files changed, 19 insertions, 46 deletions
diff --git a/src/game/bg_local.h b/src/game/bg_local.h
index 200ad9b2..38874b5a 100644
--- a/src/game/bg_local.h
+++ b/src/game/bg_local.h
@@ -31,8 +31,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#define TIMER_GESTURE (34*66+50)
#define TIMER_ATTACK 500 //nonsegmented models
-#define OVERCLIP 1.001f
-
#define FALLING_THRESHOLD -900.0f //what vertical speed to start falling sound at
@@ -77,7 +75,7 @@ extern float pm_spectatorfriction;
extern int c_pmove;
-void PM_ClipVelocity( vec3_t in, vec3_t normal, vec3_t out, float overbounce );
+void PM_ClipVelocity( vec3_t in, vec3_t normal, vec3_t out );
void PM_AddTouchEnt( int entityNum );
void PM_AddEvent( int newEvent );
diff --git a/src/game/bg_pmove.c b/src/game/bg_pmove.c
index 2590b4cd..894d7faa 100644
--- a/src/game/bg_pmove.c
+++ b/src/game/bg_pmove.c
@@ -217,29 +217,10 @@ PM_ClipVelocity
Slide off of the impacting surface
==================
*/
-void PM_ClipVelocity( vec3_t in, vec3_t normal, vec3_t out, float overbounce )
+void PM_ClipVelocity( vec3_t in, vec3_t normal, vec3_t out )
{
- float backoff;
- float change;
- int i;
-
- backoff = DotProduct( in, normal );
-
- //Com_Printf( "%1.0f ", backoff );
-
- if( backoff < 0 )
- backoff *= overbounce;
- else
- backoff /= overbounce;
-
- for( i = 0; i < 3; i++ )
- {
- change = normal[ i ] * backoff;
- //Com_Printf( "%1.0f ", change );
- out[ i ] = in[ i ] - change;
- }
-
- //Com_Printf( " " );
+ float t = -DotProduct( in, normal );
+ VectorMA( in, t, normal, out );
}
@@ -1096,8 +1077,7 @@ static void PM_WaterMove( void )
{
vel = VectorLength( pm->ps->velocity );
// slide along the ground plane
- PM_ClipVelocity( pm->ps->velocity, pml.groundTrace.plane.normal,
- pm->ps->velocity, OVERCLIP );
+ PM_ClipVelocity( pm->ps->velocity, pml.groundTrace.plane.normal, pm->ps->velocity );
VectorNormalize( pm->ps->velocity );
VectorScale( pm->ps->velocity, vel, pm->ps->velocity );
@@ -1249,8 +1229,7 @@ static void PM_AirMove( void )
// though we don't have a groundentity
// slide along the steep plane
if( pml.groundPlane )
- PM_ClipVelocity( pm->ps->velocity, pml.groundTrace.plane.normal,
- pm->ps->velocity, OVERCLIP );
+ PM_ClipVelocity( pm->ps->velocity, pml.groundTrace.plane.normal, pm->ps->velocity );
PM_StepSlideMove( qtrue, qfalse );
}
@@ -1304,8 +1283,8 @@ static void PM_ClimbMove( void )
PM_SetMovementDir( );
// project the forward and right directions onto the ground plane
- PM_ClipVelocity( pml.forward, pml.groundTrace.plane.normal, pml.forward, OVERCLIP );
- PM_ClipVelocity( pml.right, pml.groundTrace.plane.normal, pml.right, OVERCLIP );
+ PM_ClipVelocity( pml.forward, pml.groundTrace.plane.normal, pml.forward );
+ PM_ClipVelocity( pml.right, pml.groundTrace.plane.normal, pml.right );
//
VectorNormalize( pml.forward );
VectorNormalize( pml.right );
@@ -1353,8 +1332,7 @@ static void PM_ClimbMove( void )
vel = VectorLength( pm->ps->velocity );
// slide along the ground plane
- PM_ClipVelocity( pm->ps->velocity, pml.groundTrace.plane.normal,
- pm->ps->velocity, OVERCLIP );
+ PM_ClipVelocity( pm->ps->velocity, pml.groundTrace.plane.normal, pm->ps->velocity );
// don't decrease velocity when going up or down a slope
VectorNormalize( pm->ps->velocity );
@@ -1422,8 +1400,8 @@ static void PM_WalkMove( void )
pml.right[ 2 ] = 0;
// project the forward and right directions onto the ground plane
- PM_ClipVelocity( pml.forward, pml.groundTrace.plane.normal, pml.forward, OVERCLIP );
- PM_ClipVelocity( pml.right, pml.groundTrace.plane.normal, pml.right, OVERCLIP );
+ PM_ClipVelocity( pml.forward, pml.groundTrace.plane.normal, pml.forward );
+ PM_ClipVelocity( pml.right, pml.groundTrace.plane.normal, pml.right );
//
VectorNormalize( pml.forward );
VectorNormalize( pml.right );
@@ -1477,8 +1455,7 @@ static void PM_WalkMove( void )
}
// slide along the ground plane
- PM_ClipVelocity( pm->ps->velocity, pml.groundTrace.plane.normal,
- pm->ps->velocity, OVERCLIP );
+ PM_ClipVelocity( pm->ps->velocity, pml.groundTrace.plane.normal, pm->ps->velocity );
// don't do anything if standing still
if( !pm->ps->velocity[ 0 ] && !pm->ps->velocity[ 1 ] )
@@ -1530,8 +1507,7 @@ static void PM_LadderMove( void )
vel = VectorLength( pm->ps->velocity );
// slide along the ground plane
- PM_ClipVelocity( pm->ps->velocity, pml.groundTrace.plane.normal,
- pm->ps->velocity, OVERCLIP );
+ PM_ClipVelocity( pm->ps->velocity, pml.groundTrace.plane.normal, pm->ps->velocity );
VectorNormalize( pm->ps->velocity );
VectorScale( pm->ps->velocity, vel, pm->ps->velocity );
diff --git a/src/game/bg_slidemove.c b/src/game/bg_slidemove.c
index f396ba66..cd770589 100644
--- a/src/game/bg_slidemove.c
+++ b/src/game/bg_slidemove.c
@@ -74,8 +74,7 @@ qboolean PM_SlideMove( qboolean gravity )
if( pml.groundPlane )
{
// slide along the ground plane
- PM_ClipVelocity( pm->ps->velocity, pml.groundTrace.plane.normal,
- pm->ps->velocity, OVERCLIP );
+ PM_ClipVelocity( pm->ps->velocity, pml.groundTrace.plane.normal, pm->ps->velocity );
}
}
@@ -166,10 +165,10 @@ qboolean PM_SlideMove( qboolean gravity )
pml.impactSpeed = -into;
// slide along the plane
- PM_ClipVelocity( pm->ps->velocity, planes[ i ], clipVelocity, OVERCLIP );
+ PM_ClipVelocity( pm->ps->velocity, planes[ i ], clipVelocity );
// slide along the plane
- PM_ClipVelocity( endVelocity, planes[ i ], endClipVelocity, OVERCLIP );
+ PM_ClipVelocity( endVelocity, planes[ i ], endClipVelocity );
// see if there is a second plane that the new move enters
for( j = 0; j < numplanes; j++ )
@@ -181,8 +180,8 @@ qboolean PM_SlideMove( qboolean gravity )
continue; // move doesn't interact with the plane
// try clipping the move to the plane
- PM_ClipVelocity( clipVelocity, planes[ j ], clipVelocity, OVERCLIP );
- PM_ClipVelocity( endClipVelocity, planes[ j ], endClipVelocity, OVERCLIP );
+ PM_ClipVelocity( clipVelocity, planes[ j ], clipVelocity );
+ PM_ClipVelocity( endClipVelocity, planes[ j ], endClipVelocity );
// see if it goes back into the first clip plane
if( DotProduct( clipVelocity, planes[ i ] ) >= 0 )
@@ -369,7 +368,7 @@ qboolean PM_StepSlideMove( qboolean gravity, qboolean predictive )
VectorCopy( trace.endpos, pm->ps->origin );
if( trace.fraction < 1.0f )
- PM_ClipVelocity( pm->ps->velocity, trace.plane.normal, pm->ps->velocity, OVERCLIP );
+ PM_ClipVelocity( pm->ps->velocity, trace.plane.normal, pm->ps->velocity );
}
if( !predictive && stepped )