No more default 800 gravity on items - NiceAss

This commit is contained in:
Bryce Hutchings 2002-01-14 01:19:23 +00:00
parent ba6770c1bc
commit 8b181630b7
7 changed files with 182 additions and 70 deletions

View File

@ -5,6 +5,9 @@
//-----------------------------------------------------------------------------
//
// $Log$
// Revision 1.18 2002/01/14 01:19:23 niceass
// No more default 800 gravity on items - NiceAss
//
// Revision 1.17 2002/01/11 19:48:29 jbravo
// Formatted the source in non DOS format.
//
@ -594,7 +597,7 @@ static void CG_Missile( centity_t *cent ) {
if ( weapon->missileSound ) {
vec3_t velocity;
BG_EvaluateTrajectoryDelta( &cent->currentState.pos, cg.time, velocity );
CG_EvaluateTrajectoryDelta( &cent->currentState.pos, cg.time, velocity );
trap_S_AddLoopingSound( cent->currentState.number, cent->lerpOrigin, velocity, weapon->missileSound );
}
@ -638,7 +641,7 @@ static void CG_Missile( centity_t *cent ) {
if ( s1->weapon == WP_KNIFE ) {
vec3_t knifeVelocity;
BG_EvaluateTrajectoryDelta(&s1->pos, cg.time, knifeVelocity);
CG_EvaluateTrajectoryDelta(&s1->pos, cg.time, knifeVelocity);
vectoangles(knifeVelocity, cent->lerpAngles);
cent->lerpAngles[0] += cg.time; // was / 6
@ -841,11 +844,11 @@ void CG_AdjustPositionForMover( const vec3_t in, int moverNum, int fromTime, int
return;
}
BG_EvaluateTrajectory( &cent->currentState.pos, fromTime, oldOrigin );
BG_EvaluateTrajectory( &cent->currentState.apos, fromTime, oldAngles );
CG_EvaluateTrajectory( &cent->currentState.pos, fromTime, oldOrigin );
CG_EvaluateTrajectory( &cent->currentState.apos, fromTime, oldAngles );
BG_EvaluateTrajectory( &cent->currentState.pos, toTime, origin );
BG_EvaluateTrajectory( &cent->currentState.apos, toTime, angles );
CG_EvaluateTrajectory( &cent->currentState.pos, toTime, origin );
CG_EvaluateTrajectory( &cent->currentState.apos, toTime, angles );
VectorSubtract( origin, oldOrigin, deltaOrigin );
VectorSubtract( angles, oldAngles, deltaAngles );
@ -875,15 +878,15 @@ static void CG_InterpolateEntityPosition( centity_t *cent ) {
// this will linearize a sine or parabolic curve, but it is important
// to not extrapolate player positions if more recent data is available
BG_EvaluateTrajectory( &cent->currentState.pos, cg.snap->serverTime, current );
BG_EvaluateTrajectory( &cent->nextState.pos, cg.nextSnap->serverTime, next );
CG_EvaluateTrajectory( &cent->currentState.pos, cg.snap->serverTime, current );
CG_EvaluateTrajectory( &cent->nextState.pos, cg.nextSnap->serverTime, next );
cent->lerpOrigin[0] = current[0] + f * ( next[0] - current[0] );
cent->lerpOrigin[1] = current[1] + f * ( next[1] - current[1] );
cent->lerpOrigin[2] = current[2] + f * ( next[2] - current[2] );
BG_EvaluateTrajectory( &cent->currentState.apos, cg.snap->serverTime, current );
BG_EvaluateTrajectory( &cent->nextState.apos, cg.nextSnap->serverTime, next );
CG_EvaluateTrajectory( &cent->currentState.apos, cg.snap->serverTime, current );
CG_EvaluateTrajectory( &cent->nextState.apos, cg.nextSnap->serverTime, next );
cent->lerpAngles[0] = LerpAngle( current[0], next[0], f );
cent->lerpAngles[1] = LerpAngle( current[1], next[1], f );
@ -922,8 +925,8 @@ static void CG_CalcEntityLerpPositions( centity_t *cent ) {
}
// just use the current frame and evaluate as best we can
BG_EvaluateTrajectory( &cent->currentState.pos, cg.time, cent->lerpOrigin );
BG_EvaluateTrajectory( &cent->currentState.apos, cg.time, cent->lerpAngles );
CG_EvaluateTrajectory( &cent->currentState.pos, cg.time, cent->lerpOrigin );
CG_EvaluateTrajectory( &cent->currentState.apos, cg.time, cent->lerpAngles );
// adjust for riding a mover if it wasn't rolled into the predicted
// player state
@ -1281,37 +1284,3 @@ static void CG_Dlight( centity_t *cent ) {
//CG_Printf("cgame: (%f %f %f) %f\n", r, g, b, i );
}
/*
=================
CG_CalcViewAngle
Added by NiceAss.
Start not known. End known.
Used for calculating a player's viewing angle.
Currently used for spark directions (reflected off a plane).
=================
*/
void CG_CalcViewDir(const int sourceEntityNum, const vec3_t end, vec3_t viewDir) {
vec3_t delta, start;
CG_CalcMuzzlePoint(sourceEntityNum, start);
VectorSubtract(end, start, delta);
VectorNormalize2(delta, viewDir);
}
/*
=================
CG_CalcViewAngle2
Added by NiceAss.
Start known. End known.
Used for calculating a player's viewing angle.
Currently used for spark directions (reflected off a plane).
=================
*/
void CG_CalcViewDir2(const vec3_t start, const vec3_t end, vec3_t viewDir) {
vec3_t delta;
VectorSubtract(end, start, delta);
VectorNormalize2(delta, viewDir);
}

View File

@ -5,6 +5,9 @@
//-----------------------------------------------------------------------------
//
// $Log$
// Revision 1.34 2002/01/14 01:19:23 niceass
// No more default 800 gravity on items - NiceAss
//
// Revision 1.33 2002/01/11 20:20:57 jbravo
// Adding TP to main branch
//
@ -2489,7 +2492,7 @@ void CG_CheckEvents( centity_t *cent ) {
}
// calculate the position at exactly the frame time
BG_EvaluateTrajectory( &cent->currentState.pos, cg.snap->serverTime, cent->lerpOrigin );
CG_EvaluateTrajectory( &cent->currentState.pos, cg.snap->serverTime, cent->lerpOrigin );
CG_SetEntitySoundPosition( cent );
CG_EntityEvent( cent, cent->lerpOrigin );

View File

@ -5,6 +5,9 @@
//-----------------------------------------------------------------------------
//
// $Log$
// Revision 1.40 2002/01/14 01:19:23 niceass
// No more default 800 gravity on items - NiceAss
//
// Revision 1.39 2002/01/11 20:20:57 jbravo
// Adding TP to main branch
//
@ -1555,7 +1558,8 @@ void CG_Trace( trace_t *result, const vec3_t start, const vec3_t mins, const vec
//int skipNumber, int mask );
void CG_PredictPlayerState( void );
void CG_LoadDeferredPlayers( void );
void CG_EvaluateTrajectory( const trajectory_t *tr, int atTime, vec3_t result );
void CG_EvaluateTrajectoryDelta( const trajectory_t *tr, int atTime, vec3_t result );
//
// cg_events.c
@ -1581,7 +1585,6 @@ void CG_PositionRotatedEntityOnTag( refEntity_t *entity, const refEntity_t *pare
//Blaze: for weapon animations
void CG_PositionWeaponOnTag( refEntity_t *entity, const refEntity_t *parent, qhandle_t parentModel, char *tagName );
//
// cg_weapons.c
//
@ -1617,6 +1620,8 @@ void CG_DrawWeaponSelect( void );
void CG_OutOfAmmoChange( void ); // should this be in pmove?
void CG_CheckLaser (); //Elder: check laser to see if it's our own
void CG_CalcViewDir2(const vec3_t start, const vec3_t end, vec3_t viewDir);
void CG_CalcViewDir(const int sourceEntityNum, const vec3_t end, vec3_t viewDir);
//
// cg_marks.c

View File

@ -5,6 +5,9 @@
//-----------------------------------------------------------------------------
//
// $Log$
// Revision 1.7 2002/01/14 01:19:23 niceass
// No more default 800 gravity on items - NiceAss
//
// Revision 1.6 2002/01/11 19:48:29 jbravo
// Formatted the source in non DOS format.
//
@ -125,7 +128,7 @@ void CG_BloodTrail( localEntity_t *le ) {
t2 = step * ( cg.time / step );
for ( ; t <= t2; t += step ) {
BG_EvaluateTrajectory( &le->pos, t, newOrigin );
CG_EvaluateTrajectory( &le->pos, t, newOrigin );
blood = CG_SmokePuff( newOrigin, vec3_origin,
20, // radius
@ -213,7 +216,7 @@ void CG_ReflectVelocity( localEntity_t *le, trace_t *trace ) {
// reflect the velocity on the trace plane
hitTime = cg.time - cg.frametime + cg.frametime * trace->fraction;
BG_EvaluateTrajectoryDelta( &le->pos, hitTime, velocity );
CG_EvaluateTrajectoryDelta( &le->pos, hitTime, velocity );
dot = DotProduct( velocity, trace->plane.normal );
VectorMA( velocity, -2*dot, trace->plane.normal, le->pos.trDelta );
@ -266,7 +269,7 @@ void CG_AddFragment( localEntity_t *le ) {
}
// calculate new position
BG_EvaluateTrajectory( &le->pos, cg.time, newOrigin );
CG_EvaluateTrajectory( &le->pos, cg.time, newOrigin );
// trace a line from previous position to new position
CG_Trace( &trace, le->refEntity.origin, NULL, NULL, newOrigin, -1, CONTENTS_SOLID );
@ -277,7 +280,7 @@ void CG_AddFragment( localEntity_t *le ) {
if ( le->leFlags & LEF_TUMBLE ) {
vec3_t angles;
BG_EvaluateTrajectory( &le->angles, cg.time, angles );
CG_EvaluateTrajectory( &le->angles, cg.time, angles );
AnglesToAxis( angles, le->refEntity.axis );
}
@ -370,7 +373,7 @@ static void CG_AddMoveScaleFade( localEntity_t *le ) {
re->radius = le->radius * ( 1.0 - c ) + 8;
}
BG_EvaluateTrajectory( &le->pos, cg.time, re->origin );
CG_EvaluateTrajectory( &le->pos, cg.time, re->origin );
// if the view would be "inside" the sprite, kill the sprite
// so it doesn't add too much overdraw

View File

@ -5,6 +5,9 @@
//-----------------------------------------------------------------------------
//
// $Log$
// Revision 1.15 2002/01/14 01:19:23 niceass
// No more default 800 gravity on items - NiceAss
//
// Revision 1.14 2002/01/11 19:48:29 jbravo
// Formatted the source in non DOS format.
//
@ -2824,8 +2827,8 @@ void CG_ResetPlayerEntity( centity_t *cent ) {
CG_ClearLerpFrame( &cgs.clientinfo[ cent->currentState.clientNum ], &cent->pe.legs, cent->currentState.legsAnim );
CG_ClearLerpFrame( &cgs.clientinfo[ cent->currentState.clientNum ], &cent->pe.torso, cent->currentState.torsoAnim );
BG_EvaluateTrajectory( &cent->currentState.pos, cg.time, cent->lerpOrigin );
BG_EvaluateTrajectory( &cent->currentState.apos, cg.time, cent->lerpAngles );
CG_EvaluateTrajectory( &cent->currentState.pos, cg.time, cent->lerpOrigin );
CG_EvaluateTrajectory( &cent->currentState.apos, cg.time, cent->lerpAngles );
VectorCopy( cent->lerpOrigin, cent->rawOrigin );
VectorCopy( cent->lerpAngles, cent->rawAngles );

View File

@ -5,6 +5,9 @@
//-----------------------------------------------------------------------------
//
// $Log$
// Revision 1.13 2002/01/14 01:19:23 niceass
// No more default 800 gravity on items - NiceAss
//
// Revision 1.12 2002/01/11 20:20:57 jbravo
// Adding TP to main branch
//
@ -102,7 +105,7 @@ static void CG_ClipMoveToEntities ( const vec3_t start, const vec3_t mins, const
// special value for bmodel
cmodel = trap_CM_InlineModel( ent->modelindex );
VectorCopy( cent->lerpAngles, angles );
BG_EvaluateTrajectory( &cent->currentState.pos, cg.physicsTime, origin );
CG_EvaluateTrajectory( &cent->currentState.pos, cg.physicsTime, origin );
} else {
// encoded bbox
x = (ent->solid & 255);
@ -662,4 +665,90 @@ void CG_PredictPlayerState( void ) {
}
}
/*
================
CG_EvaluateTrajectory
================
*/
void CG_EvaluateTrajectory( const trajectory_t *tr, int atTime, vec3_t result ) {
float deltaTime;
float phase;
switch( tr->trType ) {
case TR_STATIONARY:
case TR_INTERPOLATE:
VectorCopy( tr->trBase, result );
break;
case TR_LINEAR:
deltaTime = ( atTime - tr->trTime ) * 0.001; // milliseconds to seconds
VectorMA( tr->trBase, deltaTime, tr->trDelta, result );
break;
case TR_SINE:
deltaTime = ( atTime - tr->trTime ) / (float) tr->trDuration;
phase = sin( deltaTime * M_PI * 2 );
VectorMA( tr->trBase, phase, tr->trDelta, result );
break;
case TR_LINEAR_STOP:
if ( atTime > tr->trTime + tr->trDuration ) {
atTime = tr->trTime + tr->trDuration;
}
deltaTime = ( atTime - tr->trTime ) * 0.001; // milliseconds to seconds
if ( deltaTime < 0 ) {
deltaTime = 0;
}
VectorMA( tr->trBase, deltaTime, tr->trDelta, result );
break;
case TR_GRAVITY:
deltaTime = ( atTime - tr->trTime ) * 0.001; // milliseconds to seconds
VectorMA( tr->trBase, deltaTime, tr->trDelta, result );
result[2] -= 0.5 * cg.predictedPlayerState.gravity * deltaTime * deltaTime; // FIXME: local gravity...
break;
default:
Com_Error( ERR_DROP, "CG_EvaluateTrajectory: unknown trType: %i", tr->trTime );
break;
}
}
/*
================
CG_EvaluateTrajectoryDelta
For determining velocity at a given time
================
*/
void CG_EvaluateTrajectoryDelta( const trajectory_t *tr, int atTime, vec3_t result ) {
float deltaTime;
float phase;
switch( tr->trType ) {
case TR_STATIONARY:
case TR_INTERPOLATE:
VectorClear( result );
break;
case TR_LINEAR:
VectorCopy( tr->trDelta, result );
break;
case TR_SINE:
deltaTime = ( atTime - tr->trTime ) / (float) tr->trDuration;
phase = cos( deltaTime * M_PI * 2 ); // derivative of sin = cos
phase *= 0.5;
VectorScale( tr->trDelta, phase, result );
break;
case TR_LINEAR_STOP:
if ( atTime > tr->trTime + tr->trDuration ) {
VectorClear( result );
return;
}
VectorCopy( tr->trDelta, result );
break;
case TR_GRAVITY:
deltaTime = ( atTime - tr->trTime ) * 0.001; // milliseconds to seconds
VectorCopy( tr->trDelta, result );
result[2] -= cg.predictedPlayerState.gravity * deltaTime; // FIXME: local gravity...
break;
default:
Com_Error( ERR_DROP, "CG_EvaluateTrajectoryDelta: unknown trType: %i", tr->trTime );
break;
}
}

View File

@ -5,6 +5,9 @@
//-----------------------------------------------------------------------------
//
// $Log$
// Revision 1.47 2002/01/14 01:19:23 niceass
// No more default 800 gravity on items - NiceAss
//
// Revision 1.46 2002/01/12 15:18:20 jbravo
// Added a fix from Niceass. (cg_drawgun affecting other player models)
//
@ -493,7 +496,7 @@ static void CG_RocketTrail( centity_t *ent, const weaponInfo_t *wi ) {
startTime = ent->trailTime;
t = step * ( (startTime + step) / step );
BG_EvaluateTrajectory( &es->pos, cg.time, origin );
CG_EvaluateTrajectory( &es->pos, cg.time, origin );
contents = CG_PointContents( origin, -1 );
// if object (e.g. grenade) is stationary, don't toss up smoke
@ -502,7 +505,7 @@ static void CG_RocketTrail( centity_t *ent, const weaponInfo_t *wi ) {
return;
}
BG_EvaluateTrajectory( &es->pos, ent->trailTime, lastPos );
CG_EvaluateTrajectory( &es->pos, ent->trailTime, lastPos );
lastContents = CG_PointContents( lastPos, -1 );
ent->trailTime = cg.time;
@ -515,7 +518,7 @@ static void CG_RocketTrail( centity_t *ent, const weaponInfo_t *wi ) {
}
for ( ; t <= ent->trailTime ; t += step ) {
BG_EvaluateTrajectory( &es->pos, t, lastPos );
CG_EvaluateTrajectory( &es->pos, t, lastPos );
smoke = CG_SmokePuff( lastPos, up,
wi->trailRadius,
@ -561,7 +564,7 @@ static void CG_NailTrail( centity_t *ent, const weaponInfo_t *wi ) {
startTime = ent->trailTime;
t = step * ( (startTime + step) / step );
BG_EvaluateTrajectory( &es->pos, cg.time, origin );
CG_EvaluateTrajectory( &es->pos, cg.time, origin );
contents = CG_PointContents( origin, -1 );
// if object (e.g. grenade) is stationary, don't toss up smoke
@ -570,7 +573,7 @@ static void CG_NailTrail( centity_t *ent, const weaponInfo_t *wi ) {
return;
}
BG_EvaluateTrajectory( &es->pos, ent->trailTime, lastPos );
CG_EvaluateTrajectory( &es->pos, ent->trailTime, lastPos );
lastContents = CG_PointContents( lastPos, -1 );
ent->trailTime = cg.time;
@ -583,7 +586,7 @@ static void CG_NailTrail( centity_t *ent, const weaponInfo_t *wi ) {
}
for ( ; t <= ent->trailTime ; t += step ) {
BG_EvaluateTrajectory( &es->pos, t, lastPos );
CG_EvaluateTrajectory( &es->pos, t, lastPos );
smoke = CG_SmokePuff( lastPos, up,
wi->trailRadius,
@ -626,7 +629,7 @@ static void CG_PlasmaTrail( centity_t *cent, const weaponInfo_t *wi ) {
startTime = cent->trailTime;
t = step * ( (startTime + step) / step );
BG_EvaluateTrajectory( &es->pos, cg.time, origin );
CG_EvaluateTrajectory( &es->pos, cg.time, origin );
le = CG_AllocLocalEntity();
re = &le->refEntity;
@ -708,7 +711,7 @@ void CG_GrappleTrail( centity_t *ent, const weaponInfo_t *wi ) {
es = &ent->currentState;
BG_EvaluateTrajectory( &es->pos, cg.time, origin );
CG_EvaluateTrajectory( &es->pos, cg.time, origin );
ent->trailTime = cg.time;
memset( &beam, 0, sizeof( beam ) );
@ -1234,6 +1237,7 @@ NiceAss; I've torn this function up with testing... ignore it =P
===============
*/
static void CG_LightningBolt( centity_t *cent, vec3_t origin ) {
/*
trace_t trace;
refEntity_t beam;
vec3_t forward;
@ -1250,7 +1254,7 @@ static void CG_LightningBolt( centity_t *cent, vec3_t origin ) {
//CG_Printf("%d \n", cg.predictedPlayerState.clientNum);
// find muzzle point for this frame
//BG_EvaluateTrajectory( &cent->currentState.apos, cg.time, cent->lerpAngles );
//CG_EvaluateTrajectory( &cent->currentState.apos, cg.time, cent->lerpAngles );
AngleVectors( cent->lerpAngles, forward, NULL, NULL );
// project forward by the lightning range
@ -1275,6 +1279,7 @@ static void CG_LightningBolt( centity_t *cent, vec3_t origin ) {
if ( trace.fraction < 1.0 ) {
}
*/
}
@ -1692,15 +1697,15 @@ Add the weapon, and flash for the player's view
void CG_AddViewWeapon( playerState_t *ps ) {
refEntity_t hand;
centity_t *cent;
clientInfo_t *ci;
//clientInfo_t *ci;
float fovOffset;
vec3_t angles;
weaponInfo_t *weapon;
// remove this:
vec3_t origin;
//vec3_t origin;
//Blaze: Reaction vars for gun positions
float rxn_gunx, rxn_guny, rxn_gunz;
//float rxn_gunx, rxn_guny, rxn_gunz;
@ -3903,7 +3908,7 @@ static void CG_LocalLaser ()
VectorCopy(re->origin, re->oldorigin);
VectorCopy(tr.endpos, re->origin);
//VectorCopy(tr.endpos, cg.laserEnt->pos.trBase);
//BG_EvaluateTrajectory(&cg.laserEnt->pos, cg.time, re->origin);
//CG_EvaluateTrajectory(&cg.laserEnt->pos, cg.time, re->origin);
//Boost the endTime
cg.laserEnt->endTime += 10000;
@ -3997,3 +4002,38 @@ void CG_ReloadWeapon (centity_t *cent, int reloadStage)
}
}
/*
=================
CG_CalcViewAngle
Added by NiceAss.
Start not known. End known.
Used for calculating a player's viewing angle.
Currently used for spark directions (reflected off a plane).
=================
*/
void CG_CalcViewDir(const int sourceEntityNum, const vec3_t end, vec3_t viewDir) {
vec3_t delta, start;
CG_CalcMuzzlePoint(sourceEntityNum, start);
VectorSubtract(end, start, delta);
VectorNormalize2(delta, viewDir);
}
/*
=================
CG_CalcViewAngle2
Added by NiceAss.
Start known. End known.
Used for calculating a player's viewing angle.
Currently used for spark directions (reflected off a plane).
=================
*/
void CG_CalcViewDir2(const vec3_t start, const vec3_t end, vec3_t viewDir) {
vec3_t delta;
VectorSubtract(end, start, delta);
VectorNormalize2(delta, viewDir);
}