diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/cgame/cg_local.h | 5 | ||||
-rw-r--r-- | src/cgame/cg_view.c | 48 | ||||
-rw-r--r-- | src/game/bg_misc.c | 16 | ||||
-rw-r--r-- | src/game/bg_pmove.c | 106 |
4 files changed, 98 insertions, 77 deletions
diff --git a/src/cgame/cg_local.h b/src/cgame/cg_local.h index 77c8ec13..0a672504 100644 --- a/src/cgame/cg_local.h +++ b/src/cgame/cg_local.h @@ -444,9 +444,7 @@ typedef struct { typedef struct { float time; - - vec3_t rotAxis; - float rotAngle; + vec3_t deltaAngles; } smooth_t; #define MAX_REWARDSTACK 10 @@ -657,6 +655,7 @@ typedef struct { qboolean weapon2Firing; vec3_t lastNormal; //TA: view smoothage + vec3_t lastVangles; //TA: view smoothage smooth_t sList[ MAXSMOOTHS ]; //TA: WW smoothing } cg_t; diff --git a/src/cgame/cg_view.c b/src/cgame/cg_view.c index 6608b21e..e940698f 100644 --- a/src/cgame/cg_view.c +++ b/src/cgame/cg_view.c @@ -758,7 +758,7 @@ static void CG_DrawSurfNormal( void ) CG_addSmoothOp =============== */ -static void CG_addSmoothOp( vec3_t rotAxis, float rotAngle ) +static void CG_addSmoothOp( vec3_t deltaAngles ) { int i; @@ -769,8 +769,7 @@ static void CG_addSmoothOp( vec3_t rotAxis, float rotAngle ) if( cg.sList[ i ].time + cg_smoothTime.integer < cg.time ) { //copy to array and stop - VectorCopy( rotAxis, cg.sList[ i ].rotAxis ); - cg.sList[ i ].rotAngle = rotAngle; + VectorCopy( deltaAngles, cg.sList[ i ].deltaAngles ); cg.sList[ i ].time = cg.time; return; } @@ -786,11 +785,8 @@ CG_smoothWWTransitions */ static void CG_smoothWWTransitions( playerState_t *ps, const vec3_t in, vec3_t out ) { - vec3_t rotAxis, surfNormal; - vec3_t refNormal = { 0.0f, 0.0f, 1.0f }; + vec3_t deltaAngles, surfNormal, inLocal; vec3_t ceilingNormal = { 0.0f, 0.0f, -1.0f }; - float rotAngle; - vec3_t inAxis[ 3 ], outAxis[ 3 ]; int i; float stLocal, sFraction; qboolean performed = qfalse; @@ -801,56 +797,50 @@ static void CG_smoothWWTransitions( playerState_t *ps, const vec3_t in, vec3_t o else VectorCopy( ceilingNormal, surfNormal ); - AnglesToAxis( in, inAxis ); + VectorCopy( in, inLocal ); //if we are moving from one surface to another smooth the transition if( !VectorCompare( surfNormal, cg.lastNormal ) ) { - //if we moving from the ceiling to the floor special case - //( x product of colinear vectors is undefined) - if( VectorCompare( ceilingNormal, cg.lastNormal ) && - VectorCompare( refNormal, surfNormal ) ) - { - AngleVectors( in, NULL, rotAxis, NULL ); - rotAngle = 180.0f; - } - else + VectorSubtract( in, cg.lastVangles, deltaAngles ); + + //normalise + for( i = 0; i < 3; i++ ) { - CrossProduct( cg.lastNormal, surfNormal, rotAxis ); - VectorNormalize( rotAxis ); - rotAngle = abs( RAD2DEG( acos( DotProduct( cg.lastNormal, surfNormal ) ) ) ); + while( deltaAngles[ i ] < -180.0f ) + deltaAngles[ i ] += 360.0f; + + while( deltaAngles[ i ] > 180.0f ) + deltaAngles[ i ] -= 360.0f; } //add the op - CG_addSmoothOp( rotAxis, rotAngle ); + CG_addSmoothOp( deltaAngles ); } //iterate through ops for( i = 0; i < MAXSMOOTHS; i++ ) { //if this op has time remaining, perform it - if( ( cg.time < cg.sList[ i ].time + cg_smoothTime.integer ) && VectorLength( cg.sList[ i ].rotAxis ) ) + if( cg.time < cg.sList[ i ].time + cg_smoothTime.integer ) { stLocal = 1.0 - ( ( ( cg.sList[ i ].time + cg_smoothTime.integer ) - cg.time ) / cg_smoothTime.integer ); sFraction = -( cos( stLocal * M_PI ) + 1 ) / 2; - RotatePointAroundVector( outAxis[ 0 ], cg.sList[ i ].rotAxis, inAxis[ 0 ], sFraction * cg.sList[ i ].rotAngle ); - RotatePointAroundVector( outAxis[ 1 ], cg.sList[ i ].rotAxis, inAxis[ 1 ], sFraction * cg.sList[ i ].rotAngle ); - RotatePointAroundVector( outAxis[ 2 ], cg.sList[ i ].rotAxis, inAxis[ 2 ], sFraction * cg.sList[ i ].rotAngle ); + VectorMA( inLocal, sFraction, cg.sList[ i ].deltaAngles, out ); - AxisCopy( outAxis, inAxis ); + VectorCopy( out, inLocal ); performed = qtrue; } } //if we performed any ops then return the smoothed angles //otherwise simply return the in angles - if( performed ) - AxisToAngles( outAxis, out ); - else + if( !performed ) VectorCopy( in, out ); //copy the current normal to the lastNormal + VectorCopy( in, cg.lastVangles ); VectorCopy( surfNormal, cg.lastNormal ); } diff --git a/src/game/bg_misc.c b/src/game/bg_misc.c index 6cfd5dd7..a3acc451 100644 --- a/src/game/bg_misc.c +++ b/src/game/bg_misc.c @@ -792,7 +792,7 @@ TA: droid spawn item { "team_droid_spawn", "sound/items/holdable.wav", - { "models/bitems/aspawn.md3", 0, 0, 0 }, + { "models/buildables/bioegg/bioegg.md3", 0, 0, 0 }, "icons/teleporter", //icon "Droid Spawn", //pickup 0, @@ -808,7 +808,7 @@ TA: droid defense item { "team_droid_def1", "sound/items/holdable.wav", - { "models/bitems/adef1.md3", 0, 0, 0 }, + { "models/buildables/defense1/defense1.md3", 0, 0, 0 }, "icons/teleporter", //icon "Droid Defense", //pickup 0, @@ -824,7 +824,7 @@ TA: droid defense item { "team_droid_def2", "sound/items/holdable.wav", - { "models/bitems/adef1.md3", 0, 0, 0 }, + { "models/buildables/sawbladel/sawbladel.md3", 0, 0, 0 }, "icons/teleporter", //icon "Droid Sawblade Launcher", //pickup 0, @@ -840,7 +840,7 @@ TA: droid build limitation item { "team_droid_hivemind", "sound/items/holdable.wav", - { "models/powerups/instant/invis.md3", 0, 0, 0 }, + { "models/buildables/hivemind/hivemind.md3", 0, 0, 0 }, "icons/teleporter", //icon "Droid Hivemind", //pickup 0, @@ -856,7 +856,7 @@ TA: human spawn item { "team_human_spawn", "sound/items/holdable.wav", - { "models/bitems/hspawn.md3", 0, 0, 0 }, + { "models/buildables/replicator/replicator.md3", 0, 0, 0 }, "icons/teleporter", //icon "Human Spawn", //pickup 0, @@ -872,7 +872,7 @@ TA: human defense item { "team_human_def1", "sound/items/holdable.wav", - { "models/bitems/turret-base.md3", "models/bitems/turret-top.md3", 0, 0 }, + { "models/buildables/plasmaturret/pturret_base.md3", "models/buildables/plasmaturret/pturret_top.md3", 0, 0 }, "icons/teleporter", //icon "Human Defense", //pickup 0, @@ -888,7 +888,7 @@ TA: human defense item { "team_human_def2", "sound/items/holdable.wav", - { "models/bitems/turret-base.md3", "models/weapons2/machinegun/machinegun.md3", 0, 0 }, + { "models/buildables/plasmaturret/pturret_base.md3", "models/weapons2/machinegun/machinegun.md3", 0, 0 }, "icons/teleporter", //icon "Human Defense2", //pickup 0, @@ -904,7 +904,7 @@ TA: human defense item { "team_human_def3", "sound/items/holdable.wav", - { "models/bitems/turret-base.md3", "models/weapons2/railgun/railgun.md3", 0, 0 }, + { "models/buildables/plasmaturret/pturret_base.md3", "models/weapons2/railgun/railgun.md3", 0, 0 }, "icons/teleporter", //icon "Human Defense3", //pickup 0, diff --git a/src/game/bg_pmove.c b/src/game/bg_pmove.c index 8a6f986a..e76918e6 100644 --- a/src/game/bg_pmove.c +++ b/src/game/bg_pmove.c @@ -1313,13 +1313,23 @@ PM_GroundClimbTrace */ static void PM_GroundClimbTrace( void ) { - vec3_t surfNormal, movedir, forward, right, point; + vec3_t surfNormal, movedir, lookdir, forward, right, point; vec3_t refNormal = { 0.0f, 0.0f, 1.0f }; vec3_t ceilingNormal = { 0.0f, 0.0f, -1.0f }; float toAngles[3], surfAngles[3]; trace_t trace; int i; + //used for delta correction + vec3_t traceCROSSsurf, traceCROSSref, surfCROSSref; + float traceDOTsurf, traceDOTref, surfDOTref, rTtDOTrTsTt; + 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; + float ldDOTtCs, d; + vec3_t abc; + //TA: If we're on the ceiling then grapplePoint is a rotation normal.. otherwise its a surface normal. // would have been nice if Carmack had left a few random variables in the ps struct for mod makers if( pm->ps->stats[ STAT_STATE ] & SS_WALLCLIMBINGCEILING ) @@ -1334,6 +1344,8 @@ static void PM_GroundClimbTrace( void ) CrossProduct( surfNormal, right, movedir ); VectorNormalize( movedir ); + VectorCopy( movedir, lookdir ); + if( pm->cmd.forwardmove < 0 ) VectorNegate( movedir, movedir ); @@ -1391,6 +1403,37 @@ static void PM_GroundClimbTrace( void ) if( i == 2 ) VectorCopy( trace.endpos, pm->ps->origin ); + //calculate a bunch of stuff... + CrossProduct( trace.plane.normal, surfNormal, traceCROSSsurf ); + VectorNormalize( traceCROSSsurf ); + + CrossProduct( trace.plane.normal, refNormal, traceCROSSref ); + VectorNormalize( traceCROSSref ); + + CrossProduct( surfNormal, refNormal, surfCROSSref ); + VectorNormalize( surfCROSSref ); + + //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 ); + traceANGref = RAD2DEG( acos( traceDOTref ) ); + + if( traceANGref > 180.0f ) + traceANGref -= 180.0f; + + //calculate angle between surf and ref + surfDOTref = DotProduct( surfNormal, refNormal ); + surfANGref = RAD2DEG( acos( surfDOTref ) ); + + if( surfANGref > 180.0f ) + surfANGref -= 180.0f; + //if the trace result and old surface normal are different then we must have transided to a new //surface... do some stuff... if( !VectorCompare( trace.plane.normal, surfNormal ) ) @@ -1401,42 +1444,6 @@ static void PM_GroundClimbTrace( void ) { //behold the evil mindfuck from hell //it has fucked mind like nothing has fucked mind before - vec3_t traceCROSSsurf, traceCROSSref, surfCROSSref; - float traceDOTsurf, traceDOTref, surfDOTref, rTtDOTrTsTt; - 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; - - CrossProduct( trace.plane.normal, surfNormal, traceCROSSsurf ); - VectorNormalize( traceCROSSsurf ); - - CrossProduct( trace.plane.normal, refNormal, traceCROSSref ); - VectorNormalize( traceCROSSref ); - - CrossProduct( surfNormal, refNormal, surfCROSSref ); - VectorNormalize( surfCROSSref ); - - //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 ); - traceANGref = RAD2DEG( acos( traceDOTref ) ); - - if( traceANGref > 180.0f ) - traceANGref -= 180.0f; - - //calculate angle between surf and ref - surfDOTref = DotProduct( surfNormal, refNormal ); - surfANGref = RAD2DEG( acos( surfDOTref ) ); - - if( surfANGref > 180.0f ) - surfANGref -= 180.0f; //calculate reference rotated through to trace plane RotatePointAroundVector( refTOtrace, traceCROSSref, horizontal, -traceANGref ); @@ -1460,6 +1467,31 @@ static void PM_GroundClimbTrace( void ) pm->ps->delta_angles[ YAW ] -= rTtANGrTsTt; } + //construct a plane dividing the surf and trace normals + CrossProduct( traceCROSSsurf, surfNormal, abc ); + VectorNormalize( abc ); + d = DotProduct( abc, pm->ps->origin ); + + //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 ) + { + VectorInverse( traceCROSSsurf ); + ldDOTtCs = DotProduct( lookdir, traceCROSSsurf ); + } + + //set the correction angle + traceANGsurf *= 1.0f - ldDOTtCs; + + //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 ) ) |