diff options
author | Tim Angus <tim@ngus.net> | 2001-08-12 01:07:49 +0000 |
---|---|---|
committer | Tim Angus <tim@ngus.net> | 2001-08-12 01:07:49 +0000 |
commit | f3fea814bd8bc6a55e8d830464a266e8086e093e (patch) | |
tree | 13c66f37296b0314a45ee3f7285eb35311722c4b /src/game/bg_pmove.c | |
parent | ea18578c4b3c47ad0bad78027eb0006adea1e151 (diff) |
Experimental view-skew limitation
Diffstat (limited to 'src/game/bg_pmove.c')
-rw-r--r-- | src/game/bg_pmove.c | 106 |
1 files changed, 69 insertions, 37 deletions
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 ) ) |