diff options
Diffstat (limited to 'src/cgame/cg_predict.c')
-rw-r--r-- | src/cgame/cg_predict.c | 50 |
1 files changed, 43 insertions, 7 deletions
diff --git a/src/cgame/cg_predict.c b/src/cgame/cg_predict.c index 5d2950cb..8c4bc8e3 100644 --- a/src/cgame/cg_predict.c +++ b/src/cgame/cg_predict.c @@ -87,8 +87,9 @@ CG_ClipMoveToEntities ==================== */ -static void CG_ClipMoveToEntities ( const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, - int skipNumber, int mask, trace_t *tr, qboolean capsule ) +static void CG_ClipMoveToEntities ( const vec3_t start, const vec3_t mins, + const vec3_t maxs, const vec3_t end, int skipNumber, + int mask, trace_t *tr, traceType_t collisionType ) { int i, j, x, zd, zu; trace_t trace; @@ -145,21 +146,34 @@ static void CG_ClipMoveToEntities ( const vec3_t start, const vec3_t mins, const } - if( capsule ) + if( collisionType == TT_CAPSULE ) { trap_CM_TransformedCapsuleTrace ( &trace, start, end, mins, maxs, cmodel, mask, origin, angles ); } - else + else if( collisionType == TT_AABB ) { trap_CM_TransformedBoxTrace ( &trace, start, end, mins, maxs, cmodel, mask, origin, angles ); } + else if( collisionType == TT_BISPHERE ) + { + trap_CM_TransformedBiSphereTrace( &trace, start, end, + mins[ 0 ], maxs[ 0 ], cmodel, mask, origin ); + } if( trace.allsolid || trace.fraction < tr->fraction ) { trace.entityNum = ent->number; - *tr = trace; + + if( tr->lateralFraction < trace.lateralFraction ) + { + float oldLateralFraction = tr->lateralFraction; + *tr = trace; + tr->lateralFraction = oldLateralFraction; + } + else + *tr = trace; } else if( trace.startsolid ) tr->startsolid = qtrue; @@ -182,7 +196,7 @@ void CG_Trace( trace_t *result, const vec3_t start, const vec3_t mins, const ve trap_CM_BoxTrace( &t, start, end, mins, maxs, 0, mask ); t.entityNum = t.fraction != 1.0 ? ENTITYNUM_WORLD : ENTITYNUM_NONE; // check all other solid models - CG_ClipMoveToEntities( start, mins, maxs, end, skipNumber, mask, &t, qfalse ); + CG_ClipMoveToEntities( start, mins, maxs, end, skipNumber, mask, &t, TT_AABB ); *result = t; } @@ -200,7 +214,29 @@ void CG_CapTrace( trace_t *result, const vec3_t start, const vec3_t mins, const trap_CM_CapsuleTrace( &t, start, end, mins, maxs, 0, mask ); t.entityNum = t.fraction != 1.0 ? ENTITYNUM_WORLD : ENTITYNUM_NONE; // check all other solid models - CG_ClipMoveToEntities( start, mins, maxs, end, skipNumber, mask, &t, qtrue ); + CG_ClipMoveToEntities( start, mins, maxs, end, skipNumber, mask, &t, TT_CAPSULE ); + + *result = t; +} + +/* +================ +CG_BiSphereTrace +================ +*/ +void CG_BiSphereTrace( trace_t *result, const vec3_t start, const vec3_t end, + const float startRadius, const float endRadius, int skipNumber, int mask ) +{ + trace_t t; + vec3_t mins, maxs; + + mins[ 0 ] = startRadius; + maxs[ 0 ] = endRadius; + + trap_CM_BiSphereTrace( &t, start, end, startRadius, endRadius, 0, mask ); + t.entityNum = t.fraction != 1.0 ? ENTITYNUM_WORLD : ENTITYNUM_NONE; + // check all other solid models + CG_ClipMoveToEntities( start, mins, maxs, end, skipNumber, mask, &t, TT_BISPHERE ); *result = t; } |