My Project: dynamics.mod/NewtonDynamics/source/core/dgIntersections.h Source File

My Project

dgIntersections.h
Go to the documentation of this file.
1 /* Copyright (c) <2003-2011> <Julio Jerez, Newton Game Dynamics>
2 *
3 * This software is provided 'as-is', without any express or implied
4 * warranty. In no event will the authors be held liable for any damages
5 * arising from the use of this software.
6 *
7 * Permission is granted to anyone to use this software for any purpose,
8 * including commercial applications, and to alter it and redistribute it
9 * freely, subject to the following restrictions:
10 *
11 * 1. The origin of this software must not be misrepresented; you must not
12 * claim that you wrote the original software. If you use this software
13 * in a product, an acknowledgment in the product documentation would be
14 * appreciated but is not required.
15 *
16 * 2. Altered source versions must be plainly marked as such, and must not be
17 * misrepresented as being the original software.
18 *
19 * 3. This notice may not be removed or altered from any source distribution.
20 */
21
22 #ifndef __dgIntersections__
23 #define __dgIntersections__
24
25 #include "dgStdafx.h"
26 #include "dgObb.h"
27 #include "dgDebug.h"
28 #include "dgVector.h"
29 #include "dgMatrix.h"
30
31 class dgPlane;
32 class dgObject;
33 class dgPolyhedra;
34
35 enum dgIntersectStatus
36 {
37 t_StopSearh,
38 t_ContinueSearh
39 };
40
41 typedef dgIntersectStatus (*dgAABBIntersectCallback) (void* const context,
42 const dgFloat32* const polygon, dgInt32 strideInBytes,
43 const dgInt32* const indexArray, dgInt32 indexCount, dgFloat32 hitDistance);
44
45 typedef dgFloat32 (*dgRayIntersectCallback) (void* const context,
46 const dgFloat32* const polygon, dgInt32 strideInBytes,
47 const dgInt32* const indexArray, dgInt32 indexCount);
48
49
50
51 DG_MSC_VECTOR_ALIGMENT
52 class dgFastRayTest
53 {
54 public:
55 DG_INLINE dgFastRayTest(const dgVector& l0, const dgVector& l1)
56 :m_p0 (l0)
57 ,m_p1(l1)
58 ,m_diff ((l1 - l0) | dgVector::m_wOne)
59 ,m_minT(dgFloat32 (0.0f))
60 ,m_maxT(dgFloat32 (1.0f))
61 ,m_zero(dgFloat32 (0.0f))
62 {
63 dgAssert (m_p0.m_w == dgFloat32 (0.0f));
64 dgAssert (m_p1.m_w == dgFloat32 (0.0f));
65 dgAssert (m_diff.m_w == dgFloat32 (1.0f));
66
67 m_isParallel = (m_diff.Abs() < dgVector (1.0e-8f));
68
69 m_dpInv = (((dgVector (dgFloat32 (1.0e-20)) & m_isParallel) | m_diff.AndNot(m_isParallel)).Reciproc ()) & dgVector::m_triplexMask;
70 m_dpBaseInv = m_dpInv;
71
72 dgFloat32 mag = dgSqrt (m_diff % m_diff);
73 m_dirError = -dgFloat32 (0.0175f) * mag;
74 m_magRayTest = dgMax (mag, dgFloat32 (1.0f));
75 }
76
77
78 dgFloat32 PolygonIntersect (const dgVector& normal, dgFloat32 maxT, const dgFloat32* const polygon, dgInt32 strideInBytes, const dgInt32* const indexArray, dgInt32 indexCount) const;
79 dgFloat32 PolygonIntersectFallback (const dgVector& normal, dgFloat32 maxT, const dgFloat32* const polygon, dgInt32 strideInBytes, const dgInt32* const indexArray, dgInt32 indexCount) const;
80
81 DG_INLINE dgInt32 BoxTest (const dgVector& minBox, const dgVector& maxBox) const
82 {
83 #if 1
84 dgVector test (((m_p0 <= minBox) | (m_p0 >= maxBox)) & m_isParallel);
85 if (test.GetSignMask() & 0x07) {
86 return 0;
87 }
88 dgVector tt0 ((minBox - m_p0).CompProduct4(m_dpInv));
89 dgVector tt1 ((maxBox - m_p0).CompProduct4(m_dpInv));
90 dgVector t0 (m_minT.GetMax(tt0.GetMin(tt1)));
91 dgVector t1 (m_maxT.GetMin(tt0.GetMax(tt1)));
92 t0 = t0.GetMax(t0.ShiftTripleRight());
93 t1 = t1.GetMin(t1.ShiftTripleRight());
94 t0 = t0.GetMax(t0.ShiftTripleRight());
95 t1 = t1.GetMin(t1.ShiftTripleRight());
96 return ((t0 < t1).GetSignMask() & 1);
97
98 #else
99
100 dgFloat32 tmin = 0.0f;
101 dgFloat32 tmax = 1.0f;
102
103 for (dgInt32 i = 0; i < 3; i++) {
104 if (m_isParallel[i]) {
105 if (m_p0[i] <= minBox[i] || m_p0[i] >= maxBox[i]) {
106 return 0;
107 }
108 } else {
109 dgFloat32 t1 = (minBox[i] - m_p0[i]) * m_dpInv[i];
110 dgFloat32 t2 = (maxBox[i] - m_p0[i]) * m_dpInv[i];
111
112 if (t1 > t2) {
113 dgSwap(t1, t2);
114 }
115 if (t1 > tmin) {
116 tmin = t1;
117 }
118 if (t2 < tmax) {
119 tmax = t2;
120 }
121 if (tmin > tmax) {
122 return 0;
123 }
124 }
125 }
126 return 0x1;
127 #endif
128 }
129
130 DG_INLINE dgFloat32 BoxIntersect (const dgVector& minBox, const dgVector& maxBox) const
131 {
132 dgVector test (((m_p0 <= minBox) | (m_p0 >= maxBox)) & m_isParallel);
133 if (test.GetSignMask() & 0x07) {
134 return dgFloat32 (1.2f);
135 }
136 dgVector tt0 ((minBox - m_p0).CompProduct4(m_dpInv));
137 dgVector tt1 ((maxBox - m_p0).CompProduct4(m_dpInv));
138 dgVector t0 (m_minT.GetMax(tt0.GetMin(tt1)));
139 dgVector t1 (m_maxT.GetMin(tt0.GetMax(tt1)));
140 t0 = t0.GetMax(t0.ShiftTripleRight());
141 t1 = t1.GetMin(t1.ShiftTripleRight());
142 t0 = t0.GetMax(t0.ShiftTripleRight());
143 t1 = t1.GetMin(t1.ShiftTripleRight());
144 dgVector mask (t0 < t1);
145 dgVector maxDist (dgFloat32 (1.2f));
146 t0 = (t0 & mask) | maxDist.AndNot(mask);
147 dgAssert ((mask.GetSignMask() & 1) == (t0.m_x < dgFloat32 (1.0f)));
148 return t0.GetScalar();
149 }
150
151
152 dgVector m_p0;
153 dgVector m_p1;
154 dgVector m_diff;
155 dgVector m_dpInv;
156 dgVector m_dpBaseInv;
157 dgVector m_minT;
158 dgVector m_maxT;
159 dgVector m_zero;
160 dgVector m_isParallel;
161 dgFloat32 m_dirError;
162 dgFloat32 m_magRayTest;
163 } DG_GCC_VECTOR_ALIGMENT;
164
165
166
167 bool dgRayBoxClip (dgVector& ray_p0, dgVector& ray_p1, const dgVector& boxP0, const dgVector& boxP1);
168 dgVector dgPointToRayDistance (const dgVector& point, const dgVector& ray_p0, const dgVector& ray_p1);
169 void dgRayToRayDistance (const dgVector& ray_p0, const dgVector& ray_p1, const dgVector& ray_q0, const dgVector& ray_q1, dgVector& p0Out, dgVector& p1Out);
170 dgVector dgPointToTriangleDistance (const dgVector& point, const dgVector& p0, const dgVector& p1, const dgVector& p2, const dgVector& normal);
171 dgBigVector dgPointToTriangleDistance (const dgBigVector& point, const dgBigVector& p0, const dgBigVector& p1, const dgBigVector& p2, const dgBigVector& normal);
172 dgFloat32 dgSweepLineToPolygonTimeOfImpact (const dgVector& p0, const dgVector& p1, dgFloat32 radius, dgInt32 count, const dgVector* const polygon, const dgVector& normal, dgVector& normalOut, dgVector& contactOut);
173 dgFloat32 dgRayCastBox (const dgVector& p0, const dgVector& p1, const dgVector& boxP0, const dgVector& boxP1, dgVector& normalOut);
174 dgFloat32 dgRayCastSphere (const dgVector& p0, const dgVector& p1, const dgVector& origin, dgFloat32 radius);
175
176 DG_INLINE dgInt32 dgOverlapTest (const dgVector& p0, const dgVector& p1, const dgVector& q0, const dgVector& q1)
177 {
178 // dgInt32 test = ((p0.m_x < q1.m_x) && (p1.m_x > q0.m_x) && (p0.m_z < q1.m_z) && (p1.m_z > q0.m_z) && (p0.m_y < q1.m_y) && (p1.m_y > q0.m_y));
179 // return test
180 dgVector val ((p0 < q1) & (p1 > q0));
181 dgInt32 mask = val.GetSignMask();
182 return ((mask & 0x07) == 0x07);
183 }
184
185
186 DG_INLINE dgInt32 dgBoxInclusionTest (const dgVector& p0, const dgVector& p1, const dgVector& q0, const dgVector& q1)
187 {
188 // dgInt32 test = (p0.m_x >= q0.m_x) && (p0.m_y >= q0.m_y) && (p0.m_z >= q0.m_z) && (p1.m_x <= q1.m_x) && (p1.m_y <= q1.m_y) && (p1.m_z <= q1.m_z);
189 // return test;
190
191 dgVector val ((p0 >= q0) & (p1 <= q1));
192 dgInt32 mask = val.GetSignMask();
193 return ((mask & 0x07) == 0x07);
194 }
195
196
197 DG_INLINE dgInt32 dgCompareBox (const dgVector& p0, const dgVector& p1, const dgVector& q0, const dgVector& q1)
198 {
199 dgAssert(0);
200 return (p0.m_x != q0.m_x) || (p0.m_y != q0.m_y) || (p0.m_z != q0.m_z) || (p1.m_x != q1.m_x) || (p1.m_y != q1.m_y) || (p1.m_z != q1.m_z);
201 }
202
203
204 DG_INLINE void dgMovingAABB (dgVector& p0, dgVector& p1, const dgVector& veloc, const dgVector& omega, dgFloat32 timestep, dgFloat32 maxRadius, dgFloat32 minRadius)
205 {
206 dgVector linearStep (veloc.Scale3 (timestep));
207
208 // estimate the maximum effect of the angular velocity and enlarge that box by that value (use 45 degrees as max angle not 90)
209 dgFloat32 maxAngle = dgMin (dgSqrt ((omega % omega) * timestep * timestep), dgFloat32 (45.0f * 3.14159f / 180.0f));
210
211 dgFloat32 angularTravel = (maxRadius - minRadius) * maxAngle;
212 dgVector angularStep (angularTravel, angularTravel, angularTravel, dgFloat32 (0.0f));
213
214 dgVector r0 (p0 - angularStep);
215 dgVector r1 (p1 + angularStep);
216 dgVector q0 (r0 + linearStep);
217 dgVector q1 (r1 + linearStep);
218 //p0 = dgVector (dgMin (r0.m_x, q0.m_x), dgMin (r0.m_y, q0.m_y), dgMin (r0.m_z, q0.m_z), dgFloat32 (0.0f));
219 p0 = r0.GetMin (q0);
220 //p1 = dgVector (dgMax (r1.m_x, q1.m_x), dgMax (r1.m_y, q1.m_y), dgMax (r1.m_z, q1.m_z), dgFloat32 (0.0f));
221 p1 = r1.GetMax (q1);
222 p0.m_w = dgFloat32 (0.0f);
223 p1.m_w = dgFloat32 (0.0f);
224 }
225
226
227 DG_INLINE dgFloat32 BoxPenetration (const dgVector& minBox, const dgVector& maxBox)
228 {
229 dgVector mask ((minBox.CompProduct4(maxBox)) < dgVector (dgFloat32 (0.0f)));
230 dgVector dist (maxBox.GetMin (minBox.Abs()) & mask);
231 dist = dist.GetMin(dist.ShiftTripleRight());
232 dist = dist.GetMin(dist.ShiftTripleRight());
233 return dist.GetScalar();
234 }
235
236 DG_INLINE dgFloat32 dgBoxDistanceToOrigin2 (const dgVector& minBox, const dgVector& maxBox)
237 {
238 dgVector mask ((minBox.CompProduct4(maxBox)) > dgVector (dgFloat32 (0.0f)));
239 dgVector dist (maxBox.Abs().GetMin (minBox.Abs()) & mask);
240 return dist.DotProduct4(dist).GetScalar();
241 }
242
243
244 DG_MSC_VECTOR_ALIGMENT
245 class dgFastAABBInfo: public dgObb
246 {
247 public:
248 DG_INLINE dgFastAABBInfo()
249 :dgObb()
250 ,m_absDir(dgGetIdentityMatrix())
251 {
252 }
253
254 DG_INLINE dgFastAABBInfo(const dgMatrix& matrix, const dgVector& size)
255 :dgObb(matrix, size)
256 {
257 SetTransposeAbsMatrix (matrix);
258 dgVector size1 (matrix[0].Abs().Scale4(size.m_x) + matrix[1].Abs().Scale4(size.m_y) + matrix[2].Abs().Scale4(size.m_z));
259 m_p0 = (matrix[3] - size1) & dgVector::m_triplexMask;
260 m_p1 = (matrix[3] + size1) & dgVector::m_triplexMask;
261 }
262
263 DG_INLINE dgFastAABBInfo(const dgVector& p0, const dgVector& p1)
264 :dgObb(dgGetIdentityMatrix(), (p1 - p0).CompProduct4(dgVector::m_half))
265 ,m_absDir(dgGetIdentityMatrix())
266 ,m_p0(p0)
267 ,m_p1(p1)
268 {
269 m_posit = ((p1 + p0).CompProduct4(dgVector::m_half) & dgVector::m_triplexMask) | dgVector::m_wOne;
270 }
271
272 DG_INLINE void SetTransposeAbsMatrix (const dgMatrix& matrix)
273 {
274 m_absDir = matrix.Transpose();
275 m_absDir[0] = m_absDir[0].Abs();
276 m_absDir[1] = m_absDir[1].Abs();
277 m_absDir[2] = m_absDir[2].Abs();
278 m_absDir[3] = dgVector::m_wOne;
279 }
280
281 DG_INLINE dgFloat32 PolygonBoxRayDistance (const dgVector& faceNormal, dgInt32 indexCount, const dgInt32* const indexArray, dgInt32 stride, const dgFloat32* const vertexArray, const dgFastRayTest& ray) const
282 {
283 dgVector minBox;
284 dgVector maxBox;
285 MakeBox1 (indexCount, indexArray, stride, vertexArray, minBox, maxBox);
286 dgFloat32 dist0 = ray.BoxIntersect(minBox, maxBox);
287 if (dist0 < dgFloat32 (1.0f)) {
288 dgMatrix faceMatrix (MakeFaceMatrix (faceNormal, indexCount, indexArray, stride, vertexArray));
289
290 MakeBox2 (faceMatrix, indexCount, indexArray, stride, vertexArray, minBox, maxBox);
291 dgVector veloc (faceMatrix.RotateVector(ray.m_diff) & dgVector::m_triplexMask);
292 dgFastRayTest localRay (dgVector (dgFloat32 (0.0f)), veloc);
293 dgFloat32 dist1 = localRay.BoxIntersect(minBox, maxBox);
294 dist0 = dgMax (dist1, dist0);
295 }
296 return dist0;
297 }
298
299
300 DG_INLINE dgFloat32 PolygonBoxDistance (const dgVector& faceNormal, dgInt32 indexCount, const dgInt32* const indexArray, dgInt32 stride, const dgFloat32* const vertexArray) const
301 {
302 dgVector minBox;
303 dgVector maxBox;
304 MakeBox1 (indexCount, indexArray, stride, vertexArray, minBox, maxBox);
305 dgFloat32 dist0 = BoxPenetration (minBox, maxBox);
306 if (dist0 > dgFloat32 (0.0f)) {
307 dgMatrix faceMatrix (MakeFaceMatrix (faceNormal, indexCount, indexArray, stride, vertexArray));
308 MakeBox2 (faceMatrix, indexCount, indexArray, stride, vertexArray, minBox, maxBox);
309 dgFloat32 dist1 = BoxPenetration (minBox, maxBox);
310 dist0 = (dist1 > dgFloat32 (0.0f)) ? dgMax (dist0, dist1) : dgFloat32 (0.0f);
311 }
312 return dist0;
313 }
314
315 private:
316 DG_INLINE void MakeBox1 (dgInt32 indexCount, const dgInt32* const indexArray, dgInt32 stride, const dgFloat32* const vertexArray, dgVector& minBox, dgVector& maxBox) const
317 {
318 //const dgMatrix& matrix = *this;
319 //dgVector faceBoxP0 (m_scale.CompProduct4(matrix.UntransformVector(dgVector(&vertexArray[indexArray[0] * stride]))));
320 //dgVector faceBoxP0 (m_scale.CompProduct4(dgVector(&vertexArray[indexArray[0] * stride])));
321 dgVector faceBoxP0 (&vertexArray[indexArray[0] * stride]);
322 dgVector faceBoxP1 (faceBoxP0);
323 for (dgInt32 i = 1; i < indexCount; i ++) {
324 //dgVector p (m_scale.CompProduct4 (matrix.UntransformVector(dgVector(&vertexArray[indexArray[i] * stride]))));
325 //dgVector p (m_scale.CompProduct4 (dgVector(&vertexArray[indexArray[i] * stride])));
326 dgVector p (&vertexArray[indexArray[i] * stride]);
327 faceBoxP0 = faceBoxP0.GetMin(p);
328 faceBoxP1 = faceBoxP1.GetMax(p);
329 }
330 //minBox = faceBoxP0 - m_size;
331 //maxBox = faceBoxP1 + m_size;
332 minBox = faceBoxP0 - m_p1;
333 maxBox = faceBoxP1 - m_p0;
334 }
335
336 DG_INLINE void MakeBox2 (const dgMatrix& faceMatrix, dgInt32 indexCount, const dgInt32* const indexArray, dgInt32 stride, const dgFloat32* const vertexArray, dgVector& minBox, dgVector& maxBox) const
337 {
338 dgVector faceBoxP0 (faceMatrix.TransformVector (dgVector (&vertexArray[indexArray[0] * stride])));
339 dgVector faceBoxP1 (faceBoxP0);
340 for (dgInt32 i = 1; i < indexCount; i ++) {
341 dgVector p (faceMatrix.TransformVector (dgVector (&vertexArray[indexArray[i] * stride])));
342 faceBoxP0 = faceBoxP0.GetMin(p);
343 faceBoxP1 = faceBoxP1.GetMax(p);
344 }
345 faceBoxP0 = faceBoxP0 & dgVector::m_triplexMask;
346 faceBoxP1 = faceBoxP1 & dgVector::m_triplexMask;
347
348 dgMatrix matrix = *this * faceMatrix;
349 dgVector size (matrix[0].Abs().Scale4(m_size.m_x) + matrix[1].Abs().Scale4(m_size.m_y) + matrix[2].Abs().Scale4(m_size.m_z));
350 dgVector boxP0 ((matrix.m_posit - size) & dgVector::m_triplexMask);
351 dgVector boxP1 ((matrix.m_posit + size) & dgVector::m_triplexMask);
352
353 minBox = faceBoxP0 - boxP1;
354 maxBox = faceBoxP1 - boxP0;
355 }
356
357
358 DG_INLINE dgMatrix MakeFaceMatrix (const dgVector& faceNormal, dgInt32 indexCount, const dgInt32* const indexArray, dgInt32 stride, const dgFloat32* const vertexArray) const
359 {
360 dgMatrix faceMatrix;
361 dgVector origin (&vertexArray[indexArray[0] * stride]);
362
363 faceMatrix[0] = faceNormal;
364 faceMatrix[1] = dgVector (&vertexArray[indexArray[1] * stride]) - origin;
365 faceMatrix[1] = faceMatrix[1].CompProduct4 (faceMatrix[1].DotProduct4(faceMatrix[1]).InvSqrt());
366 faceMatrix[2] = faceMatrix[0] * faceMatrix[1];
367 faceMatrix[3] = origin | dgVector::m_wOne;
368 return faceMatrix.Inverse();
369 }
370
371 protected:
372 dgMatrix m_absDir;
373 dgVector m_p0;
374 dgVector m_p1;
375
376 friend class dgAABBPolygonSoup;
377 friend class dgCollisionUserMesh;
378 friend class dgCollisionHeightField;
379 } DG_GCC_VECTOR_ALIGMENT;
380
381
382 #endif
383
dgPlane
Definition: dgPlane.h:29
dgFastAABBInfo::m_absDir
dgMatrix m_absDir
Definition: dgIntersections.h:372
dgSweepLineToPolygonTimeOfImpact
dgFloat32 dgSweepLineToPolygonTimeOfImpact(const dgVector &p0, const dgVector &p1, dgFloat32 radius, dgInt32 count, const dgVector *const polygon, const dgVector &normal, dgVector &normalOut, dgVector &contactOut)
Definition: dgIntersections.cpp:883
DG_GCC_VECTOR_ALIGMENT
DG_MSC_VECTOR_ALIGMENT class dgFastRayTest DG_GCC_VECTOR_ALIGMENT
dgFastAABBInfo::m_p0
dgVector m_p0
Definition: dgIntersections.h:373
dgMin
DG_INLINE T dgMin(T A, T B)
Definition: dgTypes.h:293
dgFastRayTest
Definition: dgIntersections.h:52
dgDebug.h
dgObb.h
dgRayIntersectCallback
dgFloat32(* dgRayIntersectCallback)(void *const context, const dgFloat32 *const polygon, dgInt32 strideInBytes, const dgInt32 *const indexArray, dgInt32 indexCount)
Definition: dgIntersections.h:45
dgBoxInclusionTest
DG_INLINE dgInt32 dgBoxInclusionTest(const dgVector &p0, const dgVector &p1, const dgVector &q0, const dgVector &q1)
Definition: dgIntersections.h:186
dgObb
Definition: dgObb.h:35
dgVector::m_half
static dgVector m_half
Definition: dgVector.h:1041
DG_INLINE
#define DG_INLINE
Definition: dgTypes.h:178
dgAssert
#define dgAssert(x)
Definition: dgTypes.h:158
dgFloat32
float dgFloat32
Definition: dgTypes.h:233
dgInt32
int dgInt32
Definition: dgTypes.h:218
t_ContinueSearh
Definition: dgIntersections.h:38
dgMatrix::TransformVector
dgVector TransformVector(const dgVector &v) const
Definition: dgMatrix.h:222
dgMax
DG_INLINE T dgMax(T A, T B)
Definition: dgTypes.h:299
dgFastRayTest::m_dpBaseInv
dgVector m_dpBaseInv
Definition: dgIntersections.h:156
dgVector
Definition: dgVector.h:639
dgVector::GetScalar
DG_INLINE dgFloat32 GetScalar() const
Definition: dgVector.h:691
dgRayCastBox
dgFloat32 dgRayCastBox(const dgVector &p0, const dgVector &p1, const dgVector &boxP0, const dgVector &boxP1, dgVector &normalOut)
Definition: dgIntersections.cpp:962
dgSwap
DG_INLINE void dgSwap(T &A, T &B)
Definition: dgTypes.h:323
dgVector::m_z
dgFloat32 m_z
Definition: dgVector.h:1027
dgVector::GetSignMask
DG_INLINE dgInt32 GetSignMask() const
Definition: dgVector.h:971
dgFastRayTest::m_p1
dgVector m_p1
Definition: dgIntersections.h:153
dgVector::Scale3
DG_INLINE dgVector Scale3(dgFloat32 s) const
Definition: dgVector.h:724
dgFastRayTest::BoxTest
DG_INLINE dgInt32 BoxTest(const dgVector &minBox, const dgVector &maxBox) const
Definition: dgIntersections.h:81
dgCompareBox
DG_INLINE dgInt32 dgCompareBox(const dgVector &p0, const dgVector &p1, const dgVector &q0, const dgVector &q1)
Definition: dgIntersections.h:197
dgMatrix.h
dgFastRayTest::m_magRayTest
dgFloat32 m_magRayTest
Definition: dgIntersections.h:162
dgMatrix::RotateVector
dgVector RotateVector(const dgVector &v) const
Definition: dgMatrix.h:200
dgVector.h
dgFastRayTest::BoxIntersect
DG_INLINE dgFloat32 BoxIntersect(const dgVector &minBox, const dgVector &maxBox) const
Definition: dgIntersections.h:130
dgVector::m_wOne
static dgVector m_wOne
Definition: dgVector.h:1039
dgRayToRayDistance
void dgRayToRayDistance(const dgVector &ray_p0, const dgVector &ray_p1, const dgVector &ray_q0, const dgVector &ray_q1, dgVector &p0Out, dgVector &p1Out)
Definition: dgIntersections.cpp:213
DG_MSC_VECTOR_ALIGMENT
#define DG_MSC_VECTOR_ALIGMENT
Definition: dgTypes.h:194
dgVector::m_triplexMask
static dgVector m_triplexMask
Definition: dgVector.h:1045
dgVector::m_x
dgFloat32 m_x
Definition: dgVector.h:1025
dgPolyhedra
Definition: dgPolyhedra.h:62
dgFastRayTest::m_p0
dgVector m_p0
Definition: dgIntersections.h:152
BoxPenetration
DG_INLINE dgFloat32 BoxPenetration(const dgVector &minBox, const dgVector &maxBox)
Definition: dgIntersections.h:227
dgPointToRayDistance
dgVector dgPointToRayDistance(const dgVector &point, const dgVector &ray_p0, const dgVector &ray_p1)
Definition: dgIntersections.cpp:205
dgStdafx.h
dgBoxDistanceToOrigin2
DG_INLINE dgFloat32 dgBoxDistanceToOrigin2(const dgVector &minBox, const dgVector &maxBox)
Definition: dgIntersections.h:236
dgFastRayTest::m_dirError
dgFloat32 m_dirError
Definition: dgIntersections.h:161
dgOverlapTest
DG_INLINE dgInt32 dgOverlapTest(const dgVector &p0, const dgVector &p1, const dgVector &q0, const dgVector &q1)
Definition: dgIntersections.h:176
dgAABBIntersectCallback
dgIntersectStatus(* dgAABBIntersectCallback)(void *const context, const dgFloat32 *const polygon, dgInt32 strideInBytes, const dgInt32 *const indexArray, dgInt32 indexCount, dgFloat32 hitDistance)
Definition: dgIntersections.h:41
dgFastAABBInfo
Definition: dgIntersections.h:245
dgFastRayTest::m_maxT
dgVector m_maxT
Definition: dgIntersections.h:158
dgFastRayTest::PolygonIntersect
dgFloat32 PolygonIntersect(const dgVector &normal, dgFloat32 maxT, const dgFloat32 *const polygon, dgInt32 strideInBytes, const dgInt32 *const indexArray, dgInt32 indexCount) const
Definition: dgIntersections.cpp:76
dgMatrix::Transpose
dgMatrix Transpose() const
Definition: dgMatrix.h:172
dgFastAABBInfo::SetTransposeAbsMatrix
DG_INLINE void SetTransposeAbsMatrix(const dgMatrix &matrix)
Definition: dgIntersections.h:272
dgVector::AndNot
DG_INLINE dgVector AndNot(const dgVector &data) const
Definition: dgVector.h:966
dgFastAABBInfo::PolygonBoxDistance
DG_INLINE dgFloat32 PolygonBoxDistance(const dgVector &faceNormal, dgInt32 indexCount, const dgInt32 *const indexArray, dgInt32 stride, const dgFloat32 *const vertexArray) const
Definition: dgIntersections.h:300
dgFastAABBInfo::dgFastAABBInfo
DG_INLINE dgFastAABBInfo()
Definition: dgIntersections.h:248
dgMovingAABB
DG_INLINE void dgMovingAABB(dgVector &p0, dgVector &p1, const dgVector &veloc, const dgVector &omega, dgFloat32 timestep, dgFloat32 maxRadius, dgFloat32 minRadius)
Definition: dgIntersections.h:204
dgFastAABBInfo::m_p1
dgVector m_p1
Definition: dgIntersections.h:374
dgVector::CompProduct4
DG_INLINE dgVector CompProduct4(const dgVector &A) const
Definition: dgVector.h:851
dgFastRayTest::m_dpInv
dgVector m_dpInv
Definition: dgIntersections.h:155
dgCollisionHeightField
Definition: dgCollisionHeightField.h:32
timestep
dgFloat32 timestep
Definition: dgBallConstraint.h:34
dgFastRayTest::m_zero
dgVector m_zero
Definition: dgIntersections.h:159
dgVector::Abs
DG_INLINE dgVector Abs() const
Definition: dgVector.h:862
dgFastRayTest::dgFastRayTest
DG_INLINE dgFastRayTest(const dgVector &l0, const dgVector &l1)
Definition: dgIntersections.h:55
dgVector::DotProduct4
DG_INLINE dgVector DotProduct4(const dgVector &A) const
Definition: dgVector.h:783
dgFastRayTest::PolygonIntersectFallback
dgFloat32 PolygonIntersectFallback(const dgVector &normal, dgFloat32 maxT, const dgFloat32 *const polygon, dgInt32 strideInBytes, const dgInt32 *const indexArray, dgInt32 indexCount) const
Definition: dgIntersections.cpp:37
dgCollisionUserMesh
Definition: dgCollisionUserMesh.h:30
dgMatrix
Definition: dgMatrix.h:40
dgFastRayTest::m_isParallel
dgVector m_isParallel
Definition: dgIntersections.h:160
dgFastRayTest::m_minT
dgVector m_minT
Definition: dgIntersections.h:157
dgRayCastSphere
dgFloat32 dgRayCastSphere(const dgVector &p0, const dgVector &p1, const dgVector &origin, dgFloat32 radius)
Definition: dgIntersections.cpp:901
dgMatrix::m_posit
dgVector m_posit
Definition: dgMatrix.h:104
t_StopSearh
Definition: dgIntersections.h:37
dgFastAABBInfo::dgFastAABBInfo
DG_INLINE dgFastAABBInfo(const dgMatrix &matrix, const dgVector &size)
Definition: dgIntersections.h:254
dgGetIdentityMatrix
const dgMatrix & dgGetIdentityMatrix()
Definition: dgMatrix.cpp:47
dgSqrt
#define dgSqrt(x)
Definition: dgTypes.h:691
dgIntersectStatus
dgIntersectStatus
Definition: dgIntersections.h:35
dgRayBoxClip
bool dgRayBoxClip(dgVector &ray_p0, dgVector &ray_p1, const dgVector &boxP0, const dgVector &boxP1)
Definition: dgIntersections.cpp:160
dgFastAABBInfo::PolygonBoxRayDistance
DG_INLINE dgFloat32 PolygonBoxRayDistance(const dgVector &faceNormal, dgInt32 indexCount, const dgInt32 *const indexArray, dgInt32 stride, const dgFloat32 *const vertexArray, const dgFastRayTest &ray) const
Definition: dgIntersections.h:281
dgVector::GetMin
dgVector GetMin(const dgVector &data) const
Definition: dgVector.h:874
dgAABBPolygonSoup
Definition: dgAABBPolygonSoup.h:33
dgVector::GetMax
dgVector GetMax(const dgVector &data) const
Definition: dgVector.h:869
dgVector::m_w
dgFloat32 m_w
Definition: dgVector.h:1028
dgFastAABBInfo::dgFastAABBInfo
DG_INLINE dgFastAABBInfo(const dgVector &p0, const dgVector &p1)
Definition: dgIntersections.h:263
dgBigVector
Definition: dgVector.h:207
dgFastRayTest::m_diff
dgVector m_diff
Definition: dgIntersections.h:154
dgVector::ShiftTripleRight
DG_INLINE dgVector ShiftTripleRight() const
Definition: dgVector.h:976
dgVector::m_y
dgFloat32 m_y
Definition: dgVector.h:1026
dgPointToTriangleDistance
dgVector dgPointToTriangleDistance(const dgVector &point, const dgVector &p0, const dgVector &p1, const dgVector &p2, const dgVector &normal)
Definition: dgIntersections.cpp:351