summaryrefslogtreecommitdiff
path: root/src/cgame
diff options
context:
space:
mode:
Diffstat (limited to 'src/cgame')
-rw-r--r--src/cgame/cg_draw.c2
-rw-r--r--src/cgame/cg_ents.c2
-rw-r--r--src/cgame/cg_local.h14
-rw-r--r--src/cgame/cg_main.c2
-rw-r--r--src/cgame/cg_particles.c5
-rw-r--r--src/cgame/cg_view.c110
6 files changed, 130 insertions, 5 deletions
diff --git a/src/cgame/cg_draw.c b/src/cgame/cg_draw.c
index c004c3d5..0617580b 100644
--- a/src/cgame/cg_draw.c
+++ b/src/cgame/cg_draw.c
@@ -345,7 +345,7 @@ static void CG_DrawLighting( void )
VectorCopy( cent->lerpOrigin, point );
- AngleVectors( cg.predictedPlayerState.viewangles, direction, NULL, NULL );
+ AngleVectors( cg.refdefViewAngles, direction, NULL, NULL );
currentLum = CG_LightFromDirection( point, direction );
//CG_Printf( "%d\n", lum );
diff --git a/src/cgame/cg_ents.c b/src/cgame/cg_ents.c
index 57b89fc6..62920756 100644
--- a/src/cgame/cg_ents.c
+++ b/src/cgame/cg_ents.c
@@ -655,7 +655,7 @@ static void CG_TorchLight( centity_t *cent )
if( cent->currentState.clientNum == cg.predictedPlayerState.clientNum )
{
VectorCopy( cg.predictedPlayerState.origin, from );
- VectorCopy( cg.predictedPlayerState.viewangles, angles );
+ VectorCopy( cg.refdefViewAngles, angles );
}
else
{
diff --git a/src/cgame/cg_local.h b/src/cgame/cg_local.h
index 38bc3d26..77c8ec13 100644
--- a/src/cgame/cg_local.h
+++ b/src/cgame/cg_local.h
@@ -438,6 +438,16 @@ typedef struct {
int numpositions;
} skulltrail_t;
+//TA: smoothing of view for WW transitions
+#define MAXSMOOTHS 32
+
+typedef struct
+{
+ float time;
+
+ vec3_t rotAxis;
+ float rotAngle;
+} smooth_t;
#define MAX_REWARDSTACK 10
#define MAX_SOUNDBUFFER 20
@@ -645,6 +655,9 @@ typedef struct {
int weapon2Time; //TA: time when BUTTON_ATTACK2 went t->f f->t
qboolean weapon1Firing;
qboolean weapon2Firing;
+
+ vec3_t lastNormal; //TA: view smoothage
+ smooth_t sList[ MAXSMOOTHS ]; //TA: WW smoothing
} cg_t;
@@ -1183,6 +1196,7 @@ extern vmCvar_t cg_trueLightning;
extern vmCvar_t cg_creepRes;
extern vmCvar_t cg_drawSurfNormal;
extern vmCvar_t cg_debugAlloc;
+extern vmCvar_t cg_smoothTime;
//
// cg_main.c
diff --git a/src/cgame/cg_main.c b/src/cgame/cg_main.c
index e9717faf..2cdc9149 100644
--- a/src/cgame/cg_main.c
+++ b/src/cgame/cg_main.c
@@ -186,6 +186,7 @@ vmCvar_t cg_trueLightning;
vmCvar_t cg_creepRes;
vmCvar_t cg_drawSurfNormal;
vmCvar_t cg_debugAlloc;
+vmCvar_t cg_smoothTime;
typedef struct {
@@ -266,6 +267,7 @@ static cvarTable_t cvarTable[] = {
{ &cg_creepRes, "cg_creepRes", "16", CVAR_ARCHIVE },
{ &cg_drawSurfNormal, "cg_drawSurfNormal", "0", CVAR_CHEAT },
{ &cg_debugAlloc, "cg_debugAlloc", "0", 0 },
+ { &cg_smoothTime, "cg_smoothTime", "300", 0 },
// the following variables are created in other parts of the system,
// but we also reference them here
diff --git a/src/cgame/cg_particles.c b/src/cgame/cg_particles.c
index ac709a1b..9b216ceb 100644
--- a/src/cgame/cg_particles.c
+++ b/src/cgame/cg_particles.c
@@ -136,7 +136,10 @@ void CG_ClearParticles (void)
oldtime = cg.time;
// Ridah, init the shaderAnims
- for (i=0; shaderAnimNames[i]; i++) {
+ //for (i=0; shaderAnimNames[i]; i++) {
+ //TA: figure out this thing works...
+ i = 0;
+ {
int j;
for (j=0; j<shaderAnimCounts[i]; j++) {
diff --git a/src/cgame/cg_view.c b/src/cgame/cg_view.c
index 90a2a5e9..6608b21e 100644
--- a/src/cgame/cg_view.c
+++ b/src/cgame/cg_view.c
@@ -753,6 +753,106 @@ static void CG_DrawSurfNormal( void )
trap_R_AddPolyToScene( cgs.media.whiteShader, 4, normal );
}
+/*
+===============
+CG_addSmoothOp
+===============
+*/
+static void CG_addSmoothOp( vec3_t rotAxis, float rotAngle )
+{
+ int i;
+
+ //iterate through smooth array
+ for( i = 0; i < MAXSMOOTHS; i++ )
+ {
+ //found an unused index in the smooth array
+ 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;
+ cg.sList[ i ].time = cg.time;
+ return;
+ }
+ }
+
+ //no free indices in the smooth array
+}
+
+/*
+===============
+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 ceilingNormal = { 0.0f, 0.0f, -1.0f };
+ float rotAngle;
+ vec3_t inAxis[ 3 ], outAxis[ 3 ];
+ int i;
+ float stLocal, sFraction;
+ qboolean performed = qfalse;
+
+ //set surfNormal
+ if( !( ps->stats[ STAT_STATE ] & SS_WALLCLIMBINGCEILING ) )
+ VectorCopy( ps->grapplePoint, surfNormal );
+ else
+ VectorCopy( ceilingNormal, surfNormal );
+
+ AnglesToAxis( in, inAxis );
+
+ //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
+ {
+ CrossProduct( cg.lastNormal, surfNormal, rotAxis );
+ VectorNormalize( rotAxis );
+ rotAngle = abs( RAD2DEG( acos( DotProduct( cg.lastNormal, surfNormal ) ) ) );
+ }
+
+ //add the op
+ CG_addSmoothOp( rotAxis, rotAngle );
+ }
+
+ //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 ) )
+ {
+ 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 );
+
+ AxisCopy( outAxis, inAxis );
+ performed = qtrue;
+ }
+ }
+
+ //if we performed any ops then return the smoothed angles
+ //otherwise simply return the in angles
+ if( performed )
+ AxisToAngles( outAxis, out );
+ else
+ VectorCopy( in, out );
+
+ //copy the current normal to the lastNormal
+ VectorCopy( surfNormal, cg.lastNormal );
+}
/*
===============
@@ -788,9 +888,15 @@ static int CG_CalcViewValues( void ) {
cg.xyspeed = sqrt( ps->velocity[0] * ps->velocity[0] +
ps->velocity[1] * ps->velocity[1] );
-
VectorCopy( ps->origin, cg.refdef.vieworg );
- VectorCopy( ps->viewangles, cg.refdefViewAngles );
+
+ if( BG_ClassHasAbility( ps->stats[ STAT_PCLASS ], SCA_WALLCLIMBER ) )
+ CG_smoothWWTransitions( ps, ps->viewangles, cg.refdefViewAngles );
+ else
+ VectorCopy( ps->viewangles, cg.refdefViewAngles );
+
+ if( !( ps->stats[ STAT_STATE ] & SS_WALLCLIMBING ) )
+ VectorSet( cg.lastNormal, 0.0f, 0.0f, 1.0f );
if (cg_cameraOrbit.integer) {
if (cg.time > cg.nextOrbitTime) {