diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/cgame/cg_event.c | 79 | ||||
-rw-r--r-- | src/cgame/cg_view.c | 59 | ||||
-rw-r--r-- | src/game/bg_local.h | 5 | ||||
-rw-r--r-- | src/game/bg_misc.c | 9 | ||||
-rw-r--r-- | src/game/bg_pmove.c | 90 | ||||
-rw-r--r-- | src/game/bg_public.h | 5 | ||||
-rw-r--r-- | src/game/bg_slidemove.c | 264 |
7 files changed, 337 insertions, 174 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; diff --git a/src/game/bg_local.h b/src/game/bg_local.h index 790a38df..da4987ac 100644 --- a/src/game/bg_local.h +++ b/src/game/bg_local.h @@ -71,5 +71,6 @@ void PM_AddTouchEnt( int entityNum ); void PM_AddEvent( int newEvent ); qboolean PM_SlideMove( qboolean gravity ); -void PM_StepSlideMove( qboolean gravity ); - +void PM_StepEvent( vec3_t from, vec3_t to, vec3_t normal ); +qboolean PM_StepSlideMove( qboolean gravity, qboolean predictive ); +qboolean PM_PredictStepMove( ); diff --git a/src/game/bg_misc.c b/src/game/bg_misc.c index 2ffb8407..95887e9b 100644 --- a/src/game/bg_misc.c +++ b/src/game/bg_misc.c @@ -369,8 +369,8 @@ buildableAttributes_t bg_buildableList[ ] = { "models/buildables/mgturret/turret_base.md3", "models/buildables/mgturret/turret_barrel.md3", "models/buildables/mgturret/turret_top.md3", 0 }, - { -36, -36, -30 }, //vec3_t mins; - { 36, 36, 30 }, //vec3_t maxs; + { -25, -25, -20 }, //vec3_t mins; + { 25, 25, 20 }, //vec3_t maxs; TR_GRAVITY, //trType_t traj; 0.0, //float bounce; 80, //int buildPoints; @@ -3004,6 +3004,11 @@ char *eventnames[] = { "EV_STEP_12", "EV_STEP_16", + "EV_STEPDN_4", + "EV_STEPDN_8", + "EV_STEPDN_12", + "EV_STEPDN_16", + "EV_FALL_SHORT", "EV_FALL_MEDIUM", "EV_FALL_FAR", diff --git a/src/game/bg_pmove.c b/src/game/bg_pmove.c index ce976a8e..9460600b 100644 --- a/src/game/bg_pmove.c +++ b/src/game/bg_pmove.c @@ -568,7 +568,7 @@ Flying out of the water static void PM_WaterJumpMove( void ) { // waterjump has no control, but falls - PM_StepSlideMove( qtrue ); + PM_StepSlideMove( qtrue, qfalse ); pm->ps->velocity[2] -= pm->ps->gravity * pml.frametime; if (pm->ps->velocity[2] < 0) { @@ -690,7 +690,7 @@ static void PM_FlyMove( void ) { PM_Accelerate (wishdir, wishspeed, pm_flyaccelerate); - PM_StepSlideMove( qfalse ); + PM_StepSlideMove( qfalse, qfalse ); } @@ -756,7 +756,7 @@ static void PM_AirMove( void ) { PM_SlideMove ( qtrue ); #endif - PM_StepSlideMove ( qtrue ); + PM_StepSlideMove ( qtrue, qfalse ); } /* @@ -895,7 +895,7 @@ static void PM_ClimbMove( void ) { return; } - PM_SlideMove( qfalse ); + PM_StepSlideMove( qfalse, qfalse ); } @@ -1018,7 +1018,7 @@ static void PM_WalkMove( void ) { return; } - PM_StepSlideMove( qfalse ); + PM_StepSlideMove( qfalse, qfalse ); //Com_Printf("velocity2 = %1.1f\n", VectorLength(pm->ps->velocity)); @@ -1357,50 +1357,68 @@ static void PM_GroundClimbTrace( void ) VectorNegate( movedir, movedir ); } - - for(i = 0; i <= 3; i++) + for(i = 0; i <= 4; i++) { - switch ( i ) { - case 0: - //trace into direction we are moving - VectorMA( pm->ps->origin, 0.25f, movedir, point ); - pm->trace (&trace, pm->ps->origin, pm->mins, pm->maxs, point, pm->ps->clientNum, pm->tracemask); - break; + case 0: + //we are going to step this frame so skip the transition test + if( PM_PredictStepMove( ) ) + continue; - case 1: - //trace straight down anto "ground" surface - VectorMA( pm->ps->origin, -0.25f, surfNormal, point ); - pm->trace (&trace, pm->ps->origin, pm->mins, pm->maxs, point, pm->ps->clientNum, pm->tracemask); - break; + //trace into direction we are moving + VectorMA( pm->ps->origin, 0.25f, movedir, point ); + pm->trace (&trace, pm->ps->origin, pm->mins, pm->maxs, point, pm->ps->clientNum, pm->tracemask); + break; - case 2: - //trace "underneath" BBOX so we can traverse angles > 180deg - //TA: I can't believe this actually works :0 - its gotta be messing with something - // I would like a better way if one exists... - if( pml.groundPlane != qfalse ) - { - VectorMA( pm->ps->origin, -16.0f, surfNormal, point ); - VectorMA( point, -16.0f, movedir, point ); + case 1: + //trace straight down anto "ground" surface + VectorMA( pm->ps->origin, -0.25f, surfNormal, point ); pm->trace (&trace, pm->ps->origin, pm->mins, pm->maxs, point, pm->ps->clientNum, pm->tracemask); - } - break; + break; - case 3: - //fall back so we don't have to modify PM_GroundTrace too much - VectorCopy( pm->ps->origin, point ); - point[2] = pm->ps->origin[2] - 0.25f; - pm->trace (&trace, pm->ps->origin, pm->mins, pm->maxs, point, pm->ps->clientNum, pm->tracemask); - break; + case 2: + if( pml.groundPlane != qfalse && PM_PredictStepMove( ) ) + { + //step down + VectorMA( pm->ps->origin, -STEPSIZE, surfNormal, point ); + pm->trace( &trace, pm->ps->origin, pm->mins, pm->maxs, point, pm->ps->clientNum, pm->tracemask ); + } + else + continue; + break; + + case 3: + //trace "underneath" BBOX so we can traverse angles > 180deg + if( pml.groundPlane != qfalse ) + { + VectorMA( pm->ps->origin, -16.0f, surfNormal, point ); + VectorMA( point, -16.0f, movedir, point ); + pm->trace (&trace, pm->ps->origin, pm->mins, pm->maxs, point, pm->ps->clientNum, pm->tracemask); + } + else + continue; + break; + + case 4: + //fall back so we don't have to modify PM_GroundTrace too much + VectorCopy( pm->ps->origin, point ); + point[2] = pm->ps->origin[2] - 0.25f; + pm->trace (&trace, pm->ps->origin, pm->mins, pm->maxs, point, pm->ps->clientNum, pm->tracemask); + break; } //if we hit something if( trace.fraction < 1.0 && !( trace.surfaceFlags & ( SURF_SKY | SURF_SLICK ) ) && - !( trace.entityNum != ENTITYNUM_WORLD && i != 3 ) ) + !( trace.entityNum != ENTITYNUM_WORLD && i != 4 ) ) { - if( i == 2 ) + if( i == 2 || i == 3 ) + { + if( i == 2 ) + PM_StepEvent( pm->ps->origin, trace.endpos, surfNormal ); + VectorCopy( trace.endpos, pm->ps->origin ); + } //calculate a bunch of stuff... CrossProduct( trace.plane.normal, surfNormal, traceCROSSsurf ); diff --git a/src/game/bg_public.h b/src/game/bg_public.h index 72a1ae11..793ca64a 100644 --- a/src/game/bg_public.h +++ b/src/game/bg_public.h @@ -468,6 +468,11 @@ typedef enum { EV_STEP_12, EV_STEP_16, + EV_STEPDN_4, + EV_STEPDN_8, + EV_STEPDN_12, + EV_STEPDN_16, + EV_FALL_SHORT, EV_FALL_MEDIUM, EV_FALL_FAR, diff --git a/src/game/bg_slidemove.c b/src/game/bg_slidemove.c index 9f8ce37d..b3ee8fa7 100644 --- a/src/game/bg_slidemove.c +++ b/src/game/bg_slidemove.c @@ -219,99 +219,187 @@ qboolean PM_SlideMove( qboolean gravity ) { /* ================== -PM_StepSlideMove +PM_StepEvent +================== +*/ +void PM_StepEvent( vec3_t from, vec3_t to, vec3_t normal ) +{ + float size; + vec3_t delta, dNormal; + + VectorSubtract( from, to, delta ); + VectorCopy( delta, dNormal ); + VectorNormalize( dNormal ); + + size = DotProduct( normal, dNormal ) * VectorLength( delta ); + + if( size > 0.0f ) + { + if( size > 2.0f ) + { + if( size < 7.0f ) + PM_AddEvent( EV_STEPDN_4 ); + else if( size < 11.0f ) + PM_AddEvent( EV_STEPDN_8 ); + else if( size < 15.0f ) + PM_AddEvent( EV_STEPDN_12 ); + else + PM_AddEvent( EV_STEPDN_16 ); + } + } + else + { + size = fabs( size ); + + if( size > 2.0f ) + { + if( size < 7.0f ) + PM_AddEvent( EV_STEP_4 ); + else if( size < 11.0f ) + PM_AddEvent( EV_STEP_8 ); + else if( size < 15.0f ) + PM_AddEvent( EV_STEP_12 ); + else + PM_AddEvent( EV_STEP_16 ); + } + } + + if( pm->debugLevel ) + Com_Printf( "%i:stepped\n", c_pmove ); +} +/* +================== +PM_StepSlideMove ================== */ -void PM_StepSlideMove( qboolean gravity ) { +qboolean PM_StepSlideMove( qboolean gravity, qboolean predictive ) +{ vec3_t start_o, start_v; vec3_t down_o, down_v; trace_t trace; -// float down_dist, up_dist; -// vec3_t delta, delta2; - vec3_t up, down; - float stepSize; - - VectorCopy (pm->ps->origin, start_o); - VectorCopy (pm->ps->velocity, start_v); - - if ( PM_SlideMove( gravity ) == 0 ) { - return; // we got exactly where we wanted to go first try - } - - VectorCopy(start_o, down); - down[2] -= STEPSIZE; - pm->trace (&trace, start_o, pm->mins, pm->maxs, down, pm->ps->clientNum, pm->tracemask); - VectorSet(up, 0, 0, 1); - // never step up when you still have up velocity - if ( pm->ps->velocity[2] > 0 && (trace.fraction == 1.0 || - DotProduct(trace.plane.normal, up) < 0.7)) { - return; - } - - VectorCopy (pm->ps->origin, down_o); - VectorCopy (pm->ps->velocity, down_v); - - VectorCopy (start_o, up); - up[2] += STEPSIZE; - - // test the player position if they were a stepheight higher - pm->trace (&trace, start_o, pm->mins, pm->maxs, up, pm->ps->clientNum, pm->tracemask); - if ( trace.allsolid ) { - if ( pm->debugLevel ) { - Com_Printf("%i:bend can't step\n", c_pmove); - } - return; // can't step up - } - - stepSize = trace.endpos[2] - start_o[2]; - // try slidemove from this position - VectorCopy (trace.endpos, pm->ps->origin); - VectorCopy (start_v, pm->ps->velocity); - - PM_SlideMove( gravity ); - - // push down the final amount - VectorCopy (pm->ps->origin, down); - down[2] -= stepSize; - pm->trace (&trace, pm->ps->origin, pm->mins, pm->maxs, down, pm->ps->clientNum, pm->tracemask); - if ( !trace.allsolid ) { - VectorCopy (trace.endpos, pm->ps->origin); - } - if ( trace.fraction < 1.0 ) { - PM_ClipVelocity( pm->ps->velocity, trace.plane.normal, pm->ps->velocity, OVERCLIP ); - } + vec3_t normal; + vec3_t step_v, step_vNormal; + vec3_t up, down; + float stepSize; + qboolean stepped = qfalse; + + if( pm->ps->stats[ STAT_STATE ] & SS_WALLCLIMBING ) + { + if( pm->ps->stats[ STAT_STATE ] & SS_WALLCLIMBINGCEILING ) + VectorSet( normal, 0.0f, 0.0f, -1.0f ); + else + VectorCopy( pm->ps->grapplePoint, normal ); + } + else + VectorSet( normal, 0.0f, 0.0f, 1.0f ); + + VectorCopy( pm->ps->origin, start_o ); + VectorCopy( pm->ps->velocity, start_v ); + + if( PM_SlideMove( gravity ) == 0 ) + { + if( pm->ps->stats[ STAT_STATE ] & SS_WALLCLIMBING ) + { + VectorCopy(start_o, down); + VectorMA( down, -STEPSIZE, normal, down ); + pm->trace( &trace, start_o, pm->mins, pm->maxs, down, pm->ps->clientNum, pm->tracemask ); + + //we can step down + if( trace.fraction > 0.01f && trace.fraction < 1.0f && + !trace.allsolid && pml.groundPlane != qfalse ) + { + if( pm->debugLevel ) + Com_Printf( "%d: step down\n", c_pmove ); + + stepped = qtrue; + } + } + } + else + { + VectorCopy( start_o, down ); + VectorMA( down, -STEPSIZE, normal, down ); + pm->trace( &trace, start_o, pm->mins, pm->maxs, down, pm->ps->clientNum, pm->tracemask ); + // never step up when you still have up velocity + if( DotProduct( trace.plane.normal, pm->ps->velocity ) > 0 && + ( trace.fraction == 1.0 || DotProduct( trace.plane.normal, normal ) < 0.7 ) ) + { + return stepped; + } + + VectorCopy( pm->ps->origin, down_o ); + VectorCopy( pm->ps->velocity, down_v ); + + VectorCopy( start_o, up ); + VectorMA( up, STEPSIZE, normal, up ); + + // test the player position if they were a stepheight higher + pm->trace( &trace, start_o, pm->mins, pm->maxs, up, pm->ps->clientNum, pm->tracemask ); + if( trace.allsolid ) + { + if( pm->debugLevel ) + Com_Printf( "%i:bend can't step\n", c_pmove ); + + return stepped; // can't step up + } + + VectorSubtract( trace.endpos, start_o, step_v ); + VectorCopy( step_v, step_vNormal ); + VectorNormalize( step_vNormal ); + + stepSize = DotProduct( normal, step_vNormal ) * VectorLength( step_v ); + // try slidemove from this position + VectorCopy( trace.endpos, pm->ps->origin ); + VectorCopy( start_v, pm->ps->velocity ); + + if( PM_SlideMove( gravity ) == 0 ) + { + if( pm->debugLevel ) + Com_Printf( "%d: step up\n", c_pmove ); + + stepped = qtrue; + } + + // push down the final amount + VectorCopy( pm->ps->origin, down ); + VectorMA( down, -stepSize, normal, down ); + pm->trace( &trace, pm->ps->origin, pm->mins, pm->maxs, down, pm->ps->clientNum, pm->tracemask ); + + if( !trace.allsolid ) + VectorCopy( trace.endpos, pm->ps->origin ); + + if( trace.fraction < 1.0 ) + PM_ClipVelocity( pm->ps->velocity, trace.plane.normal, pm->ps->velocity, OVERCLIP ); + } + + if( !predictive && stepped ) + PM_StepEvent( start_o, pm->ps->origin, normal ); + + return stepped; +} -#if 0 - // if the down trace can trace back to the original position directly, don't step - pm->trace( &trace, pm->ps->origin, pm->mins, pm->maxs, start_o, pm->ps->clientNum, pm->tracemask); - if ( trace.fraction == 1.0 ) { - // use the original move - VectorCopy (down_o, pm->ps->origin); - VectorCopy (down_v, pm->ps->velocity); - if ( pm->debugLevel ) { - Com_Printf("%i:bend\n", c_pmove); - } - } else -#endif - { - // use the step move - float delta; - - delta = pm->ps->origin[2] - start_o[2]; - if ( delta > 2 ) { - if ( delta < 7 ) { - PM_AddEvent( EV_STEP_4 ); - } else if ( delta < 11 ) { - PM_AddEvent( EV_STEP_8 ); - } else if ( delta < 15 ) { - PM_AddEvent( EV_STEP_12 ); - } else { - PM_AddEvent( EV_STEP_16 ); - } - } - if ( pm->debugLevel ) { - Com_Printf("%i:stepped\n", c_pmove); - } - } +/* +================== +PM_PredictStepMove +================== +*/ +qboolean PM_PredictStepMove( ) +{ + vec3_t velocity, origin; + float impactSpeed; + qboolean stepped = qfalse; + + VectorCopy( pm->ps->velocity, velocity ); + VectorCopy( pm->ps->origin, origin ); + impactSpeed = pml.impactSpeed; + + if( PM_StepSlideMove( qfalse, qtrue ) ) + stepped = qtrue; + + VectorCopy( velocity, pm->ps->velocity ); + VectorCopy( origin, pm->ps->origin ); + pml.impactSpeed = impactSpeed; + + return stepped; } |