mirror of
https://github.com/UberGames/ioef.git
synced 2025-01-31 04:50:37 +00:00
* Early out AABB collision optimisation from Robert Beckebans (Xreal)
This commit is contained in:
parent
0c99c0c1d2
commit
64239037e0
5 changed files with 69 additions and 1 deletions
|
@ -1386,6 +1386,11 @@ void CM_TraceThroughPatchCollide( traceWork_t *tw, const struct patchCollide_s *
|
||||||
static cvar_t *cv;
|
static cvar_t *cv;
|
||||||
#endif //BSPC
|
#endif //BSPC
|
||||||
|
|
||||||
|
if ( !BoundsIntersect( tw->bounds[0], tw->bounds[1],
|
||||||
|
pc->bounds[0], pc->bounds[1] ) ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (tw->isPoint) {
|
if (tw->isPoint) {
|
||||||
CM_TracePointThroughPatchCollide( tw, pc );
|
CM_TracePointThroughPatchCollide( tw, pc );
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -250,6 +250,10 @@ int CM_PointContents( const vec3_t p, clipHandle_t model ) {
|
||||||
brushnum = cm.leafbrushes[leaf->firstLeafBrush+k];
|
brushnum = cm.leafbrushes[leaf->firstLeafBrush+k];
|
||||||
b = &cm.brushes[brushnum];
|
b = &cm.brushes[brushnum];
|
||||||
|
|
||||||
|
if ( !BoundsIntersectPoint( b->bounds[0], b->bounds[1], p ) ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// see if the point is in the brush
|
// see if the point is in the brush
|
||||||
for ( i = 0 ; i < b->numsides ; i++ ) {
|
for ( i = 0 ; i < b->numsides ; i++ ) {
|
||||||
d = DotProduct( p, b->sides[i].plane->normal );
|
d = DotProduct( p, b->sides[i].plane->normal );
|
||||||
|
|
|
@ -685,6 +685,11 @@ void CM_TraceThroughLeaf( traceWork_t *tw, cLeaf_t *leaf ) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( !BoundsIntersect( tw->bounds[0], tw->bounds[1],
|
||||||
|
b->bounds[0], b->bounds[1] ) ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
CM_TraceThroughBrush( tw, b );
|
CM_TraceThroughBrush( tw, b );
|
||||||
if ( !tw->trace.fraction ) {
|
if ( !tw->trace.fraction ) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -1037,6 +1037,53 @@ void AddPointToBounds( const vec3_t v, vec3_t mins, vec3_t maxs ) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
qboolean BoundsIntersect(const vec3_t mins, const vec3_t maxs,
|
||||||
|
const vec3_t mins2, const vec3_t maxs2)
|
||||||
|
{
|
||||||
|
if ( maxs[0] < mins2[0] ||
|
||||||
|
maxs[1] < mins2[1] ||
|
||||||
|
maxs[2] < mins2[2] ||
|
||||||
|
mins[0] > maxs2[0] ||
|
||||||
|
mins[1] > maxs2[1] ||
|
||||||
|
mins[2] > maxs2[2])
|
||||||
|
{
|
||||||
|
return qfalse;
|
||||||
|
}
|
||||||
|
|
||||||
|
return qtrue;
|
||||||
|
}
|
||||||
|
|
||||||
|
qboolean BoundsIntersectSphere(const vec3_t mins, const vec3_t maxs,
|
||||||
|
const vec3_t origin, vec_t radius)
|
||||||
|
{
|
||||||
|
if ( origin[0] - radius > maxs[0] ||
|
||||||
|
origin[0] + radius < mins[0] ||
|
||||||
|
origin[1] - radius > maxs[1] ||
|
||||||
|
origin[1] + radius < mins[1] ||
|
||||||
|
origin[2] - radius > maxs[2] ||
|
||||||
|
origin[2] + radius < mins[2])
|
||||||
|
{
|
||||||
|
return qfalse;
|
||||||
|
}
|
||||||
|
|
||||||
|
return qtrue;
|
||||||
|
}
|
||||||
|
|
||||||
|
qboolean BoundsIntersectPoint(const vec3_t mins, const vec3_t maxs,
|
||||||
|
const vec3_t origin)
|
||||||
|
{
|
||||||
|
if ( origin[0] > maxs[0] ||
|
||||||
|
origin[0] < mins[0] ||
|
||||||
|
origin[1] > maxs[1] ||
|
||||||
|
origin[1] < mins[1] ||
|
||||||
|
origin[2] > maxs[2] ||
|
||||||
|
origin[2] < mins[2])
|
||||||
|
{
|
||||||
|
return qfalse;
|
||||||
|
}
|
||||||
|
|
||||||
|
return qtrue;
|
||||||
|
}
|
||||||
|
|
||||||
vec_t VectorNormalize( vec3_t v ) {
|
vec_t VectorNormalize( vec3_t v ) {
|
||||||
// NOTE: TTimo - Apple G4 altivec source uses double?
|
// NOTE: TTimo - Apple G4 altivec source uses double?
|
||||||
|
|
|
@ -530,7 +530,7 @@ vec_t VectorLengthSquared( const vec3_t v );
|
||||||
vec_t Distance( const vec3_t p1, const vec3_t p2 );
|
vec_t Distance( const vec3_t p1, const vec3_t p2 );
|
||||||
|
|
||||||
vec_t DistanceSquared( const vec3_t p1, const vec3_t p2 );
|
vec_t DistanceSquared( const vec3_t p1, const vec3_t p2 );
|
||||||
|
|
||||||
void VectorNormalizeFast( vec3_t v );
|
void VectorNormalizeFast( vec3_t v );
|
||||||
|
|
||||||
void VectorInverse( vec3_t v );
|
void VectorInverse( vec3_t v );
|
||||||
|
@ -563,6 +563,13 @@ void AxisCopy( vec3_t in[3], vec3_t out[3] );
|
||||||
void SetPlaneSignbits( struct cplane_s *out );
|
void SetPlaneSignbits( struct cplane_s *out );
|
||||||
int BoxOnPlaneSide (vec3_t emins, vec3_t emaxs, struct cplane_s *plane);
|
int BoxOnPlaneSide (vec3_t emins, vec3_t emaxs, struct cplane_s *plane);
|
||||||
|
|
||||||
|
qboolean BoundsIntersect(const vec3_t mins, const vec3_t maxs,
|
||||||
|
const vec3_t mins2, const vec3_t maxs2);
|
||||||
|
qboolean BoundsIntersectSphere(const vec3_t mins, const vec3_t maxs,
|
||||||
|
const vec3_t origin, vec_t radius);
|
||||||
|
qboolean BoundsIntersectPoint(const vec3_t mins, const vec3_t maxs,
|
||||||
|
const vec3_t origin);
|
||||||
|
|
||||||
float AngleMod(float a);
|
float AngleMod(float a);
|
||||||
float LerpAngle (float from, float to, float frac);
|
float LerpAngle (float from, float to, float frac);
|
||||||
float AngleSubtract( float a1, float a2 );
|
float AngleSubtract( float a1, float a2 );
|
||||||
|
|
Loading…
Reference in a new issue