summaryrefslogtreecommitdiff
path: root/src/cgame/cg_buildable.c
diff options
context:
space:
mode:
authorMichael Levin <risujin@fastmail.fm>2009-10-03 11:32:18 +0000
committerTim Angus <tim@ngus.net>2013-01-03 00:15:06 +0000
commit588af5daec6d9508b6cf46335bfc6de72c82331f (patch)
tree9e5d007cf9d99e7cd9c0f9bc329f1315967cb2bf /src/cgame/cg_buildable.c
parent03d3044a87e83a85a7365e77affc68986f093f22 (diff)
* 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
Diffstat (limited to 'src/cgame/cg_buildable.c')
-rw-r--r--src/cgame/cg_buildable.c31
1 files changed, 27 insertions, 4 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 );