From 588af5daec6d9508b6cf46335bfc6de72c82331f Mon Sep 17 00:00:00 2001 From: Michael Levin Date: Sat, 3 Oct 2009 11:32:18 +0000 Subject: * Options menu video modes glitch fixed (a backport) * Scores will not be reset to 0 for players whose classes change while the scoreboard is showing * Hive offset fixed so that less of the hive is sunk under the floor * Buildable positioning cap-traces are cached, saving CPU * Buildable cap-traces will not interact with bodies (players and buildables) * For Aliens holding dodge while jumping will result in a weaker jump Marauder walljump changes: * Finds a wall regardless of where player is aiming * No longer uses direction keys to direct walljump (player is using these to hug the wall!) * Will direct jump in player's view direction --- src/cgame/cg_buildable.c | 31 +++++++++++++++++++++++++++---- src/cgame/cg_local.h | 11 ++++++++++- src/cgame/cg_main.c | 2 +- 3 files changed, 38 insertions(+), 6 deletions(-) (limited to 'src/cgame') diff --git a/src/cgame/cg_buildable.c b/src/cgame/cg_buildable.c index 3fba12e4..8f4c2e5c 100644 --- a/src/cgame/cg_buildable.c +++ b/src/cgame/cg_buildable.c @@ -622,12 +622,14 @@ static void CG_PositionAndOrientateBuildable( const vec3_t angles, const vec3_t VectorMA( inOrigin, -TRACE_DEPTH, normal, end ); VectorMA( inOrigin, 1.0f, normal, start ); - CG_CapTrace( &tr, start, mins, maxs, end, skipNumber, MASK_PLAYERSOLID ); + CG_CapTrace( &tr, start, mins, maxs, end, skipNumber, + CONTENTS_SOLID | CONTENTS_PLAYERCLIP ); if( tr.fraction == 1.0f ) { //erm we missed completely - try again with a box trace - CG_Trace( &tr, start, mins, maxs, end, skipNumber, MASK_PLAYERSOLID ); + CG_Trace( &tr, start, mins, maxs, end, skipNumber, + CONTENTS_SOLID | CONTENTS_PLAYERCLIP ); } VectorMA( inOrigin, tr.fraction * -TRACE_DEPTH, normal, outOrigin ); @@ -1286,8 +1288,29 @@ void CG_Buildable( centity_t *cent ) BG_FindBBoxForBuildable( es->modelindex, mins, maxs ); if( es->pos.trType == TR_STATIONARY ) - CG_PositionAndOrientateBuildable( angles, ent.origin, surfNormal, es->number, - mins, maxs, ent.axis, ent.origin ); + { + // Positioning a buildable involves potentially up to two traces, and + // seeing as buildables rarely move, we cache the results and recalculate + // only if the buildable moves or changes orientation + if( VectorCompare( cent->buildableCache.cachedOrigin, cent->lerpOrigin ) && + VectorCompare( cent->buildableCache.cachedNormal, surfNormal ) ) + { + VectorCopy( cent->buildableCache.axis[ 0 ], ent.axis[ 0 ] ); + VectorCopy( cent->buildableCache.axis[ 1 ], ent.axis[ 1 ] ); + VectorCopy( cent->buildableCache.axis[ 2 ], ent.axis[ 2 ] ); + } + else + { + CG_PositionAndOrientateBuildable( angles, ent.origin, surfNormal, + es->number, mins, maxs, ent.axis, + ent.origin ); + VectorCopy( ent.axis[ 0 ], cent->buildableCache.axis[ 0 ] ); + VectorCopy( ent.axis[ 1 ], cent->buildableCache.axis[ 1 ] ); + VectorCopy( ent.axis[ 2 ], cent->buildableCache.axis[ 2 ] ); + VectorCopy( cent->lerpOrigin, cent->buildableCache.cachedOrigin ); + VectorCopy( surfNormal, cent->buildableCache.cachedNormal ); + } + } //offset on the Z axis if required VectorMA( ent.origin, BG_FindZOffsetForBuildable( es->modelindex ), surfNormal, ent.origin ); diff --git a/src/cgame/cg_local.h b/src/cgame/cg_local.h index 891edbd4..d969dca1 100644 --- a/src/cgame/cg_local.h +++ b/src/cgame/cg_local.h @@ -599,6 +599,14 @@ typedef struct buildableStatus_s qboolean visible; // Status is visble? } buildableStatus_t; +typedef struct buildableCache_s +{ + vec3_t cachedOrigin; // If either the cached entity origin or the + vec3_t cachedNormal; // cached surfNormal change the cache is invalid + vec3_t axis[ 3 ]; + vec3_t origin; +} buildableCache_t; + //================================================= // centity_t have a direct corespondence with gentity_t in the game, but @@ -643,6 +651,7 @@ typedef struct centity_s buildableAnimNumber_t oldBuildableAnim; //to detect when new anims are set particleSystem_t *buildablePS; buildableStatus_t buildableStatus; + buildableCache_t buildableCache; // so we don't recalculate things float lastBuildableHealthScale; int lastBuildableDamageSoundTime; @@ -672,7 +681,7 @@ typedef struct centity_s int muzzleTSDeathTime; qboolean valid; - qboolean oldValid; + qboolean oldValid; } centity_t; diff --git a/src/cgame/cg_main.c b/src/cgame/cg_main.c index c094ffee..c4c47baa 100644 --- a/src/cgame/cg_main.c +++ b/src/cgame/cg_main.c @@ -1589,7 +1589,7 @@ static const char *CG_FeederItemText( float feederID, int index, int column, qha break; case 4: - return va( "%d", info->score ); + return va( "%d", sp->score ); break; case 5: -- cgit