r1121 - trunk/code/qcommon
DONOTREPLY at icculus.org
DONOTREPLY at icculus.org
Fri Jul 27 17:52:31 EDT 2007
Author: tma
Date: 2007-07-27 17:52:31 -0400 (Fri, 27 Jul 2007)
New Revision: 1121
Modified:
trunk/code/qcommon/cm_patch.c
trunk/code/qcommon/cm_test.c
trunk/code/qcommon/cm_trace.c
trunk/code/qcommon/q_math.c
trunk/code/qcommon/q_shared.h
Log:
* Early out AABB collision optimisation from Robert Beckebans (Xreal)
Modified: trunk/code/qcommon/cm_patch.c
===================================================================
--- trunk/code/qcommon/cm_patch.c 2007-07-25 21:28:15 UTC (rev 1120)
+++ trunk/code/qcommon/cm_patch.c 2007-07-27 21:52:31 UTC (rev 1121)
@@ -1386,6 +1386,11 @@
static cvar_t *cv;
#endif //BSPC
+ if ( !BoundsIntersect( tw->bounds[0], tw->bounds[1],
+ pc->bounds[0], pc->bounds[1] ) ) {
+ return;
+ }
+
if (tw->isPoint) {
CM_TracePointThroughPatchCollide( tw, pc );
return;
Modified: trunk/code/qcommon/cm_test.c
===================================================================
--- trunk/code/qcommon/cm_test.c 2007-07-25 21:28:15 UTC (rev 1120)
+++ trunk/code/qcommon/cm_test.c 2007-07-27 21:52:31 UTC (rev 1121)
@@ -250,6 +250,10 @@
brushnum = cm.leafbrushes[leaf->firstLeafBrush+k];
b = &cm.brushes[brushnum];
+ if ( !BoundsIntersectPoint( b->bounds[0], b->bounds[1], p ) ) {
+ continue;
+ }
+
// see if the point is in the brush
for ( i = 0 ; i < b->numsides ; i++ ) {
d = DotProduct( p, b->sides[i].plane->normal );
Modified: trunk/code/qcommon/cm_trace.c
===================================================================
--- trunk/code/qcommon/cm_trace.c 2007-07-25 21:28:15 UTC (rev 1120)
+++ trunk/code/qcommon/cm_trace.c 2007-07-27 21:52:31 UTC (rev 1121)
@@ -685,6 +685,11 @@
continue;
}
+ if ( !BoundsIntersect( tw->bounds[0], tw->bounds[1],
+ b->bounds[0], b->bounds[1] ) ) {
+ continue;
+ }
+
CM_TraceThroughBrush( tw, b );
if ( !tw->trace.fraction ) {
return;
Modified: trunk/code/qcommon/q_math.c
===================================================================
--- trunk/code/qcommon/q_math.c 2007-07-25 21:28:15 UTC (rev 1120)
+++ trunk/code/qcommon/q_math.c 2007-07-27 21:52:31 UTC (rev 1121)
@@ -1037,7 +1037,54 @@
}
}
+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 ) {
// NOTE: TTimo - Apple G4 altivec source uses double?
float length, ilength;
Modified: trunk/code/qcommon/q_shared.h
===================================================================
--- trunk/code/qcommon/q_shared.h 2007-07-25 21:28:15 UTC (rev 1120)
+++ trunk/code/qcommon/q_shared.h 2007-07-27 21:52:31 UTC (rev 1121)
@@ -530,7 +530,7 @@
vec_t Distance( 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 VectorInverse( vec3_t v );
@@ -563,6 +563,13 @@
void SetPlaneSignbits( struct cplane_s *out );
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 LerpAngle (float from, float to, float frac);
float AngleSubtract( float a1, float a2 );
More information about the quake3-commits
mailing list