diff options
-rw-r--r-- | src/game/bg_misc.c | 10 | ||||
-rw-r--r-- | src/game/bg_pmove.c | 30 | ||||
-rw-r--r-- | src/game/g_cmds.c | 7 | ||||
-rw-r--r-- | src/qcommon/q_shared.h | 10 |
4 files changed, 44 insertions, 13 deletions
diff --git a/src/game/bg_misc.c b/src/game/bg_misc.c index cfdd56b8..3c66bab8 100644 --- a/src/game/bg_misc.c +++ b/src/game/bg_misc.c @@ -5010,8 +5010,9 @@ void BG_PlayerStateToEntityState( playerState_t *ps, entityState_t *s, qboolean s->pos.trType = TR_INTERPOLATE; VectorCopy( ps->origin, s->pos.trBase ); - if( snap ) - SnapVector( s->pos.trBase ); + // Snapping player origins causes more problems than it solves + //if( snap ) + // SnapVector( s->pos.trBase ); //set the trDelta for flag direction VectorCopy( ps->velocity, s->pos.trDelta ); @@ -5115,8 +5116,9 @@ void BG_PlayerStateToEntityStateExtraPolate( playerState_t *ps, entityState_t *s s->pos.trType = TR_LINEAR_STOP; VectorCopy( ps->origin, s->pos.trBase ); - if( snap ) - SnapVector( s->pos.trBase ); + // Snapping player origins causes more problems than it solves + //if( snap ) + // SnapVector( s->pos.trBase ); // set the trDelta for flag direction and linear prediction VectorCopy( ps->velocity, s->pos.trDelta ); 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 ); } diff --git a/src/game/g_cmds.c b/src/game/g_cmds.c index b530af51..e6bc45f2 100644 --- a/src/game/g_cmds.c +++ b/src/game/g_cmds.c @@ -924,7 +924,12 @@ Cmd_Where_f */ void Cmd_Where_f( gentity_t *ent ) { - trap_SendServerCommand( ent-g_entities, va( "print \"%s\n\"", vtos( ent->s.origin ) ) ); + if( !ent->client ) + return; + trap_SendServerCommand( ent - g_entities, + va( "print \"origin: %f %f %f\n\"", + ent->s.origin[ 0 ], ent->s.origin[ 1 ], + ent->s.origin[ 2 ] ) ); } /* diff --git a/src/qcommon/q_shared.h b/src/qcommon/q_shared.h index e23f8725..667fba73 100644 --- a/src/qcommon/q_shared.h +++ b/src/qcommon/q_shared.h @@ -452,7 +452,15 @@ typedef struct { #define Vector4Copy(a,b) ((b)[0]=(a)[0],(b)[1]=(a)[1],(b)[2]=(a)[2],(b)[3]=(a)[3]) #define Vector4Add(a,b,c) ((c)[0]=(a)[0]+(b)[0],(c)[1]=(a)[1]+(b)[1],(c)[2]=(a)[2]+(b)[2],(c)[3]=(a)[3]+(b)[3]) -#define SnapVector(v) {v[0]=((int)(v[0]));v[1]=((int)(v[1]));v[2]=((int)(v[2]));} +// DO NOT USE: Snaps differently depending on whether number is positive or +// negative! -0.5 and 0.5 both snapped to zero! +//#define SnapVector(v) {v[0]=((int)(v[0]));v[1]=((int)(v[1]));v[2]=((int)(v[2]));} + +// Snaps the vector to the floor value always, ignoring any weirdness from +// snapping negative versus positive numbers +#define Floor(f) ( (f) >= 0.f ? (int)(f) : -(int)(-(f)) ) +#define SnapVector(v) {(v)[0]=Floor((v)[0]);(v)[1]=Floor((v)[1]);(v)[2]=Floor((v)[2]);} + // just in case you do't want to use the macros vec_t _DotProduct( const vec3_t v1, const vec3_t v2 ); void _VectorSubtract( const vec3_t veca, const vec3_t vecb, vec3_t out ); |