Bullet Collision Detection & Physics Library
btBoxCollision.h
Go to the documentation of this file.
1 #ifndef BT_BOX_COLLISION_H_INCLUDED
2 #define BT_BOX_COLLISION_H_INCLUDED
3 
7 /*
8 This source file is part of GIMPACT Library.
9 
10 For the latest info, see http://gimpact.sourceforge.net/
11 
12 Copyright (c) 2007 Francisco Leon Najera. C.C. 80087371.
13 email: projectileman@yahoo.com
14 
15 
16 This software is provided 'as-is', without any express or implied warranty.
17 In no event will the authors be held liable for any damages arising from the use of this software.
18 Permission is granted to anyone to use this software for any purpose,
19 including commercial applications, and to alter it and redistribute it freely,
20 subject to the following restrictions:
21 
22 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
23 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
24 3. This notice may not be removed or altered from any source distribution.
25 */
26 
27 #include "LinearMath/btTransform.h"
28 
30 #define BT_SWAP_NUMBERS(a, b) \
31  { \
32  a = a + b; \
33  b = a - b; \
34  a = a - b; \
35  }
36 
37 #define BT_MAX(a, b) (a < b ? b : a)
38 #define BT_MIN(a, b) (a > b ? b : a)
39 
40 #define BT_GREATER(x, y) btFabs(x) > (y)
41 
42 #define BT_MAX3(a, b, c) BT_MAX(a, BT_MAX(b, c))
43 #define BT_MIN3(a, b, c) BT_MIN(a, BT_MIN(b, c))
44 
46 {
50 };
51 
52 //SIMD_FORCE_INLINE bool test_cross_edge_box(
53 // const btVector3 & edge,
54 // const btVector3 & absolute_edge,
55 // const btVector3 & pointa,
56 // const btVector3 & pointb, const btVector3 & extend,
57 // int dir_index0,
58 // int dir_index1
59 // int component_index0,
60 // int component_index1)
61 //{
62 // // dir coords are -z and y
63 //
64 // const btScalar dir0 = -edge[dir_index0];
65 // const btScalar dir1 = edge[dir_index1];
66 // btScalar pmin = pointa[component_index0]*dir0 + pointa[component_index1]*dir1;
67 // btScalar pmax = pointb[component_index0]*dir0 + pointb[component_index1]*dir1;
68 // //find minmax
69 // if(pmin>pmax)
70 // {
71 // BT_SWAP_NUMBERS(pmin,pmax);
72 // }
73 // //find extends
74 // const btScalar rad = extend[component_index0] * absolute_edge[dir_index0] +
75 // extend[component_index1] * absolute_edge[dir_index1];
76 //
77 // if(pmin>rad || -rad>pmax) return false;
78 // return true;
79 //}
80 //
81 //SIMD_FORCE_INLINE bool test_cross_edge_box_X_axis(
82 // const btVector3 & edge,
83 // const btVector3 & absolute_edge,
84 // const btVector3 & pointa,
85 // const btVector3 & pointb, btVector3 & extend)
86 //{
87 //
88 // return test_cross_edge_box(edge,absolute_edge,pointa,pointb,extend,2,1,1,2);
89 //}
90 //
91 //
92 //SIMD_FORCE_INLINE bool test_cross_edge_box_Y_axis(
93 // const btVector3 & edge,
94 // const btVector3 & absolute_edge,
95 // const btVector3 & pointa,
96 // const btVector3 & pointb, btVector3 & extend)
97 //{
98 //
99 // return test_cross_edge_box(edge,absolute_edge,pointa,pointb,extend,0,2,2,0);
100 //}
101 //
102 //SIMD_FORCE_INLINE bool test_cross_edge_box_Z_axis(
103 // const btVector3 & edge,
104 // const btVector3 & absolute_edge,
105 // const btVector3 & pointa,
106 // const btVector3 & pointb, btVector3 & extend)
107 //{
108 //
109 // return test_cross_edge_box(edge,absolute_edge,pointa,pointb,extend,1,0,0,1);
110 //}
111 
112 #define TEST_CROSS_EDGE_BOX_MCR(edge, absolute_edge, pointa, pointb, _extend, i_dir_0, i_dir_1, i_comp_0, i_comp_1) \
113  { \
114  const btScalar dir0 = -edge[i_dir_0]; \
115  const btScalar dir1 = edge[i_dir_1]; \
116  btScalar pmin = pointa[i_comp_0] * dir0 + pointa[i_comp_1] * dir1; \
117  btScalar pmax = pointb[i_comp_0] * dir0 + pointb[i_comp_1] * dir1; \
118  if (pmin > pmax) \
119  { \
120  BT_SWAP_NUMBERS(pmin, pmax); \
121  } \
122  const btScalar abs_dir0 = absolute_edge[i_dir_0]; \
123  const btScalar abs_dir1 = absolute_edge[i_dir_1]; \
124  const btScalar rad = _extend[i_comp_0] * abs_dir0 + _extend[i_comp_1] * abs_dir1; \
125  if (pmin > rad || -rad > pmax) return false; \
126  }
127 
128 #define TEST_CROSS_EDGE_BOX_X_AXIS_MCR(edge, absolute_edge, pointa, pointb, _extend) \
129  { \
130  TEST_CROSS_EDGE_BOX_MCR(edge, absolute_edge, pointa, pointb, _extend, 2, 1, 1, 2); \
131  }
132 
133 #define TEST_CROSS_EDGE_BOX_Y_AXIS_MCR(edge, absolute_edge, pointa, pointb, _extend) \
134  { \
135  TEST_CROSS_EDGE_BOX_MCR(edge, absolute_edge, pointa, pointb, _extend, 0, 2, 2, 0); \
136  }
137 
138 #define TEST_CROSS_EDGE_BOX_Z_AXIS_MCR(edge, absolute_edge, pointa, pointb, _extend) \
139  { \
140  TEST_CROSS_EDGE_BOX_MCR(edge, absolute_edge, pointa, pointb, _extend, 1, 0, 0, 1); \
141  }
142 
145  const btMatrix3x3 &mat, const btVector3 &vec3, int colindex)
146 {
147  return vec3[0] * mat[0][colindex] + vec3[1] * mat[1][colindex] + vec3[2] * mat[2][colindex];
148 }
149 
153 {
154 public:
158 
160  {
161  // static const btVector3 vepsi(1e-6f,1e-6f,1e-6f);
162  // m_AR[0] = vepsi + m_R1to0[0].absolute();
163  // m_AR[1] = vepsi + m_R1to0[1].absolute();
164  // m_AR[2] = vepsi + m_R1to0[2].absolute();
165 
166  int i, j;
167 
168  for (i = 0; i < 3; i++)
169  {
170  for (j = 0; j < 3; j++)
171  {
172  m_AR[i][j] = 1e-6f + btFabs(m_R1to0[i][j]);
173  }
174  }
175  }
176 
178  {
179  }
180 
183  {
184  btTransform temp_trans = trans0.inverse();
185  temp_trans = temp_trans * trans1;
186 
187  m_T1to0 = temp_trans.getOrigin();
188  m_R1to0 = temp_trans.getBasis();
189 
190  calc_absolute_matrix();
191  }
192 
195  {
196  m_R1to0 = trans0.getBasis().inverse();
197  m_T1to0 = m_R1to0 * (-trans0.getOrigin());
198 
199  m_T1to0 += m_R1to0 * trans1.getOrigin();
200  m_R1to0 *= trans1.getBasis();
201 
202  calc_absolute_matrix();
203  }
204 
206  {
207  return point.dot3(m_R1to0[0], m_R1to0[1], m_R1to0[2]) + m_T1to0;
208  }
209 };
210 
211 #define BOX_PLANE_EPSILON 0.000001f
212 
215 btAABB
216 {
217 public:
220 
222  {
223  }
224 
225  btAABB(const btVector3 &V1,
226  const btVector3 &V2,
227  const btVector3 &V3)
228  {
229  m_min[0] = BT_MIN3(V1[0], V2[0], V3[0]);
230  m_min[1] = BT_MIN3(V1[1], V2[1], V3[1]);
231  m_min[2] = BT_MIN3(V1[2], V2[2], V3[2]);
232 
233  m_max[0] = BT_MAX3(V1[0], V2[0], V3[0]);
234  m_max[1] = BT_MAX3(V1[1], V2[1], V3[1]);
235  m_max[2] = BT_MAX3(V1[2], V2[2], V3[2]);
236  }
237 
238  btAABB(const btVector3 &V1,
239  const btVector3 &V2,
240  const btVector3 &V3,
241  btScalar margin)
242  {
243  m_min[0] = BT_MIN3(V1[0], V2[0], V3[0]);
244  m_min[1] = BT_MIN3(V1[1], V2[1], V3[1]);
245  m_min[2] = BT_MIN3(V1[2], V2[2], V3[2]);
246 
247  m_max[0] = BT_MAX3(V1[0], V2[0], V3[0]);
248  m_max[1] = BT_MAX3(V1[1], V2[1], V3[1]);
249  m_max[2] = BT_MAX3(V1[2], V2[2], V3[2]);
250 
251  m_min[0] -= margin;
252  m_min[1] -= margin;
253  m_min[2] -= margin;
254  m_max[0] += margin;
255  m_max[1] += margin;
256  m_max[2] += margin;
257  }
258 
259  btAABB(const btAABB &other) : m_min(other.m_min), m_max(other.m_max)
260  {
261  }
262 
263  btAABB(const btAABB &other, btScalar margin) : m_min(other.m_min), m_max(other.m_max)
264  {
265  m_min[0] -= margin;
266  m_min[1] -= margin;
267  m_min[2] -= margin;
268  m_max[0] += margin;
269  m_max[1] += margin;
270  m_max[2] += margin;
271  }
272 
274  {
275  m_min[0] = SIMD_INFINITY;
276  m_min[1] = SIMD_INFINITY;
277  m_min[2] = SIMD_INFINITY;
278  m_max[0] = -SIMD_INFINITY;
279  m_max[1] = -SIMD_INFINITY;
280  m_max[2] = -SIMD_INFINITY;
281  }
282 
284  {
285  m_min[0] -= margin;
286  m_min[1] -= margin;
287  m_min[2] -= margin;
288  m_max[0] += margin;
289  m_max[1] += margin;
290  m_max[2] += margin;
291  }
292 
294  {
295  m_min[0] = other.m_min[0] - margin;
296  m_min[1] = other.m_min[1] - margin;
297  m_min[2] = other.m_min[2] - margin;
298 
299  m_max[0] = other.m_max[0] + margin;
300  m_max[1] = other.m_max[1] + margin;
301  m_max[2] = other.m_max[2] + margin;
302  }
303 
304  template <typename CLASS_POINT>
306  const CLASS_POINT &V1,
307  const CLASS_POINT &V2,
308  const CLASS_POINT &V3)
309  {
310  m_min[0] = BT_MIN3(V1[0], V2[0], V3[0]);
311  m_min[1] = BT_MIN3(V1[1], V2[1], V3[1]);
312  m_min[2] = BT_MIN3(V1[2], V2[2], V3[2]);
313 
314  m_max[0] = BT_MAX3(V1[0], V2[0], V3[0]);
315  m_max[1] = BT_MAX3(V1[1], V2[1], V3[1]);
316  m_max[2] = BT_MAX3(V1[2], V2[2], V3[2]);
317  }
318 
319  template <typename CLASS_POINT>
321  const CLASS_POINT &V1,
322  const CLASS_POINT &V2,
323  const CLASS_POINT &V3, btScalar margin)
324  {
325  m_min[0] = BT_MIN3(V1[0], V2[0], V3[0]);
326  m_min[1] = BT_MIN3(V1[1], V2[1], V3[1]);
327  m_min[2] = BT_MIN3(V1[2], V2[2], V3[2]);
328 
329  m_max[0] = BT_MAX3(V1[0], V2[0], V3[0]);
330  m_max[1] = BT_MAX3(V1[1], V2[1], V3[1]);
331  m_max[2] = BT_MAX3(V1[2], V2[2], V3[2]);
332 
333  m_min[0] -= margin;
334  m_min[1] -= margin;
335  m_min[2] -= margin;
336  m_max[0] += margin;
337  m_max[1] += margin;
338  m_max[2] += margin;
339  }
340 
343  {
344  btVector3 center = (m_max + m_min) * 0.5f;
345  btVector3 extends = m_max - center;
346  // Compute new center
347  center = trans(center);
348 
349  btVector3 textends = extends.dot3(trans.getBasis().getRow(0).absolute(),
350  trans.getBasis().getRow(1).absolute(),
351  trans.getBasis().getRow(2).absolute());
352 
353  m_min = center - textends;
354  m_max = center + textends;
355  }
356 
359  {
360  btVector3 center = (m_max + m_min) * 0.5f;
361  btVector3 extends = m_max - center;
362  // Compute new center
363  center = trans.transform(center);
364 
365  btVector3 textends = extends.dot3(trans.m_R1to0.getRow(0).absolute(),
366  trans.m_R1to0.getRow(1).absolute(),
367  trans.m_R1to0.getRow(2).absolute());
368 
369  m_min = center - textends;
370  m_max = center + textends;
371  }
372 
374  SIMD_FORCE_INLINE void merge(const btAABB &box)
375  {
376  m_min[0] = BT_MIN(m_min[0], box.m_min[0]);
377  m_min[1] = BT_MIN(m_min[1], box.m_min[1]);
378  m_min[2] = BT_MIN(m_min[2], box.m_min[2]);
379 
380  m_max[0] = BT_MAX(m_max[0], box.m_max[0]);
381  m_max[1] = BT_MAX(m_max[1], box.m_max[1]);
382  m_max[2] = BT_MAX(m_max[2], box.m_max[2]);
383  }
384 
386  template <typename CLASS_POINT>
387  SIMD_FORCE_INLINE void merge_point(const CLASS_POINT &point)
388  {
389  m_min[0] = BT_MIN(m_min[0], point[0]);
390  m_min[1] = BT_MIN(m_min[1], point[1]);
391  m_min[2] = BT_MIN(m_min[2], point[2]);
392 
393  m_max[0] = BT_MAX(m_max[0], point[0]);
394  m_max[1] = BT_MAX(m_max[1], point[1]);
395  m_max[2] = BT_MAX(m_max[2], point[2]);
396  }
397 
400  {
401  center = (m_max + m_min) * 0.5f;
402  extend = m_max - center;
403  }
404 
406  SIMD_FORCE_INLINE void find_intersection(const btAABB &other, btAABB &intersection) const
407  {
408  intersection.m_min[0] = BT_MAX(other.m_min[0], m_min[0]);
409  intersection.m_min[1] = BT_MAX(other.m_min[1], m_min[1]);
410  intersection.m_min[2] = BT_MAX(other.m_min[2], m_min[2]);
411 
412  intersection.m_max[0] = BT_MIN(other.m_max[0], m_max[0]);
413  intersection.m_max[1] = BT_MIN(other.m_max[1], m_max[1]);
414  intersection.m_max[2] = BT_MIN(other.m_max[2], m_max[2]);
415  }
416 
417  SIMD_FORCE_INLINE bool has_collision(const btAABB &other) const
418  {
419  if (m_min[0] > other.m_max[0] ||
420  m_max[0] < other.m_min[0] ||
421  m_min[1] > other.m_max[1] ||
422  m_max[1] < other.m_min[1] ||
423  m_min[2] > other.m_max[2] ||
424  m_max[2] < other.m_min[2])
425  {
426  return false;
427  }
428  return true;
429  }
430 
436  SIMD_FORCE_INLINE bool collide_ray(const btVector3 &vorigin, const btVector3 &vdir) const
437  {
438  btVector3 extents, center;
439  this->get_center_extend(center, extents);
440  ;
441 
442  btScalar Dx = vorigin[0] - center[0];
443  if (BT_GREATER(Dx, extents[0]) && Dx * vdir[0] >= 0.0f) return false;
444  btScalar Dy = vorigin[1] - center[1];
445  if (BT_GREATER(Dy, extents[1]) && Dy * vdir[1] >= 0.0f) return false;
446  btScalar Dz = vorigin[2] - center[2];
447  if (BT_GREATER(Dz, extents[2]) && Dz * vdir[2] >= 0.0f) return false;
448 
449  btScalar f = vdir[1] * Dz - vdir[2] * Dy;
450  if (btFabs(f) > extents[1] * btFabs(vdir[2]) + extents[2] * btFabs(vdir[1])) return false;
451  f = vdir[2] * Dx - vdir[0] * Dz;
452  if (btFabs(f) > extents[0] * btFabs(vdir[2]) + extents[2] * btFabs(vdir[0])) return false;
453  f = vdir[0] * Dy - vdir[1] * Dx;
454  if (btFabs(f) > extents[0] * btFabs(vdir[1]) + extents[1] * btFabs(vdir[0])) return false;
455  return true;
456  }
457 
458  SIMD_FORCE_INLINE void projection_interval(const btVector3 &direction, btScalar &vmin, btScalar &vmax) const
459  {
460  btVector3 center = (m_max + m_min) * 0.5f;
461  btVector3 extend = m_max - center;
462 
463  btScalar _fOrigin = direction.dot(center);
464  btScalar _fMaximumExtent = extend.dot(direction.absolute());
465  vmin = _fOrigin - _fMaximumExtent;
466  vmax = _fOrigin + _fMaximumExtent;
467  }
468 
470  {
471  btScalar _fmin, _fmax;
472  this->projection_interval(plane, _fmin, _fmax);
473 
474  if (plane[3] > _fmax + BOX_PLANE_EPSILON)
475  {
476  return BT_CONST_BACK_PLANE; // 0
477  }
478 
479  if (plane[3] + BOX_PLANE_EPSILON >= _fmin)
480  {
481  return BT_CONST_COLLIDE_PLANE; //1
482  }
483  return BT_CONST_FRONT_PLANE; //2
484  }
485 
487  {
488  btAABB tbox = box;
489  tbox.appy_transform(trans1_to_0);
490  return has_collision(tbox);
491  }
492 
494  const BT_BOX_BOX_TRANSFORM_CACHE &trans1_to_0) const
495  {
496  btAABB tbox = box;
497  tbox.appy_transform_trans_cache(trans1_to_0);
498  return has_collision(tbox);
499  }
500 
503  const btAABB &box, const BT_BOX_BOX_TRANSFORM_CACHE &transcache, bool fulltest) const
504  {
505  //Taken from OPCODE
506  btVector3 ea, eb; //extends
507  btVector3 ca, cb; //extends
508  get_center_extend(ca, ea);
509  box.get_center_extend(cb, eb);
510 
511  btVector3 T;
512  btScalar t, t2;
513  int i;
514 
515  // Class I : A's basis vectors
516  for (i = 0; i < 3; i++)
517  {
518  T[i] = transcache.m_R1to0[i].dot(cb) + transcache.m_T1to0[i] - ca[i];
519  t = transcache.m_AR[i].dot(eb) + ea[i];
520  if (BT_GREATER(T[i], t)) return false;
521  }
522  // Class II : B's basis vectors
523  for (i = 0; i < 3; i++)
524  {
525  t = bt_mat3_dot_col(transcache.m_R1to0, T, i);
526  t2 = bt_mat3_dot_col(transcache.m_AR, ea, i) + eb[i];
527  if (BT_GREATER(t, t2)) return false;
528  }
529  // Class III : 9 cross products
530  if (fulltest)
531  {
532  int j, m, n, o, p, q, r;
533  for (i = 0; i < 3; i++)
534  {
535  m = (i + 1) % 3;
536  n = (i + 2) % 3;
537  o = i == 0 ? 1 : 0;
538  p = i == 2 ? 1 : 2;
539  for (j = 0; j < 3; j++)
540  {
541  q = j == 2 ? 1 : 2;
542  r = j == 0 ? 1 : 0;
543  t = T[n] * transcache.m_R1to0[m][j] - T[m] * transcache.m_R1to0[n][j];
544  t2 = ea[o] * transcache.m_AR[p][j] + ea[p] * transcache.m_AR[o][j] +
545  eb[r] * transcache.m_AR[i][q] + eb[q] * transcache.m_AR[i][r];
546  if (BT_GREATER(t, t2)) return false;
547  }
548  }
549  }
550  return true;
551  }
552 
555  const btVector4 &plane) const
556  {
557  eBT_PLANE_INTERSECTION_TYPE classify = plane_classify(plane);
558  return (classify == BT_CONST_COLLIDE_PLANE);
559  }
560 
563  const btVector3 &p1,
564  const btVector3 &p2,
565  const btVector3 &p3,
566  const btVector4 &triangle_plane) const
567  {
568  if (!collide_plane(triangle_plane)) return false;
569 
570  btVector3 center, extends;
571  this->get_center_extend(center, extends);
572 
573  const btVector3 v1(p1 - center);
574  const btVector3 v2(p2 - center);
575  const btVector3 v3(p3 - center);
576 
577  //First axis
578  btVector3 diff(v2 - v1);
579  btVector3 abs_diff = diff.absolute();
580  //Test With X axis
581  TEST_CROSS_EDGE_BOX_X_AXIS_MCR(diff, abs_diff, v1, v3, extends);
582  //Test With Y axis
583  TEST_CROSS_EDGE_BOX_Y_AXIS_MCR(diff, abs_diff, v1, v3, extends);
584  //Test With Z axis
585  TEST_CROSS_EDGE_BOX_Z_AXIS_MCR(diff, abs_diff, v1, v3, extends);
586 
587  diff = v3 - v2;
588  abs_diff = diff.absolute();
589  //Test With X axis
590  TEST_CROSS_EDGE_BOX_X_AXIS_MCR(diff, abs_diff, v2, v1, extends);
591  //Test With Y axis
592  TEST_CROSS_EDGE_BOX_Y_AXIS_MCR(diff, abs_diff, v2, v1, extends);
593  //Test With Z axis
594  TEST_CROSS_EDGE_BOX_Z_AXIS_MCR(diff, abs_diff, v2, v1, extends);
595 
596  diff = v1 - v3;
597  abs_diff = diff.absolute();
598  //Test With X axis
599  TEST_CROSS_EDGE_BOX_X_AXIS_MCR(diff, abs_diff, v3, v2, extends);
600  //Test With Y axis
601  TEST_CROSS_EDGE_BOX_Y_AXIS_MCR(diff, abs_diff, v3, v2, extends);
602  //Test With Z axis
603  TEST_CROSS_EDGE_BOX_Z_AXIS_MCR(diff, abs_diff, v3, v2, extends);
604 
605  return true;
606  }
607 };
608 
611 {
612  if (!(t1.getOrigin() == t2.getOrigin())) return false;
613 
614  if (!(t1.getBasis().getRow(0) == t2.getBasis().getRow(0))) return false;
615  if (!(t1.getBasis().getRow(1) == t2.getBasis().getRow(1))) return false;
616  if (!(t1.getBasis().getRow(2) == t2.getBasis().getRow(2))) return false;
617  return true;
618 }
619 
620 #endif // GIM_BOX_COLLISION_H_INCLUDED
btAABB::btAABB
btAABB(const btAABB &other, btScalar margin)
Definition: btBoxCollision.h:263
btVector3::absolute
btVector3 absolute() const
Return a vector with the absolute values of each element.
Definition: btVector3.h:364
BT_BOX_BOX_TRANSFORM_CACHE::BT_BOX_BOX_TRANSFORM_CACHE
BT_BOX_BOX_TRANSFORM_CACHE()
Definition: btBoxCollision.h:177
btAABB::overlapping_trans_cache
bool overlapping_trans_cache(const btAABB &box, const BT_BOX_BOX_TRANSFORM_CACHE &transcache, bool fulltest) const
transcache is the transformation cache from box to this AABB
Definition: btBoxCollision.h:502
BT_BOX_BOX_TRANSFORM_CACHE::calc_absolute_matrix
void calc_absolute_matrix()
Definition: btBoxCollision.h:159
btTransform::inverse
btTransform inverse() const
Return the inverse of this transform.
Definition: btTransform.h:182
btVector3::dot3
btVector3 dot3(const btVector3 &v0, const btVector3 &v1, const btVector3 &v2) const
Definition: btVector3.h:720
btAABB::get_center_extend
void get_center_extend(btVector3 &center, btVector3 &extend) const
Gets the extend and center.
Definition: btBoxCollision.h:399
btScalar
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
Definition: btScalar.h:294
btMatrix3x3::inverse
btMatrix3x3 inverse() const
Return the inverse of the matrix.
Definition: btMatrix3x3.h:1070
BT_CONST_COLLIDE_PLANE
Definition: btBoxCollision.h:48
BT_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: btBoxCollision.h:194
btAABB::btAABB
btAABB()
Definition: btBoxCollision.h:221
eBT_PLANE_INTERSECTION_TYPE
eBT_PLANE_INTERSECTION_TYPE
Definition: btBoxCollision.h:45
btVector3::dot
btScalar dot(const btVector3 &v) const
Return the dot product.
Definition: btVector3.h:229
btAABB::overlapping_trans_conservative2
bool overlapping_trans_conservative2(const btAABB &box, const BT_BOX_BOX_TRANSFORM_CACHE &trans1_to_0) const
Definition: btBoxCollision.h:493
btAABB::projection_interval
void projection_interval(const btVector3 &direction, btScalar &vmin, btScalar &vmax) const
Definition: btBoxCollision.h:458
btAABB::appy_transform_trans_cache
void appy_transform_trans_cache(const BT_BOX_BOX_TRANSFORM_CACHE &trans)
Apply a transform to an AABB.
Definition: btBoxCollision.h:358
BT_BOX_BOX_TRANSFORM_CACHE::transform
btVector3 transform(const btVector3 &point) const
Definition: btBoxCollision.h:205
BT_CONST_BACK_PLANE
Definition: btBoxCollision.h:47
btAABB::collide_triangle_exact
bool collide_triangle_exact(const btVector3 &p1, const btVector3 &p2, const btVector3 &p3, const btVector4 &triangle_plane) const
test for a triangle, with edges
Definition: btBoxCollision.h:562
BT_MIN
#define BT_MIN(a, b)
Definition: btBoxCollision.h:38
btAABB::btAABB
btAABB(const btVector3 &V1, const btVector3 &V2, const btVector3 &V3)
Definition: btBoxCollision.h:225
TEST_CROSS_EDGE_BOX_X_AXIS_MCR
#define TEST_CROSS_EDGE_BOX_X_AXIS_MCR(edge, absolute_edge, pointa, pointb, _extend)
Definition: btBoxCollision.h:128
btAABB::copy_with_margin
void copy_with_margin(const btAABB &other, btScalar margin)
Definition: btBoxCollision.h:293
btVector4
Definition: btVector3.h:1073
btMatrix3x3::getRow
const btVector3 & getRow(int i) const
Get a row of the matrix as a vector.
Definition: btMatrix3x3.h:140
btAABB::find_intersection
void find_intersection(const btAABB &other, btAABB &intersection) const
Finds the intersecting box between this box and the other.
Definition: btBoxCollision.h:406
btCompareTransformsEqual
bool btCompareTransformsEqual(const btTransform &t1, const btTransform &t2)
Compairison of transformation objects.
Definition: btBoxCollision.h:610
btAABB
Axis aligned box.
Definition: btBoxCollision.h:214
btFabs
btScalar btFabs(btScalar x)
Definition: btScalar.h:477
btAABB::increment_margin
void increment_margin(btScalar margin)
Definition: btBoxCollision.h:283
BT_MAX
#define BT_MAX(a, b)
Definition: btBoxCollision.h:37
btTransform::getBasis
btMatrix3x3 & getBasis()
Return the basis matrix for the rotation.
Definition: btTransform.h:108
TEST_CROSS_EDGE_BOX_Y_AXIS_MCR
#define TEST_CROSS_EDGE_BOX_Y_AXIS_MCR(edge, absolute_edge, pointa, pointb, _extend)
Definition: btBoxCollision.h:133
btMatrix3x3
The btMatrix3x3 class implements a 3x3 rotation matrix, to perform linear algebra in combination with...
Definition: btMatrix3x3.h:46
btTransform.h
btTransform
The btTransform class supports rigid transforms with only translation and rotation and no scaling/she...
Definition: btTransform.h:28
BOX_PLANE_EPSILON
#define BOX_PLANE_EPSILON
Definition: btBoxCollision.h:211
btAABB::invalidate
void invalidate()
Definition: btBoxCollision.h:273
btAABB::overlapping_trans_conservative
bool overlapping_trans_conservative(const btAABB &box, btTransform &trans1_to_0) const
Definition: btBoxCollision.h:486
TEST_CROSS_EDGE_BOX_Z_AXIS_MCR
#define TEST_CROSS_EDGE_BOX_Z_AXIS_MCR(edge, absolute_edge, pointa, pointb, _extend)
Definition: btBoxCollision.h:138
SIMD_INFINITY
#define SIMD_INFINITY
Definition: btScalar.h:524
btVector3
btVector3 can be used to represent 3D points and vectors.
Definition: btVector3.h:80
btTransform::getOrigin
btVector3 & getOrigin()
Return the origin vector translation.
Definition: btTransform.h:113
btAABB::btAABB
btAABB(const btVector3 &V1, const btVector3 &V2, const btVector3 &V3, btScalar margin)
Definition: btBoxCollision.h:238
ATTRIBUTE_ALIGNED16
#define ATTRIBUTE_ALIGNED16(a)
Definition: btScalar.h:84
BT_MAX3
#define BT_MAX3(a, b, c)
Definition: btBoxCollision.h:42
BT_MIN3
#define BT_MIN3(a, b, c)
Definition: btBoxCollision.h:43
btAABB::calc_from_triangle_margin
void calc_from_triangle_margin(const CLASS_POINT &V1, const CLASS_POINT &V2, const CLASS_POINT &V3, btScalar margin)
Definition: btBoxCollision.h:320
BT_BOX_BOX_TRANSFORM_CACHE::m_T1to0
btVector3 m_T1to0
Transforms translation of model1 to model 0.
Definition: btBoxCollision.h:155
SIMD_FORCE_INLINE
#define SIMD_FORCE_INLINE
Definition: btScalar.h:83
BT_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: btBoxCollision.h:182
btAABB::m_max
btVector3 m_max
Definition: btBoxCollision.h:219
btAABB::merge_point
void merge_point(const CLASS_POINT &point)
Merges a point.
Definition: btBoxCollision.h:387
btAABB::merge
void merge(const btAABB &box)
Merges a Box.
Definition: btBoxCollision.h:374
btAABB::appy_transform
void appy_transform(const btTransform &trans)
Apply a transform to an AABB.
Definition: btBoxCollision.h:342
BT_BOX_BOX_TRANSFORM_CACHE
Class for transforming a model1 to the space of model0.
Definition: btBoxCollision.h:151
btAABB::collide_ray
bool collide_ray(const btVector3 &vorigin, const btVector3 &vdir) const
Finds the Ray intersection parameter.
Definition: btBoxCollision.h:436
BT_CONST_FRONT_PLANE
Definition: btBoxCollision.h:49
BT_BOX_BOX_TRANSFORM_CACHE::m_R1to0
btMatrix3x3 m_R1to0
Transforms Rotation of model1 to model 0, equal to R0' * R1.
Definition: btBoxCollision.h:156
btAABB::m_min
btVector3 m_min
Definition: btBoxCollision.h:218
btAABB::plane_classify
eBT_PLANE_INTERSECTION_TYPE plane_classify(const btVector4 &plane) const
Definition: btBoxCollision.h:469
bt_mat3_dot_col
btScalar bt_mat3_dot_col(const btMatrix3x3 &mat, const btVector3 &vec3, int colindex)
Returns the dot product between a vec3f and the col of a matrix.
Definition: btBoxCollision.h:144
btAABB::btAABB
btAABB(const btAABB &other)
Definition: btBoxCollision.h:259
BT_BOX_BOX_TRANSFORM_CACHE::m_AR
btMatrix3x3 m_AR
Absolute value of m_R1to0.
Definition: btBoxCollision.h:157
btAABB::has_collision
bool has_collision(const btAABB &other) const
Definition: btBoxCollision.h:417
BT_GREATER
#define BT_GREATER(x, y)
Definition: btBoxCollision.h:40
btAABB::calc_from_triangle
void calc_from_triangle(const CLASS_POINT &V1, const CLASS_POINT &V2, const CLASS_POINT &V3)
Definition: btBoxCollision.h:305
btAABB::collide_plane
bool collide_plane(const btVector4 &plane) const
Simple test for planes.
Definition: btBoxCollision.h:554