From eb95d5b561d44d5ead7d9f524f6cf449add9eac1 Mon Sep 17 00:00:00 2001 From: /dev/humancontroller Date: Sun, 13 Jul 2014 21:04:47 +0200 Subject: also invalidate the buildable orientation cache if the angles or the buildable type changes --- src/cgame/cg_buildable.c | 6 +++++- src/cgame/cg_local.h | 6 ++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/cgame/cg_buildable.c b/src/cgame/cg_buildable.c index 2c85bfd7..33a3cc0e 100644 --- a/src/cgame/cg_buildable.c +++ b/src/cgame/cg_buildable.c @@ -1321,7 +1321,9 @@ void CG_Buildable( centity_t *cent ) // 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 ) ) + VectorCompare( cent->buildableCache.cachedAngles, cent->lerpAngles ) && + VectorCompare( cent->buildableCache.cachedNormal, surfNormal ) && + cent->buildableCache.cachedType == es->modelindex ) { VectorCopy( cent->buildableCache.axis[ 0 ], ent.axis[ 0 ] ); VectorCopy( cent->buildableCache.axis[ 1 ], ent.axis[ 1 ] ); @@ -1338,7 +1340,9 @@ void CG_Buildable( centity_t *cent ) VectorCopy( ent.axis[ 2 ], cent->buildableCache.axis[ 2 ] ); VectorCopy( ent.origin, cent->buildableCache.origin ); VectorCopy( cent->lerpOrigin, cent->buildableCache.cachedOrigin ); + VectorCopy( cent->lerpAngles, cent->buildableCache.cachedAngles ); VectorCopy( surfNormal, cent->buildableCache.cachedNormal ); + cent->buildableCache.cachedType = es->modelindex; } } else diff --git a/src/cgame/cg_local.h b/src/cgame/cg_local.h index ab160784..0d73474a 100644 --- a/src/cgame/cg_local.h +++ b/src/cgame/cg_local.h @@ -606,8 +606,10 @@ typedef struct buildableStatus_s 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 cachedOrigin; // If any of the values differ from their + vec3_t cachedAngles; // cached versions, then the cache is invalid + vec3_t cachedNormal; + buildable_t cachedType; vec3_t axis[ 3 ]; vec3_t origin; } buildableCache_t; -- cgit