3 #define FINDMINMAX(x0, x1, x2, min, max) \ 16 if(normal[q]>0.0
f) { vmin[q]=-maxbox[q]; vmax[q]=maxbox[q]; }
17 else { vmin[q]=maxbox[q]; vmax[q]=-maxbox[q]; }
19 if((normal|vmin)+d>0.0
f)
return FALSE;
20 if((normal|vmax)+d>=0.0
f)
return TRUE;
26 #define AXISTEST_X01(a, b, fa, fb) \ 27 min = a*v0.y - b*v0.z; \ 28 max = a*v2.y - b*v2.z; \ 29 if(min>max) {const float tmp=max; max=min; min=tmp; } \ 30 rad = fa * extents.y + fb * extents.z; \ 31 if(min>rad || max<-rad) return FALSE; 34 #define AXISTEST_X2(a, b, fa, fb) \ 35 min = a*v0.y - b*v0.z; \ 36 max = a*v1.y - b*v1.z; \ 37 if(min>max) {const float tmp=max; max=min; min=tmp; } \ 38 rad = fa * extents.y + fb * extents.z; \ 39 if(min>rad || max<-rad) return FALSE; 42 #define AXISTEST_Y02(a, b, fa, fb) \ 43 min = b*v0.z - a*v0.x; \ 44 max = b*v2.z - a*v2.x; \ 45 if(min>max) {const float tmp=max; max=min; min=tmp; } \ 46 rad = fa * extents.x + fb * extents.z; \ 47 if(min>rad || max<-rad) return FALSE; 50 #define AXISTEST_Y1(a, b, fa, fb) \ 51 min = b*v0.z - a*v0.x; \ 52 max = b*v1.z - a*v1.x; \ 53 if(min>max) {const float tmp=max; max=min; min=tmp; } \ 54 rad = fa * extents.x + fb * extents.z; \ 55 if(min>rad || max<-rad) return FALSE; 58 #define AXISTEST_Z12(a, b, fa, fb) \ 59 min = a*v1.x - b*v1.y; \ 60 max = a*v2.x - b*v2.y; \ 61 if(min>max) {const float tmp=max; max=min; min=tmp; } \ 62 rad = fa * extents.x + fb * extents.y; \ 63 if(min>rad || max<-rad) return FALSE; 66 #define AXISTEST_Z0(a, b, fa, fb) \ 67 min = a*v0.x - b*v0.y; \ 68 max = a*v1.x - b*v1.y; \ 69 if(min>max) {const float tmp=max; max=min; min=tmp; } \ 70 rad = fa * extents.x + fb * extents.y; \ 71 if(min>rad || max<-rad) return FALSE; 78 #define IMPLEMENT_CLASS3_TESTS \ 82 const float fey0 = fabsf(e0.y); \ 83 const float fez0 = fabsf(e0.z); \ 84 AXISTEST_X01(e0.z, e0.y, fez0, fey0); \ 85 const float fex0 = fabsf(e0.x); \ 86 AXISTEST_Y02(e0.z, e0.x, fez0, fex0); \ 87 AXISTEST_Z12(e0.y, e0.x, fey0, fex0); \ 89 const float fey1 = fabsf(e1.y); \ 90 const float fez1 = fabsf(e1.z); \ 91 AXISTEST_X01(e1.z, e1.y, fez1, fey1); \ 92 const float fex1 = fabsf(e1.x); \ 93 AXISTEST_Y02(e1.z, e1.x, fez1, fex1); \ 94 AXISTEST_Z0(e1.y, e1.x, fey1, fex1); \ 96 const Point e2 = mLeafVerts[0] - mLeafVerts[2]; \ 97 const float fey2 = fabsf(e2.y); \ 98 const float fez2 = fabsf(e2.z); \ 99 AXISTEST_X2(e2.z, e2.y, fez2, fey2); \ 100 const float fex2 = fabsf(e2.x); \ 101 AXISTEST_Y1(e2.z, e2.x, fez2, fex2); \ 102 AXISTEST_Z12(e2.y, e2.x, fey2, fex2); 162 if(min>extents.
x || max<-extents.
x)
return FALSE;
170 if(min>extents.
y || max<-extents.
y)
return FALSE;
178 if(min>extents.
z || max<-extents.
z)
return FALSE;
183 const Point e0 = v1 - v0;
184 const Point e1 = v2 - v1;
185 const Point normal = e0 ^ e1;
186 const float d = -normal|v0;
201 mNbVolumePrimTests++;
204 const Point& extents = mBoxExtents;
234 if(min>mBoxExtents.x || max<-mBoxExtents.x)
return FALSE;
237 if(min>mBoxExtents.y || max<-mBoxExtents.y)
return FALSE;
240 if(min>mBoxExtents.z || max<-mBoxExtents.z)
return FALSE;
245 const Point e0 = v1 - v0;
246 const Point e1 = v2 - v1;
247 const Point normal = e0 ^ e1;
248 const float d = -normal|v0;
262 mNbVolumePrimTests++;
265 const Point& center = mBox.mCenter;
266 const Point& extents = mBox.mExtents;
307 if(min>extents.
x || max<-extents.
x)
return FALSE;
315 if(min>extents.
y || max<-extents.
y)
return FALSE;
323 if(min>extents.
z || max<-extents.
z)
return FALSE;
328 const Point e0 = v1 - v0;
329 const Point e1 = v2 - v1;
330 const Point normal = e0 ^ e1;
331 const float d = -normal|v0;
Point mLeafVerts[3]
Triangle vertices.
static int min(int a, int b)
inline_ BOOL planeBoxOverlap(const Point &normal, const float d, const Point &maxbox)
TO BE DOCUMENTED.
inline_ BOOL TriBoxOverlap(const Point ¢er, const Point &extents)
bool mFullPrimBoxTest
Perform full Primitive-BV tests (true) or SAT-lite tests (false)
#define FINDMINMAX(x0, x1, x2, min, max)
This macro quickly finds the min & max values among 3 variables.
int BOOL
Another boolean type.
unsigned int udword
sizeof(udword) must be 4
udword mNbBVPrimTests
Number of BV-Primitive tests.
inline_ float FCMin3(float a, float b, float c)
A global function to find MIN(a,b,c) using FCOMI/FCMOV.
#define IMPLEMENT_CLASS3_TESTS
inline_ float FCMax3(float a, float b, float c)
A global function to find MAX(a,b,c) using FCOMI/FCMOV.
static int max(int a, int b)