summaryrefslogtreecommitdiff
path: root/src/cgame
diff options
context:
space:
mode:
authorChristopher Schwarz <lakitu7@gmail.com>2011-01-19 20:43:25 +0000
committerTim Angus <tim@ngus.net>2013-01-03 00:17:51 +0000
commitb4742563518b608a7c27066ebf64930963164515 (patch)
treefa9f7abddbd78a27eeb8d3f3678f0fa7561b4b15 /src/cgame
parent16886b666d89866108fb94fd2fcdd803c3246b6a (diff)
* (bug 2929) Prevent buildable model and bbox from being too far from each other (glitch building). Thanks F50, gimhael.
Diffstat (limited to 'src/cgame')
-rw-r--r--src/cgame/cg_buildable.c27
1 files changed, 19 insertions, 8 deletions
diff --git a/src/cgame/cg_buildable.c b/src/cgame/cg_buildable.c
index cef82e17..207c6b49 100644
--- a/src/cgame/cg_buildable.c
+++ b/src/cgame/cg_buildable.c
@@ -552,7 +552,8 @@ static void CG_PositionAndOrientateBuildable( const vec3_t angles, const vec3_t
vec3_t outAxis[ 3 ], vec3_t outOrigin )
{
vec3_t forward, start, end;
- trace_t tr;
+ trace_t tr, box_tr;
+ float mag, fraction;
AngleVectors( angles, forward, NULL, NULL );
VectorCopy( normal, outAxis[ 2 ] );
@@ -572,17 +573,27 @@ static void CG_PositionAndOrientateBuildable( const vec3_t angles, const vec3_t
VectorMA( inOrigin, -TRACE_DEPTH, normal, end );
VectorMA( inOrigin, 1.0f, normal, start );
+
+ // Take both capsule and box traces. If the capsule trace does not differ
+ // significantly from the box trace use it. This may cause buildables to be
+ // positioned *inside* the surface on which it is placed. This is intentional
+
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,
- CONTENTS_SOLID | CONTENTS_PLAYERCLIP );
- }
+ CG_Trace( &box_tr, start, mins, maxs, end, skipNumber,
+ CONTENTS_SOLID | CONTENTS_PLAYERCLIP );
+
+ mag = Distance( tr.endpos, box_tr.endpos );
+
+ fraction = tr.fraction;
+
+ // this is either too far off of the bbox to be useful for gameplay purposes
+ // or the model is positioned in thin air anyways.
+ if( mag > 15.0f || tr.fraction == 1.0f )
+ fraction = box_tr.fraction;
- VectorMA( inOrigin, tr.fraction * -TRACE_DEPTH, normal, outOrigin );
+ VectorMA( inOrigin, fraction * -TRACE_DEPTH, normal, outOrigin );
}
/*