diff options
Diffstat (limited to 'src/game')
-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 |
5 files changed, 245 insertions, 128 deletions
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; } |