Bullet Collision Detection & Physics Library: gim_box_collision.h Source File

Bullet Collision Detection & Physics Library

gim_box_collision.h
Go to the documentation of this file.
1 #ifndef GIM_BOX_COLLISION_H_INCLUDED
2 #define GIM_BOX_COLLISION_H_INCLUDED
3
7 /*
8 -----------------------------------------------------------------------------
9 This source file is part of GIMPACT Library.
10
11 For the latest info, see http://gimpact.sourceforge.net/
12
13 Copyright (c) 2006 Francisco Leon Najera. C.C. 80087371.
14 email: projectileman@yahoo.com
15
16 This library is free software; you can redistribute it and/or
17 modify it under the terms of EITHER:
18 (1) The GNU Lesser General Public License as published by the Free
19 Software Foundation; either version 2.1 of the License, or (at
20 your option) any later version. The text of the GNU Lesser
21 General Public License is included with this library in the
22 file GIMPACT-LICENSE-LGPL.TXT.
23 (2) The BSD-style license that is included with this library in
24 the file GIMPACT-LICENSE-BSD.TXT.
25 (3) The zlib/libpng license that is included with this library in
26 the file GIMPACT-LICENSE-ZLIB.TXT.
27
28 This library is distributed in the hope that it will be useful,
29 but WITHOUT ANY WARRANTY; without even the implied warranty of
30 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files
31 GIMPACT-LICENSE-LGPL.TXT, GIMPACT-LICENSE-ZLIB.TXT and GIMPACT-LICENSE-BSD.TXT for more details.
32
33 -----------------------------------------------------------------------------
34 */
35 #include "gim_basic_geometry_operations.h"
36 #include "LinearMath/btTransform.h"
37
38
39
40 //SIMD_FORCE_INLINE bool test_cross_edge_box(
41 // const btVector3 & edge,
42 // const btVector3 & absolute_edge,
43 // const btVector3 & pointa,
44 // const btVector3 & pointb, const btVector3 & extend,
45 // int dir_index0,
46 // int dir_index1
47 // int component_index0,
48 // int component_index1)
49 //{
50 // // dir coords are -z and y
51 //
52 // const btScalar dir0 = -edge[dir_index0];
53 // const btScalar dir1 = edge[dir_index1];
54 // btScalar pmin = pointa[component_index0]*dir0 + pointa[component_index1]*dir1;
55 // btScalar pmax = pointb[component_index0]*dir0 + pointb[component_index1]*dir1;
56 // //find minmax
57 // if(pmin>pmax)
58 // {
59 // GIM_SWAP_NUMBERS(pmin,pmax);
60 // }
61 // //find extends
62 // const btScalar rad = extend[component_index0] * absolute_edge[dir_index0] +
63 // extend[component_index1] * absolute_edge[dir_index1];
64 //
65 // if(pmin>rad || -rad>pmax) return false;
66 // return true;
67 //}
68 //
69 //SIMD_FORCE_INLINE bool test_cross_edge_box_X_axis(
70 // const btVector3 & edge,
71 // const btVector3 & absolute_edge,
72 // const btVector3 & pointa,
73 // const btVector3 & pointb, btVector3 & extend)
74 //{
75 //
76 // return test_cross_edge_box(edge,absolute_edge,pointa,pointb,extend,2,1,1,2);
77 //}
78 //
79 //
80 //SIMD_FORCE_INLINE bool test_cross_edge_box_Y_axis(
81 // const btVector3 & edge,
82 // const btVector3 & absolute_edge,
83 // const btVector3 & pointa,
84 // const btVector3 & pointb, btVector3 & extend)
85 //{
86 //
87 // return test_cross_edge_box(edge,absolute_edge,pointa,pointb,extend,0,2,2,0);
88 //}
89 //
90 //SIMD_FORCE_INLINE bool test_cross_edge_box_Z_axis(
91 // const btVector3 & edge,
92 // const btVector3 & absolute_edge,
93 // const btVector3 & pointa,
94 // const btVector3 & pointb, btVector3 & extend)
95 //{
96 //
97 // return test_cross_edge_box(edge,absolute_edge,pointa,pointb,extend,1,0,0,1);
98 //}
99
100 #ifndef TEST_CROSS_EDGE_BOX_MCR
101
102 #define TEST_CROSS_EDGE_BOX_MCR(edge,absolute_edge,pointa,pointb,_extend,i_dir_0,i_dir_1,i_comp_0,i_comp_1)\
103 {\
104 const btScalar dir0 = -edge[i_dir_0];\
105 const btScalar dir1 = edge[i_dir_1];\
106 btScalar pmin = pointa[i_comp_0]*dir0 + pointa[i_comp_1]*dir1;\
107 btScalar pmax = pointb[i_comp_0]*dir0 + pointb[i_comp_1]*dir1;\
108 if(pmin>pmax)\
109 {\
110 GIM_SWAP_NUMBERS(pmin,pmax); \
111 }\
112 const btScalar abs_dir0 = absolute_edge[i_dir_0];\
113 const btScalar abs_dir1 = absolute_edge[i_dir_1];\
114 const btScalar rad = _extend[i_comp_0] * abs_dir0 + _extend[i_comp_1] * abs_dir1;\
115 if(pmin>rad || -rad>pmax) return false;\
116 }\
117
118 #endif
119
120 #define TEST_CROSS_EDGE_BOX_X_AXIS_MCR(edge,absolute_edge,pointa,pointb,_extend)\
121 {\
122 TEST_CROSS_EDGE_BOX_MCR(edge,absolute_edge,pointa,pointb,_extend,2,1,1,2);\
123 }\
124
125 #define TEST_CROSS_EDGE_BOX_Y_AXIS_MCR(edge,absolute_edge,pointa,pointb,_extend)\
126 {\
127 TEST_CROSS_EDGE_BOX_MCR(edge,absolute_edge,pointa,pointb,_extend,0,2,2,0);\
128 }\
129
130 #define TEST_CROSS_EDGE_BOX_Z_AXIS_MCR(edge,absolute_edge,pointa,pointb,_extend)\
131 {\
132 TEST_CROSS_EDGE_BOX_MCR(edge,absolute_edge,pointa,pointb,_extend,1,0,0,1);\
133 }\
134
135
136
138 class GIM_BOX_BOX_TRANSFORM_CACHE
139 {
140 public:
141 btVector3 m_T1to0;
142 btMatrix3x3 m_R1to0;
143 btMatrix3x3 m_AR;
144
145 SIMD_FORCE_INLINE void calc_absolute_matrix()
146 {
147 static const btVector3 vepsi(1e-6f,1e-6f,1e-6f);
148 m_AR[0] = vepsi + m_R1to0[0].absolute();
149 m_AR[1] = vepsi + m_R1to0[1].absolute();
150 m_AR[2] = vepsi + m_R1to0[2].absolute();
151 }
152
153 GIM_BOX_BOX_TRANSFORM_CACHE()
154 {
155 }
156
157
158 GIM_BOX_BOX_TRANSFORM_CACHE(mat4f trans1_to_0)
159 {
160 COPY_MATRIX_3X3(m_R1to0,trans1_to_0)
161 MAT_GET_TRANSLATION(trans1_to_0,m_T1to0)
162 calc_absolute_matrix();
163 }
164
166 SIMD_FORCE_INLINE void calc_from_homogenic(const btTransform & trans0,const btTransform & trans1)
167 {
168
169 m_R1to0 = trans0.getBasis().transpose();
170 m_T1to0 = m_R1to0 * (-trans0.getOrigin());
171
172 m_T1to0 += m_R1to0*trans1.getOrigin();
173 m_R1to0 *= trans1.getBasis();
174
175 calc_absolute_matrix();
176 }
177
179 SIMD_FORCE_INLINE void calc_from_full_invert(const btTransform & trans0,const btTransform & trans1)
180 {
181 m_R1to0 = trans0.getBasis().inverse();
182 m_T1to0 = m_R1to0 * (-trans0.getOrigin());
183
184 m_T1to0 += m_R1to0*trans1.getOrigin();
185 m_R1to0 *= trans1.getBasis();
186
187 calc_absolute_matrix();
188 }
189
190 SIMD_FORCE_INLINE btVector3 transform(const btVector3 & point)
191 {
192 return point.dot3(m_R1to0[0], m_R1to0[1], m_R1to0[2]) + m_T1to0;
193 }
194 };
195
196 #ifndef BOX_PLANE_EPSILON
197 #define BOX_PLANE_EPSILON 0.000001f
198 #endif
199
201 class GIM_AABB
202 {
203 public:
204 btVector3 m_min;
205 btVector3 m_max;
206
207 GIM_AABB()
208 {}
209
210
211 GIM_AABB(const btVector3 & V1,
212 const btVector3 & V2,
213 const btVector3 & V3)
214 {
215 m_min[0] = GIM_MIN3(V1[0],V2[0],V3[0]);
216 m_min[1] = GIM_MIN3(V1[1],V2[1],V3[1]);
217 m_min[2] = GIM_MIN3(V1[2],V2[2],V3[2]);
218
219 m_max[0] = GIM_MAX3(V1[0],V2[0],V3[0]);
220 m_max[1] = GIM_MAX3(V1[1],V2[1],V3[1]);
221 m_max[2] = GIM_MAX3(V1[2],V2[2],V3[2]);
222 }
223
224 GIM_AABB(const btVector3 & V1,
225 const btVector3 & V2,
226 const btVector3 & V3,
227 GREAL margin)
228 {
229 m_min[0] = GIM_MIN3(V1[0],V2[0],V3[0]);
230 m_min[1] = GIM_MIN3(V1[1],V2[1],V3[1]);
231 m_min[2] = GIM_MIN3(V1[2],V2[2],V3[2]);
232
233 m_max[0] = GIM_MAX3(V1[0],V2[0],V3[0]);
234 m_max[1] = GIM_MAX3(V1[1],V2[1],V3[1]);
235 m_max[2] = GIM_MAX3(V1[2],V2[2],V3[2]);
236
237 m_min[0] -= margin;
238 m_min[1] -= margin;
239 m_min[2] -= margin;
240 m_max[0] += margin;
241 m_max[1] += margin;
242 m_max[2] += margin;
243 }
244
245 GIM_AABB(const GIM_AABB &other):
246 m_min(other.m_min),m_max(other.m_max)
247 {
248 }
249
250 GIM_AABB(const GIM_AABB &other,btScalar margin ):
251 m_min(other.m_min),m_max(other.m_max)
252 {
253 m_min[0] -= margin;
254 m_min[1] -= margin;
255 m_min[2] -= margin;
256 m_max[0] += margin;
257 m_max[1] += margin;
258 m_max[2] += margin;
259 }
260
261 SIMD_FORCE_INLINE void invalidate()
262 {
263 m_min[0] = G_REAL_INFINITY;
264 m_min[1] = G_REAL_INFINITY;
265 m_min[2] = G_REAL_INFINITY;
266 m_max[0] = -G_REAL_INFINITY;
267 m_max[1] = -G_REAL_INFINITY;
268 m_max[2] = -G_REAL_INFINITY;
269 }
270
271 SIMD_FORCE_INLINE void increment_margin(btScalar margin)
272 {
273 m_min[0] -= margin;
274 m_min[1] -= margin;
275 m_min[2] -= margin;
276 m_max[0] += margin;
277 m_max[1] += margin;
278 m_max[2] += margin;
279 }
280
281 SIMD_FORCE_INLINE void copy_with_margin(const GIM_AABB &other, btScalar margin)
282 {
283 m_min[0] = other.m_min[0] - margin;
284 m_min[1] = other.m_min[1] - margin;
285 m_min[2] = other.m_min[2] - margin;
286
287 m_max[0] = other.m_max[0] + margin;
288 m_max[1] = other.m_max[1] + margin;
289 m_max[2] = other.m_max[2] + margin;
290 }
291
292 template<typename CLASS_POINT>
293 SIMD_FORCE_INLINE void calc_from_triangle(
294 const CLASS_POINT & V1,
295 const CLASS_POINT & V2,
296 const CLASS_POINT & V3)
297 {
298 m_min[0] = GIM_MIN3(V1[0],V2[0],V3[0]);
299 m_min[1] = GIM_MIN3(V1[1],V2[1],V3[1]);
300 m_min[2] = GIM_MIN3(V1[2],V2[2],V3[2]);
301
302 m_max[0] = GIM_MAX3(V1[0],V2[0],V3[0]);
303 m_max[1] = GIM_MAX3(V1[1],V2[1],V3[1]);
304 m_max[2] = GIM_MAX3(V1[2],V2[2],V3[2]);
305 }
306
307 template<typename CLASS_POINT>
308 SIMD_FORCE_INLINE void calc_from_triangle_margin(
309 const CLASS_POINT & V1,
310 const CLASS_POINT & V2,
311 const CLASS_POINT & V3, btScalar margin)
312 {
313 m_min[0] = GIM_MIN3(V1[0],V2[0],V3[0]);
314 m_min[1] = GIM_MIN3(V1[1],V2[1],V3[1]);
315 m_min[2] = GIM_MIN3(V1[2],V2[2],V3[2]);
316
317 m_max[0] = GIM_MAX3(V1[0],V2[0],V3[0]);
318 m_max[1] = GIM_MAX3(V1[1],V2[1],V3[1]);
319 m_max[2] = GIM_MAX3(V1[2],V2[2],V3[2]);
320
321 m_min[0] -= margin;
322 m_min[1] -= margin;
323 m_min[2] -= margin;
324 m_max[0] += margin;
325 m_max[1] += margin;
326 m_max[2] += margin;
327 }
328
330 SIMD_FORCE_INLINE void appy_transform(const btTransform & trans)
331 {
332 btVector3 center = (m_max+m_min)*0.5f;
333 btVector3 extends = m_max - center;
334 // Compute new center
335 center = trans(center);
336
337 btVector3 textends = extends.dot3(trans.getBasis().getRow(0).absolute(),
338 trans.getBasis().getRow(1).absolute(),
339 trans.getBasis().getRow(2).absolute());
340
341 m_min = center - textends;
342 m_max = center + textends;
343 }
344
346 SIMD_FORCE_INLINE void merge(const GIM_AABB & box)
347 {
348 m_min[0] = GIM_MIN(m_min[0],box.m_min[0]);
349 m_min[1] = GIM_MIN(m_min[1],box.m_min[1]);
350 m_min[2] = GIM_MIN(m_min[2],box.m_min[2]);
351
352 m_max[0] = GIM_MAX(m_max[0],box.m_max[0]);
353 m_max[1] = GIM_MAX(m_max[1],box.m_max[1]);
354 m_max[2] = GIM_MAX(m_max[2],box.m_max[2]);
355 }
356
358 template<typename CLASS_POINT>
359 SIMD_FORCE_INLINE void merge_point(const CLASS_POINT & point)
360 {
361 m_min[0] = GIM_MIN(m_min[0],point[0]);
362 m_min[1] = GIM_MIN(m_min[1],point[1]);
363 m_min[2] = GIM_MIN(m_min[2],point[2]);
364
365 m_max[0] = GIM_MAX(m_max[0],point[0]);
366 m_max[1] = GIM_MAX(m_max[1],point[1]);
367 m_max[2] = GIM_MAX(m_max[2],point[2]);
368 }
369
371 SIMD_FORCE_INLINE void get_center_extend(btVector3 & center,btVector3 & extend) const
372 {
373 center = (m_max+m_min)*0.5f;
374 extend = m_max - center;
375 }
376
378 SIMD_FORCE_INLINE void find_intersection(const GIM_AABB & other, GIM_AABB & intersection) const
379 {
380 intersection.m_min[0] = GIM_MAX(other.m_min[0],m_min[0]);
381 intersection.m_min[1] = GIM_MAX(other.m_min[1],m_min[1]);
382 intersection.m_min[2] = GIM_MAX(other.m_min[2],m_min[2]);
383
384 intersection.m_max[0] = GIM_MIN(other.m_max[0],m_max[0]);
385 intersection.m_max[1] = GIM_MIN(other.m_max[1],m_max[1]);
386 intersection.m_max[2] = GIM_MIN(other.m_max[2],m_max[2]);
387 }
388
389
390 SIMD_FORCE_INLINE bool has_collision(const GIM_AABB & other) const
391 {
392 if(m_min[0] > other.m_max[0] ||
393 m_max[0] < other.m_min[0] ||
394 m_min[1] > other.m_max[1] ||
395 m_max[1] < other.m_min[1] ||
396 m_min[2] > other.m_max[2] ||
397 m_max[2] < other.m_min[2])
398 {
399 return false;
400 }
401 return true;
402 }
403
409 SIMD_FORCE_INLINE bool collide_ray(const btVector3 & vorigin,const btVector3 & vdir)
410 {
411 btVector3 extents,center;
412 this->get_center_extend(center,extents);;
413
414 btScalar Dx = vorigin[0] - center[0];
415 if(GIM_GREATER(Dx, extents[0]) && Dx*vdir[0]>=0.0f) return false;
416 btScalar Dy = vorigin[1] - center[1];
417 if(GIM_GREATER(Dy, extents[1]) && Dy*vdir[1]>=0.0f) return false;
418 btScalar Dz = vorigin[2] - center[2];
419 if(GIM_GREATER(Dz, extents[2]) && Dz*vdir[2]>=0.0f) return false;
420
421
422 btScalar f = vdir[1] * Dz - vdir[2] * Dy;
423 if(btFabs(f) > extents[1]*btFabs(vdir[2]) + extents[2]*btFabs(vdir[1])) return false;
424 f = vdir[2] * Dx - vdir[0] * Dz;
425 if(btFabs(f) > extents[0]*btFabs(vdir[2]) + extents[2]*btFabs(vdir[0]))return false;
426 f = vdir[0] * Dy - vdir[1] * Dx;
427 if(btFabs(f) > extents[0]*btFabs(vdir[1]) + extents[1]*btFabs(vdir[0]))return false;
428 return true;
429 }
430
431
432 SIMD_FORCE_INLINE void projection_interval(const btVector3 & direction, btScalar &vmin, btScalar &vmax) const
433 {
434 btVector3 center = (m_max+m_min)*0.5f;
435 btVector3 extend = m_max-center;
436
437 btScalar _fOrigin = direction.dot(center);
438 btScalar _fMaximumExtent = extend.dot(direction.absolute());
439 vmin = _fOrigin - _fMaximumExtent;
440 vmax = _fOrigin + _fMaximumExtent;
441 }
442
443 SIMD_FORCE_INLINE ePLANE_INTERSECTION_TYPE plane_classify(const btVector4 &plane) const
444 {
445 btScalar _fmin,_fmax;
446 this->projection_interval(plane,_fmin,_fmax);
447
448 if(plane[3] > _fmax + BOX_PLANE_EPSILON)
449 {
450 return G_BACK_PLANE; // 0
451 }
452
453 if(plane[3]+BOX_PLANE_EPSILON >=_fmin)
454 {
455 return G_COLLIDE_PLANE; //1
456 }
457 return G_FRONT_PLANE;//2
458 }
459
460 SIMD_FORCE_INLINE bool overlapping_trans_conservative(const GIM_AABB & box, btTransform & trans1_to_0)
461 {
462 GIM_AABB tbox = box;
463 tbox.appy_transform(trans1_to_0);
464 return has_collision(tbox);
465 }
466
468 SIMD_FORCE_INLINE bool overlapping_trans_cache(
469 const GIM_AABB & box,const GIM_BOX_BOX_TRANSFORM_CACHE & transcache, bool fulltest)
470 {
471
472 //Taken from OPCODE
473 btVector3 ea,eb;//extends
474 btVector3 ca,cb;//extends
475 get_center_extend(ca,ea);
476 box.get_center_extend(cb,eb);
477
478
479 btVector3 T;
480 btScalar t,t2;
481 int i;
482
483 // Class I : A's basis vectors
484 for(i=0;i<3;i++)
485 {
486 T[i] = transcache.m_R1to0[i].dot(cb) + transcache.m_T1to0[i] - ca[i];
487 t = transcache.m_AR[i].dot(eb) + ea[i];
488 if(GIM_GREATER(T[i], t)) return false;
489 }
490 // Class II : B's basis vectors
491 for(i=0;i<3;i++)
492 {
493 t = MAT_DOT_COL(transcache.m_R1to0,T,i);
494 t2 = MAT_DOT_COL(transcache.m_AR,ea,i) + eb[i];
495 if(GIM_GREATER(t,t2)) return false;
496 }
497 // Class III : 9 cross products
498 if(fulltest)
499 {
500 int j,m,n,o,p,q,r;
501 for(i=0;i<3;i++)
502 {
503 m = (i+1)%3;
504 n = (i+2)%3;
505 o = i==0?1:0;
506 p = i==2?1:2;
507 for(j=0;j<3;j++)
508 {
509 q = j==2?1:2;
510 r = j==0?1:0;
511 t = T[n]*transcache.m_R1to0[m][j] - T[m]*transcache.m_R1to0[n][j];
512 t2 = ea[o]*transcache.m_AR[p][j] + ea[p]*transcache.m_AR[o][j] +
513 eb[r]*transcache.m_AR[i][q] + eb[q]*transcache.m_AR[i][r];
514 if(GIM_GREATER(t,t2)) return false;
515 }
516 }
517 }
518 return true;
519 }
520
522 SIMD_FORCE_INLINE bool collide_plane(
523 const btVector4 & plane)
524 {
525 ePLANE_INTERSECTION_TYPE classify = plane_classify(plane);
526 return (classify == G_COLLIDE_PLANE);
527 }
528
530 SIMD_FORCE_INLINE bool collide_triangle_exact(
531 const btVector3 & p1,
532 const btVector3 & p2,
533 const btVector3 & p3,
534 const btVector4 & triangle_plane)
535 {
536 if(!collide_plane(triangle_plane)) return false;
537
538 btVector3 center,extends;
539 this->get_center_extend(center,extends);
540
541 const btVector3 v1(p1 - center);
542 const btVector3 v2(p2 - center);
543 const btVector3 v3(p3 - center);
544
545 //First axis
546 btVector3 diff(v2 - v1);
547 btVector3 abs_diff = diff.absolute();
548 //Test With X axis
549 TEST_CROSS_EDGE_BOX_X_AXIS_MCR(diff,abs_diff,v1,v3,extends);
550 //Test With Y axis
551 TEST_CROSS_EDGE_BOX_Y_AXIS_MCR(diff,abs_diff,v1,v3,extends);
552 //Test With Z axis
553 TEST_CROSS_EDGE_BOX_Z_AXIS_MCR(diff,abs_diff,v1,v3,extends);
554
555
556 diff = v3 - v2;
557 abs_diff = diff.absolute();
558 //Test With X axis
559 TEST_CROSS_EDGE_BOX_X_AXIS_MCR(diff,abs_diff,v2,v1,extends);
560 //Test With Y axis
561 TEST_CROSS_EDGE_BOX_Y_AXIS_MCR(diff,abs_diff,v2,v1,extends);
562 //Test With Z axis
563 TEST_CROSS_EDGE_BOX_Z_AXIS_MCR(diff,abs_diff,v2,v1,extends);
564
565 diff = v1 - v3;
566 abs_diff = diff.absolute();
567 //Test With X axis
568 TEST_CROSS_EDGE_BOX_X_AXIS_MCR(diff,abs_diff,v3,v2,extends);
569 //Test With Y axis
570 TEST_CROSS_EDGE_BOX_Y_AXIS_MCR(diff,abs_diff,v3,v2,extends);
571 //Test With Z axis
572 TEST_CROSS_EDGE_BOX_Z_AXIS_MCR(diff,abs_diff,v3,v2,extends);
573
574 return true;
575 }
576 };
577
578 #ifndef BT_BOX_COLLISION_H_INCLUDED
579 SIMD_FORCE_INLINE bool btCompareTransformsEqual(const btTransform & t1,const btTransform & t2)
581 {
582 if(!(t1.getOrigin() == t2.getOrigin()) ) return false;
583
584 if(!(t1.getBasis().getRow(0) == t2.getBasis().getRow(0)) ) return false;
585 if(!(t1.getBasis().getRow(1) == t2.getBasis().getRow(1)) ) return false;
586 if(!(t1.getBasis().getRow(2) == t2.getBasis().getRow(2)) ) return false;
587 return true;
588 }
589 #endif
590
591
592
593 #endif // GIM_BOX_COLLISION_H_INCLUDED
GIM_AABB::invalidate
void invalidate()
Definition: gim_box_collision.h:261
GIM_MIN
#define GIM_MIN(a, b)
Definition: gim_math.h:94
GIM_BOX_BOX_TRANSFORM_CACHE::calc_absolute_matrix
void calc_absolute_matrix()
Definition: gim_box_collision.h:145
GIM_AABB::calc_from_triangle_margin
void calc_from_triangle_margin(const CLASS_POINT &V1, const CLASS_POINT &V2, const CLASS_POINT &V3, btScalar margin)
Definition: gim_box_collision.h:308
GIM_BOX_BOX_TRANSFORM_CACHE::m_T1to0
btVector3 m_T1to0
Transforms translation of model1 to model 0.
Definition: gim_box_collision.h:141
TEST_CROSS_EDGE_BOX_X_AXIS_MCR
#define TEST_CROSS_EDGE_BOX_X_AXIS_MCR(edge, absolute_edge, pointa, pointb, _extend)
Definition: gim_box_collision.h:120
GIM_AABB::m_min
btVector3 m_min
Definition: gim_box_collision.h:204
btVector3::dot3
btVector3 dot3(const btVector3 &v0, const btVector3 &v1, const btVector3 &v2) const
Definition: btVector3.h:731
GIM_BOX_BOX_TRANSFORM_CACHE::calc_from_homogenic
void calc_from_homogenic(const btTransform &trans0, const btTransform &trans1)
Calc the transformation relative 1 to 0. Inverts matrics by transposing.
Definition: gim_box_collision.h:166
GIM_GREATER
#define GIM_GREATER(x, y)
Definition: gim_math.h:110
gim_basic_geometry_operations.h
btMatrix3x3::getRow
const btVector3 & getRow(int i) const
Get a row of the matrix as a vector.
Definition: btMatrix3x3.h:142
SIMD_FORCE_INLINE
#define SIMD_FORCE_INLINE
Definition: btScalar.h:81
GIM_AABB
Axis aligned box.
Definition: gim_box_collision.h:201
btTransform.h
GIM_AABB::get_center_extend
void get_center_extend(btVector3 &center, btVector3 &extend) const
Gets the extend and center.
Definition: gim_box_collision.h:371
GIM_AABB::GIM_AABB
GIM_AABB(const GIM_AABB &other)
Definition: gim_box_collision.h:245
GIM_AABB::copy_with_margin
void copy_with_margin(const GIM_AABB &other, btScalar margin)
Definition: gim_box_collision.h:281
GREAL
#define GREAL
Definition: gim_math.h:39
GIM_AABB::overlapping_trans_conservative
bool overlapping_trans_conservative(const GIM_AABB &box, btTransform &trans1_to_0)
Definition: gim_box_collision.h:460
GIM_AABB::collide_ray
bool collide_ray(const btVector3 &vorigin, const btVector3 &vdir)
Finds the Ray intersection parameter.
Definition: gim_box_collision.h:409
GIM_BOX_BOX_TRANSFORM_CACHE::m_AR
btMatrix3x3 m_AR
Absolute value of m_R1to0.
Definition: gim_box_collision.h:143
btMatrix3x3::transpose
btMatrix3x3 transpose() const
Return the transpose of the matrix.
Definition: btMatrix3x3.h:958
GIM_AABB::calc_from_triangle
void calc_from_triangle(const CLASS_POINT &V1, const CLASS_POINT &V2, const CLASS_POINT &V3)
Definition: gim_box_collision.h:293
btVector4
Definition: btVector3.h:1089
GIM_MAX
#define GIM_MAX(a, b)
Definition: gim_math.h:93
GIM_AABB::projection_interval
void projection_interval(const btVector3 &direction, btScalar &vmin, btScalar &vmax) const
Definition: gim_box_collision.h:432
GIM_AABB::has_collision
bool has_collision(const GIM_AABB &other) const
Definition: gim_box_collision.h:390
btTransform::getOrigin
btVector3 & getOrigin()
Return the origin vector translation.
Definition: btTransform.h:117
BOX_PLANE_EPSILON
#define BOX_PLANE_EPSILON
Definition: gim_box_collision.h:197
GIM_AABB::GIM_AABB
GIM_AABB()
Definition: gim_box_collision.h:207
TEST_CROSS_EDGE_BOX_Y_AXIS_MCR
#define TEST_CROSS_EDGE_BOX_Y_AXIS_MCR(edge, absolute_edge, pointa, pointb, _extend)
Definition: gim_box_collision.h:125
btVector3::dot
btScalar dot(const btVector3 &v) const
Return the dot product.
Definition: btVector3.h:235
GIM_AABB::collide_plane
bool collide_plane(const btVector4 &plane)
Simple test for planes.
Definition: gim_box_collision.h:522
btTransform::getBasis
btMatrix3x3 & getBasis()
Return the basis matrix for the rotation.
Definition: btTransform.h:112
G_BACK_PLANE
Definition: gim_basic_geometry_operations.h:127
GIM_AABB::GIM_AABB
GIM_AABB(const GIM_AABB &other, btScalar margin)
Definition: gim_box_collision.h:250
GIM_MIN3
#define GIM_MIN3(a, b, c)
Definition: gim_math.h:97
G_COLLIDE_PLANE
Definition: gim_basic_geometry_operations.h:128
btVector3
btVector3 can be used to represent 3D points and vectors.
Definition: btVector3.h:83
GIM_AABB::find_intersection
void find_intersection(const GIM_AABB &other, GIM_AABB &intersection) const
Finds the intersecting box between this box and the other.
Definition: gim_box_collision.h:378
GIM_BOX_BOX_TRANSFORM_CACHE::calc_from_full_invert
void calc_from_full_invert(const btTransform &trans0, const btTransform &trans1)
Calcs the full invertion of the matrices. Useful for scaling matrices.
Definition: gim_box_collision.h:179
btVector3::absolute
btVector3 absolute() const
Return a vector will the absolute values of each element.
Definition: btVector3.h:372
GIM_AABB::overlapping_trans_cache
bool overlapping_trans_cache(const GIM_AABB &box, const GIM_BOX_BOX_TRANSFORM_CACHE &transcache, bool fulltest)
transcache is the transformation cache from box to this AABB
Definition: gim_box_collision.h:468
mat4f
GREAL mat4f[4][4]
Matrix 4D, row ordered.
Definition: gim_geom_types.h:88
btTransform
The btTransform class supports rigid transforms with only translation and rotation and no scaling/she...
Definition: btTransform.h:34
GIM_AABB::GIM_AABB
GIM_AABB(const btVector3 &V1, const btVector3 &V2, const btVector3 &V3)
Definition: gim_box_collision.h:211
btMatrix3x3::absolute
btMatrix3x3 absolute() const
Return the matrix with all values non negative.
Definition: btMatrix3x3.h:937
btCompareTransformsEqual
bool btCompareTransformsEqual(const btTransform &t1, const btTransform &t2)
Compairison of transformation objects.
Definition: gim_box_collision.h:580
GIM_AABB::plane_classify
ePLANE_INTERSECTION_TYPE plane_classify(const btVector4 &plane) const
Definition: gim_box_collision.h:443
GIM_BOX_BOX_TRANSFORM_CACHE::m_R1to0
btMatrix3x3 m_R1to0
Transforms Rotation of model1 to model 0, equal to R0&#39; * R1.
Definition: gim_box_collision.h:142
GIM_AABB::m_max
btVector3 m_max
Definition: gim_box_collision.h:205
GIM_BOX_BOX_TRANSFORM_CACHE
Class for transforming a model1 to the space of model0.
Definition: gim_box_collision.h:138
GIM_AABB::merge_point
void merge_point(const CLASS_POINT &point)
Merges a point.
Definition: gim_box_collision.h:359
GIM_AABB::appy_transform
void appy_transform(const btTransform &trans)
Apply a transform to an AABB.
Definition: gim_box_collision.h:330
ePLANE_INTERSECTION_TYPE
ePLANE_INTERSECTION_TYPE
Definition: gim_basic_geometry_operations.h:125
GIM_BOX_BOX_TRANSFORM_CACHE::GIM_BOX_BOX_TRANSFORM_CACHE
GIM_BOX_BOX_TRANSFORM_CACHE(mat4f trans1_to_0)
Definition: gim_box_collision.h:158
MAT_GET_TRANSLATION
#define MAT_GET_TRANSLATION(mat, vec3)
Get the triple(3) col of a transform matrix.
Definition: gim_linear_math.h:1524
G_REAL_INFINITY
#define G_REAL_INFINITY
Definition: gim_math.h:58
COPY_MATRIX_3X3
#define COPY_MATRIX_3X3(b, a)
Definition: gim_linear_math.h:615
TEST_CROSS_EDGE_BOX_Z_AXIS_MCR
#define TEST_CROSS_EDGE_BOX_Z_AXIS_MCR(edge, absolute_edge, pointa, pointb, _extend)
Definition: gim_box_collision.h:130
btMatrix3x3
The btMatrix3x3 class implements a 3x3 rotation matrix, to perform linear algebra in combination with...
Definition: btMatrix3x3.h:48
G_FRONT_PLANE
Definition: gim_basic_geometry_operations.h:129
GIM_AABB::collide_triangle_exact
bool collide_triangle_exact(const btVector3 &p1, const btVector3 &p2, const btVector3 &p3, const btVector4 &triangle_plane)
test for a triangle, with edges
Definition: gim_box_collision.h:530
GIM_BOX_BOX_TRANSFORM_CACHE::GIM_BOX_BOX_TRANSFORM_CACHE
GIM_BOX_BOX_TRANSFORM_CACHE()
Definition: gim_box_collision.h:153
GIM_MAX3
#define GIM_MAX3(a, b, c)
Definition: gim_math.h:96
GIM_AABB::GIM_AABB
GIM_AABB(const btVector3 &V1, const btVector3 &V2, const btVector3 &V3, GREAL margin)
Definition: gim_box_collision.h:224
GIM_BOX_BOX_TRANSFORM_CACHE::transform
btVector3 transform(const btVector3 &point)
Definition: gim_box_collision.h:190
btMatrix3x3::inverse
btMatrix3x3 inverse() const
Return the inverse of the matrix.
Definition: btMatrix3x3.h:1003
MAT_DOT_COL
#define MAT_DOT_COL(mat, vec3, colindex)
Returns the dot product between a vec3f and the col of a matrix.
Definition: gim_linear_math.h:1552
GIM_AABB::increment_margin
void increment_margin(btScalar margin)
Definition: gim_box_collision.h:271
GIM_AABB::merge
void merge(const GIM_AABB &box)
Merges a Box.
Definition: gim_box_collision.h:346
btScalar
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
Definition: btScalar.h:292
btFabs
btScalar btFabs(btScalar x)
Definition: btScalar.h:475