diff options
Diffstat (limited to 'src/game/bg_pmove.c')
-rw-r--r-- | src/game/bg_pmove.c | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/src/game/bg_pmove.c b/src/game/bg_pmove.c index 8cad84fe..25746f9b 100644 --- a/src/game/bg_pmove.c +++ b/src/game/bg_pmove.c @@ -1815,7 +1815,6 @@ static void PM_GroundTraceMissed( void ) pml.walking = qfalse; } - /* ============= PM_GroundClimbTrace @@ -1833,7 +1832,7 @@ static void PM_GroundClimbTrace( void ) //used for delta correction vec3_t traceCROSSsurf, traceCROSSref, surfCROSSref; float traceDOTsurf, traceDOTref, surfDOTref, rTtDOTrTsTt; - float traceANGref, surfANGref; + float traceANGsurf, traceANGref, surfANGref; vec3_t horizontal = { 1.0f, 0.0f, 0.0f }; //arbituary vector perpendicular to refNormal vec3_t refTOtrace, refTOsurfTOtrace, tempVec; int rTtANGrTsTt; @@ -1910,7 +1909,7 @@ static void PM_GroundClimbTrace( void ) 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.0f && !( trace.surfaceFlags & ( SURF_SKY | SURF_SLICK ) ) ) { @@ -1921,7 +1920,7 @@ static void PM_GroundClimbTrace( void ) VectorCopy( trace.endpos, pm->ps->origin ); } - + //calculate a bunch of stuff... CrossProduct( trace.plane.normal, surfNormal, traceCROSSsurf ); VectorNormalize( traceCROSSsurf ); @@ -1934,6 +1933,10 @@ static void PM_GroundClimbTrace( void ) //calculate angle between surf and trace traceDOTsurf = DotProduct( trace.plane.normal, surfNormal ); + traceANGsurf = RAD2DEG( acos( traceDOTsurf ) ); + + if( traceANGsurf > 180.0f ) + traceANGsurf -= 180.0f; //calculate angle between trace and ref traceDOTref = DotProduct( trace.plane.normal, refNormal ); @@ -1965,6 +1968,7 @@ static void PM_GroundClimbTrace( void ) //calculate reference rotated through to surf plane then to trace plane RotatePointAroundVector( tempVec, surfCROSSref, horizontal, -surfANGref ); + RotatePointAroundVector( refTOsurfTOtrace, traceCROSSsurf, tempVec, -traceANGsurf ); //calculate angle between refTOtrace and refTOsurfTOtrace rTtDOTrTsTt = DotProduct( refTOtrace, refTOsurfTOtrace ); @@ -1990,6 +1994,10 @@ static void PM_GroundClimbTrace( void ) //construct a point representing where the player is looking VectorAdd( pm->ps->origin, lookdir, point ); + //check whether point is on one side of the plane, if so invert the correction angle + if( ( abc[ 0 ] * point[ 0 ] + abc[ 1 ] * point[ 1 ] + abc[ 2 ] * point[ 2 ] - d ) > 0 ) + traceANGsurf = -traceANGsurf; + //find the . product of the lookdir and traceCROSSsurf if( ( ldDOTtCs = DotProduct( lookdir, traceCROSSsurf ) ) < 0.0f ) { @@ -1997,6 +2005,15 @@ static void PM_GroundClimbTrace( void ) ldDOTtCs = DotProduct( lookdir, traceCROSSsurf ); } + //set the correction angle + traceANGsurf *= 1.0f - ldDOTtCs; + + if( !( pm->ps->persistant[ PERS_STATE ] & PS_WALLCLIMBINGFOLLOW ) ) + { + //correct the angle + pm->ps->delta_angles[ PITCH ] -= ANGLE2SHORT( traceANGsurf ); + } + //transition from wall to ceiling //normal for subsequent viewangle rotations if( VectorCompare( trace.plane.normal, ceilingNormal ) ) @@ -2029,7 +2046,7 @@ static void PM_GroundClimbTrace( void ) VectorCopy( trace.plane.normal, pm->ps->grapplePoint ); pm->ps->stats[ STAT_STATE ] &= ~SS_WALLCLIMBINGCEILING; } - + //IMPORTANT: break out of the for loop if we've hit something break; } @@ -2087,7 +2104,6 @@ static void PM_GroundClimbTrace( void ) PM_AddTouchEnt( trace.entityNum ); } - /* ============= PM_GroundTrace @@ -3601,7 +3617,7 @@ void PmoveSingle( pmove_t *pmove ) PM_WaterEvents( ); // snap some parts of playerstate to save network bandwidth - trap_SnapVector( pm->ps->velocity ); + SnapVector( pm->ps->velocity ); } |