/* ================== PM_StepSlideMove ================== */ bool PM_StepSlideMove( bool gravity, bool predictive ) { vec3_t start_o, start_v; vec3_t down_o, down_v; trace_t trace; vec3_t normal; vec3_t step_v, step_vNormal; vec3_t up, down; float stepSize; bool stepped = false; 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 ) { 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 != false ) { if( pm->debugLevel ) Com_Printf( "%d: step down\n", c_pmove ); stepped = true; } } 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.0f && ( trace.fraction == 1.0f || DotProduct( trace.plane.normal, normal ) < 0.7f ) ) { 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 = true; } // 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.0f ) 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; }
/* ================== PM_StepSlideMove ================== */ qboolean PM_StepSlideMove( qboolean gravity, qboolean predictive ) { vec3_t start_o, start_v; vec3_t down_o, down_v; trace_t trace; vec3_t normal; vec3_t step_v, step_vNormal; vec3_t up, down; float stepSize; qboolean stepped = qfalse; BG_GetClientNormal( pm->ps, normal ); VectorCopy( pm->ps->origin, start_o ); VectorCopy( pm->ps->velocity, start_v ); if ( PM_SlideMove( gravity ) == 0 ) { 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 > 1 ) { 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.0f && ( trace.fraction == 1.0f || DotProduct( trace.plane.normal, normal ) < 0.7f ) ) { 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 > 1 ) { 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 > 1 ) { 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.0f ) { PM_ClipVelocity( pm->ps->velocity, trace.plane.normal, pm->ps->velocity ); } } if ( !predictive && stepped ) { PM_StepEvent( start_o, pm->ps->origin, normal ); } return stepped; }
/* ================== PM_StepSlideMove ================== */ bool PM_StepSlideMove( bool gravity, bool predictive ) { vec3_t start_o, start_v; #ifndef UNREALARENA vec3_t down_o, down_v; #endif trace_t trace; #ifndef UNREALARENA vec3_t normal; vec3_t step_v, step_vNormal; #endif vec3_t up, down; float stepSize; bool stepped = false; #ifndef UNREALARENA BG_GetClientNormal( pm->ps, normal ); #endif VectorCopy( pm->ps->origin, start_o ); VectorCopy( pm->ps->velocity, start_v ); if ( !PM_SlideMove( gravity ) ) { #ifdef UNREALARENA return stepped; // we got exactly where we wanted to go first try #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, 0 ); //we can step down if ( trace.fraction > 0.01f && trace.fraction < 1.0f && !trace.allsolid && pml.groundPlane ) { if ( pm->debugLevel > 1 ) { Log::Notice( "%d: step down\n", c_pmove ); } stepped = true; } #endif } else { VectorCopy( start_o, down ); #ifdef UNREALARENA down[ 2 ] -= STEPSIZE; #else VectorMA( down, -STEPSIZE, normal, down ); #endif pm->trace( &trace, start_o, pm->mins, pm->maxs, down, pm->ps->clientNum, pm->tracemask, 0 ); #ifdef UNREALARENA VectorSet( up, 0.0f, 0.0f, 1.0f ); #endif // never step up when you still have up velocity #ifdef UNREALARENA if ( pm->ps->velocity[ 2 ] > 0.0f && ( trace.fraction == 1.0f || DotProduct( trace.plane.normal, up ) < 0.7f ) ) #else if ( DotProduct( trace.plane.normal, pm->ps->velocity ) > 0.0f && ( trace.fraction == 1.0f || DotProduct( trace.plane.normal, normal ) < 0.7f ) ) #endif { return stepped; } #ifndef UNREALARENA // never step up when flying upwards with the jetpack if ( pm->ps->velocity[ 2 ] > 0.0f && ( pm->ps->stats[ STAT_STATE2 ] & SS2_JETPACK_ACTIVE ) ) { return stepped; } VectorCopy( pm->ps->origin, down_o ); VectorCopy( pm->ps->velocity, down_v ); #endif VectorCopy( start_o, up ); #ifdef UNREALARENA up[ 2 ] += STEPSIZE; #else VectorMA( up, STEPSIZE, normal, up ); #endif // 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, 0 ); if ( trace.allsolid ) { if ( pm->debugLevel > 1 ) { Log::Notice( "%i:bend can't step\n", c_pmove ); } return stepped; // can't step up } #ifdef UNREALARENA stepSize = trace.endpos[ 2 ] - start_o[ 2 ]; // if the new position is falling then do nothing if ( PM_CheckFallingFromLedge( trace.endpos ) ) { VectorCopy( start_o, pm->ps->origin ); return stepped; } #else VectorSubtract( trace.endpos, start_o, step_v ); VectorCopy( step_v, step_vNormal ); VectorNormalize( step_vNormal ); stepSize = DotProduct( normal, step_vNormal ) * VectorLength( step_v ); #endif // try slidemove from this position VectorCopy( trace.endpos, pm->ps->origin ); VectorCopy( start_v, pm->ps->velocity ); #ifdef UNREALARENA PM_SlideMove( gravity, stepSize ); #else if ( PM_SlideMove( gravity ) == 0 ) { if ( pm->debugLevel > 1 ) { Log::Notice( "%d: step up\n", c_pmove ); } stepped = true; } #endif // push down the final amount VectorCopy( pm->ps->origin, down ); #ifdef UNREALARENA down[ 2 ] -= stepSize; #else VectorMA( down, -stepSize, normal, down ); #endif pm->trace( &trace, pm->ps->origin, pm->mins, pm->maxs, down, pm->ps->clientNum, pm->tracemask, 0 ); if ( !trace.allsolid ) { #ifdef UNREALARENA // if the new position is falling then do nothing if ( PM_CheckFallingFromLedge( trace.endpos ) ) { VectorCopy( start_o, pm->ps->origin ); return stepped; } #endif VectorCopy( trace.endpos, pm->ps->origin ); } if ( trace.fraction < 1.0f ) { PM_ClipVelocity( pm->ps->velocity, trace.plane.normal, pm->ps->velocity ); } } #ifdef UNREALARENA if ( !predictive ) { stepped = true; // use the step move float delta; delta = pm->ps->origin[ 2 ] - start_o[ 2 ]; if ( delta > 2.0f ) { if ( delta < 7.0f ) { PM_AddEvent( EV_STEP_4 ); } else if ( delta < 11.0f ) { PM_AddEvent( EV_STEP_8 ); } else if ( delta < 15.0f ) { PM_AddEvent( EV_STEP_12 ); } else { PM_AddEvent( EV_STEP_16 ); } } if ( pm->debugLevel > 1 ) { Log::Notice( "%i:stepped\n", c_pmove ); } } #else if ( !predictive && stepped ) { PM_StepEvent( start_o, pm->ps->origin, normal ); } #endif return stepped; }