summaryrefslogtreecommitdiff
path: root/src/cgame
diff options
context:
space:
mode:
authorTim Angus <tim@ngus.net>2002-01-26 02:09:28 +0000
committerTim Angus <tim@ngus.net>2002-01-26 02:09:28 +0000
commit5f93de9200093106f94d38de33f4ba88ef6d3471 (patch)
treee8dd6178f55f1e6979caf902e4a9a69b8efcbaac /src/cgame
parent69d8824059eb08ce5fa8a21801b037dcc6bacb3f (diff)
Stepping filter for WW
Diffstat (limited to 'src/cgame')
-rw-r--r--src/cgame/cg_event.c79
-rw-r--r--src/cgame/cg_view.c59
2 files changed, 92 insertions, 46 deletions
diff --git a/src/cgame/cg_event.c b/src/cgame/cg_event.c
index 1da5612c..06cd169e 100644
--- a/src/cgame/cg_event.c
+++ b/src/cgame/cg_event.c
@@ -581,41 +581,56 @@ void CG_EntityEvent( centity_t *cent, vec3_t position )
}
break;
- case EV_STEP_4:
- case EV_STEP_8:
- case EV_STEP_12:
- case EV_STEP_16: // smooth out step up transitions
- DEBUGNAME("EV_STEP");
- {
- float oldStep;
- int delta;
- int step;
+ case EV_STEP_4:
+ case EV_STEP_8:
+ case EV_STEP_12:
+ case EV_STEP_16: // smooth out step up transitions
+ case EV_STEPDN_4:
+ case EV_STEPDN_8:
+ case EV_STEPDN_12:
+ case EV_STEPDN_16: // smooth out step up transitions
+ DEBUGNAME("EV_STEP");
+ {
+ float oldStep;
+ int delta;
+ int step;
+
+ if( clientNum != cg.predictedPlayerState.clientNum )
+ break;
+
+ // if we are interpolating, we don't need to smooth steps
+ if( cg.demoPlayback || ( cg.snap->ps.pm_flags & PMF_FOLLOW ) ||
+ cg_nopredict.integer || cg_synchronousClients.integer )
+ break;
+
+ // check for stepping up before a previous step is completed
+ delta = cg.time - cg.stepTime;
+
+ if( delta < STEP_TIME )
+ oldStep = cg.stepChange * ( STEP_TIME - delta ) / STEP_TIME;
+ else
+ oldStep = 0;
- if ( clientNum != cg.predictedPlayerState.clientNum ) {
- break;
- }
- // if we are interpolating, we don't need to smooth steps
- if ( cg.demoPlayback || (cg.snap->ps.pm_flags & PMF_FOLLOW) ||
- cg_nopredict.integer || cg_synchronousClients.integer ) {
- break;
- }
- // check for stepping up before a previous step is completed
- delta = cg.time - cg.stepTime;
- if (delta < steptime) {
- oldStep = cg.stepChange * (steptime - delta) / steptime;
- } else {
- oldStep = 0;
+ // add this amount
+ if( event >= EV_STEPDN_4 )
+ {
+ step = 4 * ( event - EV_STEPDN_4 + 1 );
+ cg.stepChange = oldStep - step;
}
-
- // add this amount
- step = 4 * (event - EV_STEP_4 + 1 );
- cg.stepChange = oldStep + step;
- if ( cg.stepChange > MAX_STEP_CHANGE ) {
- cg.stepChange = MAX_STEP_CHANGE;
+ else
+ {
+ step = 4 * ( event - EV_STEP_4 + 1 );
+ cg.stepChange = oldStep + step;
}
- cg.stepTime = cg.time;
- break;
- }
+
+ if( cg.stepChange > MAX_STEP_CHANGE )
+ cg.stepChange = MAX_STEP_CHANGE;
+ else if( cg.stepChange < -MAX_STEP_CHANGE )
+ cg.stepChange = -MAX_STEP_CHANGE;
+
+ cg.stepTime = cg.time;
+ break;
+ }
case EV_JUMP_PAD:
DEBUGNAME("EV_JUMP_PAD");
diff --git a/src/cgame/cg_view.c b/src/cgame/cg_view.c
index 46d8d822..ed59c526 100644
--- a/src/cgame/cg_view.c
+++ b/src/cgame/cg_view.c
@@ -292,20 +292,38 @@ static void CG_OffsetThirdPersonView( void ) {
// this causes a compiler bug on mac MrC compiler
-static void CG_StepOffset( void ) {
- int timeDelta;
- int steptime;
-
- steptime = BG_FindSteptimeForClass( cg.predictedPlayerState.stats[ STAT_PCLASS ] );
-
- // smooth out stair climbing
- timeDelta = cg.time - cg.stepTime;
- if ( timeDelta < steptime ) {
- cg.refdef.vieworg[2] -= cg.stepChange
- * (steptime - timeDelta) / steptime;
+static void CG_StepOffset( void )
+{
+ float steptime;
+ int timeDelta;
+ vec3_t normal;
+ playerState_t *ps = &cg.predictedPlayerState;
+
+ if( ps->stats[ STAT_STATE ] & SS_WALLCLIMBING )
+ {
+ if( ps->stats[ STAT_STATE ] & SS_WALLCLIMBINGCEILING )
+ VectorSet( normal, 0.0f, 0.0f, -1.0f );
+ else
+ VectorCopy( ps->grapplePoint, normal );
}
-}
+ else
+ VectorSet( normal, 0.0f, 0.0f, 1.0f );
+
+ steptime = BG_FindSteptimeForClass( ps->stats[ STAT_PCLASS ] );
+
+ // smooth out stair climbing
+ timeDelta = cg.time - cg.stepTime;
+ if( timeDelta < steptime )
+ {
+ float stepChange = cg.stepChange
+ * (steptime - timeDelta) / steptime;
+ if( ps->stats[ STAT_STATE ] & SS_WALLCLIMBING )
+ VectorMA( cg.refdef.vieworg, -stepChange, normal, cg.refdef.vieworg );
+ else
+ cg.refdef.vieworg[2] -= stepChange;
+ }
+}
/*
===============
CG_OffsetFirstPersonView
@@ -323,6 +341,19 @@ static void CG_OffsetFirstPersonView( void ) {
vec3_t predictedVelocity;
int timeDelta;
float bob2;
+ vec3_t normal;
+ playerState_t *ps = &cg.predictedPlayerState;
+
+ if( ps->stats[ STAT_STATE ] & SS_WALLCLIMBING )
+ {
+ if( ps->stats[ STAT_STATE ] & SS_WALLCLIMBINGCEILING )
+ VectorSet( normal, 0.0f, 0.0f, -1.0f );
+ else
+ VectorCopy( ps->grapplePoint, normal );
+ }
+ else
+ VectorSet( normal, 0.0f, 0.0f, 1.0f );
+
if ( cg.snap->ps.pm_type == PM_INTERMISSION ) {
return;
@@ -497,7 +528,7 @@ static void CG_OffsetFirstPersonView( void ) {
// add view height
//TA: when wall climbing the viewheight is not straight up
if( cg.predictedPlayerState.stats[ STAT_STATE ] & SS_WALLCLIMBING )
- VectorMA( origin, cg.predictedPlayerState.viewheight, cg.predictedPlayerState.grapplePoint, origin );
+ VectorMA( origin, ps->viewheight, normal, origin );
else
origin[2] += cg.predictedPlayerState.viewheight;
@@ -516,7 +547,7 @@ static void CG_OffsetFirstPersonView( void ) {
//TA: likewise for bob
if( cg.predictedPlayerState.stats[ STAT_STATE ] & SS_WALLCLIMBING )
- VectorMA( origin, bob, cg.predictedPlayerState.grapplePoint, origin );
+ VectorMA( origin, bob, normal, origin );
else
origin[2] += bob;