summaryrefslogtreecommitdiff
path: root/src/cgame
diff options
context:
space:
mode:
Diffstat (limited to 'src/cgame')
-rw-r--r--src/cgame/cg_buildable.c31
-rw-r--r--src/cgame/cg_local.h11
-rw-r--r--src/cgame/cg_main.c2
3 files changed, 38 insertions, 6 deletions
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: