Bullet Collision Detection & Physics Library
gim_box_set.h
Go to the documentation of this file.
1 #ifndef GIM_BOX_SET_H_INCLUDED
2 #define GIM_BOX_SET_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 
36 #include "gim_array.h"
37 #include "gim_radixsort.h"
38 #include "gim_box_collision.h"
39 #include "gim_tri_collision.h"
40 
42 struct GIM_PAIR
43 {
47  {
48  }
49 
50  GIM_PAIR(const GIM_PAIR& p)
51  {
52  m_index1 = p.m_index1;
53  m_index2 = p.m_index2;
54  }
55 
56  GIM_PAIR(GUINT index1, GUINT index2)
57  {
58  m_index1 = index1;
59  m_index2 = index2;
60  }
61 };
62 
64 class gim_pair_set : public gim_array<GIM_PAIR>
65 {
66 public:
68  {
69  }
70  inline void push_pair(GUINT index1, GUINT index2)
71  {
72  push_back(GIM_PAIR(index1, index2));
73  }
74 
75  inline void push_pair_inv(GUINT index1, GUINT index2)
76  {
77  push_back(GIM_PAIR(index2, index1));
78  }
79 };
80 
82 
88 {
89 public:
92  virtual bool is_trimesh() = 0;
93  virtual GUINT get_primitive_count() = 0;
94  virtual void get_primitive_box(GUINT prim_index, GIM_AABB& primbox) = 0;
95  virtual void get_primitive_triangle(GUINT prim_index, GIM_TRIANGLE& triangle) = 0;
96 };
97 
99 {
102 };
103 
106 {
112 
114  {
115  m_left = 0;
116  m_right = 0;
117  m_escapeIndex = 0;
118  m_data = 0;
119  }
120 
122  {
123  return (!m_left && !m_right);
124  }
125 };
126 
129 {
130 protected:
133 
134 protected:
136  gim_array<GIM_AABB_DATA>& primitive_boxes,
137  GUINT startIndex, GUINT endIndex, GUINT splitAxis);
138 
139  GUINT _calc_splitting_axis(gim_array<GIM_AABB_DATA>& primitive_boxes, GUINT startIndex, GUINT endIndex);
140 
141  void _build_sub_tree(gim_array<GIM_AABB_DATA>& primitive_boxes, GUINT startIndex, GUINT endIndex);
142 
143 public:
145  {
146  m_num_nodes = 0;
147  }
148 
151  void build_tree(gim_array<GIM_AABB_DATA>& primitive_boxes);
152 
154  {
156  m_num_nodes = 0;
157  }
158 
161  {
162  return m_num_nodes;
163  }
164 
166  SIMD_FORCE_INLINE bool isLeafNode(GUINT nodeindex) const
167  {
168  return m_node_array[nodeindex].is_leaf_node();
169  }
170 
172  {
173  return m_node_array[nodeindex].m_data;
174  }
175 
176  SIMD_FORCE_INLINE void getNodeBound(GUINT nodeindex, GIM_AABB& bound) const
177  {
178  bound = m_node_array[nodeindex].m_bound;
179  }
180 
181  SIMD_FORCE_INLINE void setNodeBound(GUINT nodeindex, const GIM_AABB& bound)
182  {
183  m_node_array[nodeindex].m_bound = bound;
184  }
185 
187  {
188  return m_node_array[nodeindex].m_left;
189  }
190 
192  {
193  return m_node_array[nodeindex].m_right;
194  }
195 
197  {
198  return m_node_array[nodeindex].m_escapeIndex;
199  }
200 
202 };
203 
205 
210 template <typename _GIM_PRIMITIVE_MANAGER_PROTOTYPE, typename _GIM_BOX_TREE_PROTOTYPE>
212 {
213 protected:
214  _GIM_PRIMITIVE_MANAGER_PROTOTYPE m_primitive_manager;
215  _GIM_BOX_TREE_PROTOTYPE m_box_tree;
216 
217 protected:
218  //stackless refit
220  {
221  GUINT nodecount = getNodeCount();
222  while (nodecount--)
223  {
224  if (isLeafNode(nodecount))
225  {
226  GIM_AABB leafbox;
227  m_primitive_manager.get_primitive_box(getNodeData(nodecount), leafbox);
228  setNodeBound(nodecount, leafbox);
229  }
230  else
231  {
232  //get left bound
233  GUINT childindex = getLeftNodeIndex(nodecount);
234  GIM_AABB bound;
235  getNodeBound(childindex, bound);
236  //get right bound
237  childindex = getRightNodeIndex(nodecount);
238  GIM_AABB bound2;
239  getNodeBound(childindex, bound2);
240  bound.merge(bound2);
241 
242  setNodeBound(nodecount, bound);
243  }
244  }
245  }
246 
247 public:
249  {
250  }
251 
253  {
254  GIM_AABB totalbox;
255  getNodeBound(0, totalbox);
256  return totalbox;
257  }
258 
259  SIMD_FORCE_INLINE void setPrimitiveManager(const _GIM_PRIMITIVE_MANAGER_PROTOTYPE& primitive_manager)
260  {
261  m_primitive_manager = primitive_manager;
262  }
263 
264  const _GIM_PRIMITIVE_MANAGER_PROTOTYPE& getPrimitiveManager() const
265  {
266  return m_primitive_manager;
267  }
268 
269  _GIM_PRIMITIVE_MANAGER_PROTOTYPE& getPrimitiveManager()
270  {
271  return m_primitive_manager;
272  }
273 
276 
279  {
280  refit();
281  }
282 
285  {
286  //obtain primitive boxes
287  gim_array<GIM_AABB_DATA> primitive_boxes;
288  primitive_boxes.resize(m_primitive_manager.get_primitive_count(), false);
289 
290  for (GUINT i = 0; i < primitive_boxes.size(); i++)
291  {
292  m_primitive_manager.get_primitive_box(i, primitive_boxes[i].m_bound);
293  primitive_boxes[i].m_data = i;
294  }
295 
296  m_box_tree.build_tree(primitive_boxes);
297  }
298 
300  SIMD_FORCE_INLINE bool boxQuery(const GIM_AABB& box, gim_array<GUINT>& collided_results) const
301  {
302  GUINT curIndex = 0;
303  GUINT numNodes = getNodeCount();
304 
305  while (curIndex < numNodes)
306  {
307  GIM_AABB bound;
308  getNodeBound(curIndex, bound);
309 
310  //catch bugs in tree data
311 
312  bool aabbOverlap = bound.has_collision(box);
313  bool isleafnode = isLeafNode(curIndex);
314 
315  if (isleafnode && aabbOverlap)
316  {
317  collided_results.push_back(getNodeData(curIndex));
318  }
319 
320  if (aabbOverlap || isleafnode)
321  {
322  //next subnode
323  curIndex++;
324  }
325  else
326  {
327  //skip node
328  curIndex += getScapeNodeIndex(curIndex);
329  }
330  }
331  if (collided_results.size() > 0) return true;
332  return false;
333  }
334 
337  const btTransform& transform, gim_array<GUINT>& collided_results) const
338  {
339  GIM_AABB transbox = box;
340  transbox.appy_transform(transform);
341  return boxQuery(transbox, collided_results);
342  }
343 
346  const btVector3& ray_dir, const btVector3& ray_origin,
347  gim_array<GUINT>& collided_results) const
348  {
349  GUINT curIndex = 0;
350  GUINT numNodes = getNodeCount();
351 
352  while (curIndex < numNodes)
353  {
354  GIM_AABB bound;
355  getNodeBound(curIndex, bound);
356 
357  //catch bugs in tree data
358 
359  bool aabbOverlap = bound.collide_ray(ray_origin, ray_dir);
360  bool isleafnode = isLeafNode(curIndex);
361 
362  if (isleafnode && aabbOverlap)
363  {
364  collided_results.push_back(getNodeData(curIndex));
365  }
366 
367  if (aabbOverlap || isleafnode)
368  {
369  //next subnode
370  curIndex++;
371  }
372  else
373  {
374  //skip node
375  curIndex += getScapeNodeIndex(curIndex);
376  }
377  }
378  if (collided_results.size() > 0) return true;
379  return false;
380  }
381 
384  {
385  return true;
386  }
387 
390  {
391  return m_primitive_manager.is_trimesh();
392  }
393 
396  {
397  return m_box_tree.getNodeCount();
398  }
399 
401  SIMD_FORCE_INLINE bool isLeafNode(GUINT nodeindex) const
402  {
403  return m_box_tree.isLeafNode(nodeindex);
404  }
405 
407  {
408  return m_box_tree.getNodeData(nodeindex);
409  }
410 
411  SIMD_FORCE_INLINE void getNodeBound(GUINT nodeindex, GIM_AABB& bound) const
412  {
413  m_box_tree.getNodeBound(nodeindex, bound);
414  }
415 
416  SIMD_FORCE_INLINE void setNodeBound(GUINT nodeindex, const GIM_AABB& bound)
417  {
418  m_box_tree.setNodeBound(nodeindex, bound);
419  }
420 
422  {
423  return m_box_tree.getLeftNodeIndex(nodeindex);
424  }
425 
427  {
428  return m_box_tree.getRightNodeIndex(nodeindex);
429  }
430 
432  {
433  return m_box_tree.getScapeNodeIndex(nodeindex);
434  }
435 
436  SIMD_FORCE_INLINE void getNodeTriangle(GUINT nodeindex, GIM_TRIANGLE& triangle) const
437  {
438  m_primitive_manager.get_primitive_triangle(getNodeData(nodeindex), triangle);
439  }
440 };
441 
443 
446 template <typename _GIM_PRIMITIVE_MANAGER_PROTOTYPE>
447 class GIM_BOX_TREE_SET : public GIM_BOX_TREE_TEMPLATE_SET<_GIM_PRIMITIVE_MANAGER_PROTOTYPE, GIM_BOX_TREE>
448 {
449 public:
450 };
451 
453 template <typename BOX_SET_CLASS0, typename BOX_SET_CLASS1>
455 {
456 public:
458  BOX_SET_CLASS0* m_boxset0;
459  BOX_SET_CLASS1* m_boxset1;
476 
477 public:
479  {
482  }
483 
484 protected:
486  {
487  if (node0_has_triangle) return;
488  m_boxset0->getNodeTriangle(node0, m_tri0);
489  //transform triangle
494 
495  node0_has_triangle = true;
496  }
497 
499  {
500  if (node1_has_triangle) return;
501  m_boxset1->getNodeTriangle(node1, m_tri1);
502  //transform triangle
507 
508  node1_has_triangle = true;
509  }
510 
512  {
513  if (node0 == current_node0) return;
514  m_boxset0->getNodeBound(node0, m_box0);
515  node0_is_leaf = m_boxset0->isLeafNode(node0);
516  node0_has_triangle = false;
517  current_node0 = node0;
518  }
519 
521  {
522  if (node1 == current_node1) return;
523  m_boxset1->getNodeBound(node1, m_box1);
524  node1_is_leaf = m_boxset1->isLeafNode(node1);
525  node1_has_triangle = false;
526  current_node1 = node1;
527  }
528 
530  {
531  retrieve_node0_info(node0);
532  retrieve_node1_info(node1);
534  if (!result) return false;
535 
537  {
538  //perform primitive vs box collision
540  //do triangle vs box collision
542 
545 
547 
548  if (!result) return false;
549  return true;
550  }
551  else if (t1_is_trimesh && node1_is_leaf)
552  {
553  //perform primitive vs box collision
555  //do triangle vs box collision
557 
560 
562 
563  if (!result) return false;
564  return true;
565  }
566  return true;
567  }
568 
569  //stackless collision routine
571  {
572  gim_pair_set stack_collisions;
573  stack_collisions.reserve(32);
574 
575  //add the first pair
576  stack_collisions.push_pair(0, 0);
577 
578  while (stack_collisions.size())
579  {
580  //retrieve the last pair and pop
581  GUINT node0 = stack_collisions.back().m_index1;
582  GUINT node1 = stack_collisions.back().m_index2;
583  stack_collisions.pop_back();
584  if (node_collision(node0, node1)) // a collision is found
585  {
586  if (node0_is_leaf)
587  {
588  if (node1_is_leaf)
589  {
590  m_collision_pairs->push_pair(m_boxset0->getNodeData(node0), m_boxset1->getNodeData(node1));
591  }
592  else
593  {
594  //collide left
595  stack_collisions.push_pair(node0, m_boxset1->getLeftNodeIndex(node1));
596 
597  //collide right
598  stack_collisions.push_pair(node0, m_boxset1->getRightNodeIndex(node1));
599  }
600  }
601  else
602  {
603  if (node1_is_leaf)
604  {
605  //collide left
606  stack_collisions.push_pair(m_boxset0->getLeftNodeIndex(node0), node1);
607  //collide right
608  stack_collisions.push_pair(m_boxset0->getRightNodeIndex(node0), node1);
609  }
610  else
611  {
612  GUINT left0 = m_boxset0->getLeftNodeIndex(node0);
613  GUINT right0 = m_boxset0->getRightNodeIndex(node0);
614  GUINT left1 = m_boxset1->getLeftNodeIndex(node1);
615  GUINT right1 = m_boxset1->getRightNodeIndex(node1);
616  //collide left
617  stack_collisions.push_pair(left0, left1);
618  //collide right
619  stack_collisions.push_pair(left0, right1);
620  //collide left
621  stack_collisions.push_pair(right0, left1);
622  //collide right
623  stack_collisions.push_pair(right0, right1);
624 
625  } // else if node1 is not a leaf
626  } // else if node0 is not a leaf
627 
628  } // if(node_collision(node0,node1))
629  } //while(stack_collisions.size())
630  }
631 
632 public:
633  void find_collision(BOX_SET_CLASS0* boxset1, const btTransform& trans1,
634  BOX_SET_CLASS1* boxset2, const btTransform& trans2,
635  gim_pair_set& collision_pairs, bool complete_primitive_tests = true)
636  {
637  m_collision_pairs = &collision_pairs;
638  m_boxset0 = boxset1;
639  m_boxset1 = boxset2;
640 
641  trans_cache_1to0.calc_from_homogenic(trans1, trans2);
642 
643  trans_cache_0to1 = trans2.inverse();
644  trans_cache_0to1 *= trans1;
645 
646  if (complete_primitive_tests)
647  {
648  t0_is_trimesh = boxset1->getPrimitiveManager().is_trimesh();
649  t1_is_trimesh = boxset2->getPrimitiveManager().is_trimesh();
650  }
651  else
652  {
653  t0_is_trimesh = false;
654  t1_is_trimesh = false;
655  }
656 
658  }
659 };
660 
661 #endif // GIM_BOXPRUNING_H_INCLUDED
GIM_BOX_TREE_TEMPLATE_SET::hasHierarchy
bool hasHierarchy() const
tells if this set has hierarcht
Definition: gim_box_set.h:383
gim_array::m_data
T * m_data
properties
Definition: gim_array.h:47
GIM_BOX_TREE_NODE
Node Structure for trees.
Definition: gim_box_set.h:105
GIM_AABB_DATA::m_bound
GIM_AABB m_bound
Definition: gim_box_set.h:100
GIM_AABB::merge
void merge(const GIM_AABB &box)
Merges a Box.
Definition: gim_box_collision.h:338
GIM_TREE_TREE_COLLIDER::m_collision_pairs
gim_pair_set * m_collision_pairs
Definition: gim_box_set.h:457
GIM_BOX_TREE::_build_sub_tree
void _build_sub_tree(gim_array< GIM_AABB_DATA > &primitive_boxes, GUINT startIndex, GUINT endIndex)
Definition: gim_box_set.cpp:115
GIM_TREE_TREE_COLLIDER::retrieve_node1_triangle
void retrieve_node1_triangle(GUINT node1)
Definition: gim_box_set.h:498
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:161
GIM_AABB_DATA::m_data
GUINT m_data
Definition: gim_box_set.h:101
GIM_BOX_TREE_NODE::GIM_BOX_TREE_NODE
GIM_BOX_TREE_NODE()
Definition: gim_box_set.h:113
btTransform::inverse
btTransform inverse() const
Return the inverse of this transform.
Definition: btTransform.h:182
GIM_TREE_TREE_COLLIDER::node0_has_triangle
bool node0_has_triangle
Definition: gim_box_set.h:466
GIM_BOX_TREE::build_tree
void build_tree(gim_array< GIM_AABB_DATA > &primitive_boxes)
prototype functions for box tree management
Definition: gim_box_set.cpp:167
GIM_BOX_TREE::m_num_nodes
GUINT m_num_nodes
Definition: gim_box_set.h:131
GIM_BOX_TREE_TEMPLATE_SET::GIM_BOX_TREE_TEMPLATE_SET
GIM_BOX_TREE_TEMPLATE_SET()
Definition: gim_box_set.h:248
GIM_TREE_TREE_COLLIDER::m_tri1_plane
btVector4 m_tri1_plane
Definition: gim_box_set.h:475
GIM_BOX_TREE::getScapeNodeIndex
GUINT getScapeNodeIndex(GUINT nodeindex) const
Definition: gim_box_set.h:196
gim_array
Very simple array container with fast access and simd memory.
Definition: gim_array.h:42
GIM_PAIR::GIM_PAIR
GIM_PAIR(GUINT index1, GUINT index2)
Definition: gim_box_set.h:56
gim_array.h
GIM_PAIR::m_index1
int m_index1
Definition: btGImpactBvhStructs.h:35
GIM_BOX_TREE_TEMPLATE_SET::getGlobalBox
GIM_AABB getGlobalBox() const
Definition: gim_box_set.h:252
GIM_BOX_BOX_TRANSFORM_CACHE::transform
btVector3 transform(const btVector3 &point)
Definition: gim_box_collision.h:184
GIM_BOX_TREE
Basic Box tree structure.
Definition: gim_box_set.h:128
GIM_BOX_TREE_NODE::m_left
GUINT m_left
Left subtree.
Definition: gim_box_set.h:108
GIM_BOX_TREE::clearNodes
void clearNodes()
Definition: gim_box_set.h:153
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:518
GIM_PRIMITIVE_MANAGER_PROTOTYPE::get_primitive_triangle
virtual void get_primitive_triangle(GUINT prim_index, GIM_TRIANGLE &triangle)=0
GIM_TREE_TREE_COLLIDER::node0_is_leaf
bool node0_is_leaf
Definition: gim_box_set.h:462
GIM_TREE_TREE_COLLIDER::m_tri0_plane
btVector4 m_tri0_plane
Definition: gim_box_set.h:473
GIM_TREE_TREE_COLLIDER::retrieve_node0_info
void retrieve_node0_info(GUINT node0)
Definition: gim_box_set.h:511
GIM_BOX_TREE_TEMPLATE_SET::getRightNodeIndex
GUINT getRightNodeIndex(GUINT nodeindex) const
Definition: gim_box_set.h:426
GIM_BOX_TREE_TEMPLATE_SET::getNodeCount
GUINT getNodeCount() const
node count
Definition: gim_box_set.h:395
gim_array::reserve
bool reserve(GUINT size)
public operations
Definition: gim_array.h:96
GIM_BOX_TREE_TEMPLATE_SET::buildSet
void buildSet()
this rebuild the entire set
Definition: gim_box_set.h:284
GIM_PAIR::m_index2
int m_index2
Definition: btGImpactBvhStructs.h:36
GIM_BOX_TREE_NODE::is_leaf_node
bool is_leaf_node() const
Definition: gim_box_set.h:121
GUINT
#define GUINT
Definition: gim_math.h:40
GIM_TREE_TREE_COLLIDER::node1_is_leaf
bool node1_is_leaf
Definition: gim_box_set.h:463
GIM_BOX_TREE::getNodeBound
void getNodeBound(GUINT nodeindex, GIM_AABB &bound) const
Definition: gim_box_set.h:176
GIM_PRIMITIVE_MANAGER_PROTOTYPE::get_primitive_box
virtual void get_primitive_box(GUINT prim_index, GIM_AABB &primbox)=0
GIM_PAIR::m_index2
GUINT m_index2
Definition: gim_box_set.h:45
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:458
GIM_BOX_TREE_NODE::m_data
GUINT m_data
primitive index if apply
Definition: gim_box_set.h:111
GIM_BOX_TREE_TEMPLATE_SET::getPrimitiveManager
const _GIM_PRIMITIVE_MANAGER_PROTOTYPE & getPrimitiveManager() const
Definition: gim_box_set.h:264
GIM_TREE_TREE_COLLIDER::m_box1
GIM_AABB m_box1
Definition: gim_box_set.h:469
GIM_TREE_TREE_COLLIDER::node1_has_triangle
bool node1_has_triangle
Definition: gim_box_set.h:467
GIM_AABB_DATA
Definition: gim_box_set.h:98
btVector4
Definition: btVector3.h:1073
GIM_AABB::has_collision
bool has_collision(const GIM_AABB &other) const
Definition: gim_box_collision.h:381
GIM_TREE_TREE_COLLIDER::trans_cache_1to0
GIM_BOX_BOX_TRANSFORM_CACHE trans_cache_1to0
Definition: gim_box_set.h:470
GIM_BOX_TREE_TEMPLATE_SET::refit
void refit()
Definition: gim_box_set.h:219
GIM_BOX_TREE_TEMPLATE_SET::rayQuery
bool rayQuery(const btVector3 &ray_dir, const btVector3 &ray_origin, gim_array< GUINT > &collided_results) const
returns the indices of the primitives in the m_primitive_manager
Definition: gim_box_set.h:345
GIM_BOX_TREE_TEMPLATE_SET::getNodeTriangle
void getNodeTriangle(GUINT nodeindex, GIM_TRIANGLE &triangle) const
Definition: gim_box_set.h:436
GIM_TRIANGLE::m_margin
btScalar m_margin
Definition: gim_tri_collision.h:123
GIM_BOX_TREE_TEMPLATE_SET::getNodeBound
void getNodeBound(GUINT nodeindex, GIM_AABB &bound) const
Definition: gim_box_set.h:411
GIM_BOX_TREE::_sort_and_calc_splitting_index
GUINT _sort_and_calc_splitting_index(gim_array< GIM_AABB_DATA > &primitive_boxes, GUINT startIndex, GUINT endIndex, GUINT splitAxis)
Definition: gim_box_set.cpp:63
GIM_AABB
Axis aligned box.
Definition: gim_box_collision.h:195
GIM_TRIANGLE
Class for colliding triangles.
Definition: gim_tri_collision.h:120
GIM_TREE_TREE_COLLIDER::m_boxset1
BOX_SET_CLASS1 * m_boxset1
Definition: gim_box_set.h:459
GIM_BOX_TREE_NODE::m_right
GUINT m_right
Right subtree.
Definition: gim_box_set.h:109
GIM_BOX_TREE::getNodeData
GUINT getNodeData(GUINT nodeindex) const
Definition: gim_box_set.h:171
GIM_AABB::increment_margin
void increment_margin(btScalar margin)
Definition: gim_box_collision.h:263
GIM_BOX_TREE_TEMPLATE_SET::setPrimitiveManager
void setPrimitiveManager(const _GIM_PRIMITIVE_MANAGER_PROTOTYPE &primitive_manager)
Definition: gim_box_set.h:259
GIM_BOX_TREE::getNodeCount
GUINT getNodeCount() const
node count
Definition: gim_box_set.h:160
GIM_TREE_TREE_COLLIDER::t0_is_trimesh
bool t0_is_trimesh
Definition: gim_box_set.h:464
gim_radixsort.h
GIM_TRIANGLE::get_plane
void get_plane(btVector4 &plane) const
Definition: gim_tri_collision.h:140
GIM_TREE_TREE_COLLIDER
GIM_BOX_SET collision methods.
Definition: gim_box_set.h:454
GIM_BOX_TREE_TEMPLATE_SET::getLeftNodeIndex
GUINT getLeftNodeIndex(GUINT nodeindex) const
Definition: gim_box_set.h:421
GIM_BOX_TREE_TEMPLATE_SET::getPrimitiveManager
_GIM_PRIMITIVE_MANAGER_PROTOTYPE & getPrimitiveManager()
Definition: gim_box_set.h:269
GIM_TREE_TREE_COLLIDER::retrieve_node0_triangle
void retrieve_node0_triangle(GUINT node0)
Definition: gim_box_set.h:485
GIM_BOX_TREE_NODE::m_escapeIndex
GUINT m_escapeIndex
Scape index for traversing.
Definition: gim_box_set.h:110
GIM_TREE_TREE_COLLIDER::m_tri1
GIM_TRIANGLE m_tri1
Definition: gim_box_set.h:474
gim_array::back
T & back()
Definition: gim_array.h:198
GIM_BOX_TREE_TEMPLATE_SET::isTrimesh
bool isTrimesh() const
tells if this set is a trimesh
Definition: gim_box_set.h:389
btTransform
The btTransform class supports rigid transforms with only translation and rotation and no scaling/she...
Definition: btTransform.h:28
GIM_BOX_TREE_TEMPLATE_SET::m_box_tree
_GIM_BOX_TREE_PROTOTYPE m_box_tree
Definition: gim_box_set.h:215
GIM_TREE_TREE_COLLIDER::m_tri0
GIM_TRIANGLE m_tri0
Definition: gim_box_set.h:472
GIM_BOX_TREE::getRightNodeIndex
GUINT getRightNodeIndex(GUINT nodeindex) const
Definition: gim_box_set.h:191
GIM_TREE_TREE_COLLIDER::m_boxset0
BOX_SET_CLASS0 * m_boxset0
Definition: gim_box_set.h:458
GIM_TREE_TREE_COLLIDER::node_collision
bool node_collision(GUINT node0, GUINT node1)
Definition: gim_box_set.h:529
btVector3
btVector3 can be used to represent 3D points and vectors.
Definition: btVector3.h:80
GIM_PAIR
Overlapping pair.
Definition: btGImpactBvhStructs.h:33
gim_array::pop_back
void pop_back()
Definition: gim_array.h:234
gim_array< GIM_PAIR >::push_back
void push_back(const GIM_PAIR &obj)
Definition: gim_array.h:213
GIM_TREE_TREE_COLLIDER::m_box0
GIM_AABB m_box0
Definition: gim_box_set.h:468
GIM_BOX_TREE_TEMPLATE_SET::isLeafNode
bool isLeafNode(GUINT nodeindex) const
tells if the node is a leaf
Definition: gim_box_set.h:401
GIM_PRIMITIVE_MANAGER_PROTOTYPE::~GIM_PRIMITIVE_MANAGER_PROTOTYPE
virtual ~GIM_PRIMITIVE_MANAGER_PROTOTYPE()
Definition: gim_box_set.h:90
GIM_BOX_TREE::isLeafNode
bool isLeafNode(GUINT nodeindex) const
tells if the node is a leaf
Definition: gim_box_set.h:166
GIM_BOX_TREE_TEMPLATE_SET::setNodeBound
void setNodeBound(GUINT nodeindex, const GIM_AABB &bound)
Definition: gim_box_set.h:416
GIM_TREE_TREE_COLLIDER::t1_is_trimesh
bool t1_is_trimesh
Definition: gim_box_set.h:465
GIM_TREE_TREE_COLLIDER::current_node0
GUINT current_node0
Definition: gim_box_set.h:460
GIM_BOX_TREE_TEMPLATE_SET::update
void update()
node manager prototype functions
Definition: gim_box_set.h:278
GIM_AABB::collide_ray
bool collide_ray(const btVector3 &vorigin, const btVector3 &vdir)
Finds the Ray intersection parameter.
Definition: gim_box_collision.h:400
GIM_BOX_BOX_TRANSFORM_CACHE
Class for transforming a model1 to the space of model0.
Definition: gim_box_collision.h:134
gim_box_collision.h
SIMD_FORCE_INLINE
#define SIMD_FORCE_INLINE
Definition: btScalar.h:83
GIM_BOX_TREE_TEMPLATE_SET
Generic Box Tree Template.
Definition: gim_box_set.h:211
GIM_PAIR::m_index1
GUINT m_index1
Definition: gim_box_set.h:44
gim_array::clear
void clear()
Definition: gim_array.h:110
GIM_BOX_TREE::_calc_splitting_axis
GUINT _calc_splitting_axis(gim_array< GIM_AABB_DATA > &primitive_boxes, GUINT startIndex, GUINT endIndex)
Definition: gim_box_set.cpp:33
GIM_PAIR::GIM_PAIR
GIM_PAIR()
Definition: gim_box_set.h:46
GIM_BOX_TREE::GIM_BOX_TREE
GIM_BOX_TREE()
Definition: gim_box_set.h:144
GIM_TREE_TREE_COLLIDER::current_node1
GUINT current_node1
Definition: gim_box_set.h:461
GIM_PAIR::GIM_PAIR
GIM_PAIR(const GIM_PAIR &p)
Definition: gim_box_set.h:50
GIM_TREE_TREE_COLLIDER::find_collision_pairs
void find_collision_pairs()
Definition: gim_box_set.h:570
GIM_BOX_TREE_SET
Class for Box Tree Sets.
Definition: gim_box_set.h:447
GIM_TREE_TREE_COLLIDER::retrieve_node1_info
void retrieve_node1_info(GUINT node1)
Definition: gim_box_set.h:520
GIM_TREE_TREE_COLLIDER::trans_cache_0to1
btTransform trans_cache_0to1
Definition: gim_box_set.h:471
GIM_BOX_TREE_TEMPLATE_SET::getNodeData
GUINT getNodeData(GUINT nodeindex) const
Definition: gim_box_set.h:406
GIM_BOX_TREE_TEMPLATE_SET::getScapeNodeIndex
GUINT getScapeNodeIndex(GUINT nodeindex) const
Definition: gim_box_set.h:431
GIM_BOX_TREE_TEMPLATE_SET::boxQueryTrans
bool boxQueryTrans(const GIM_AABB &box, const btTransform &transform, gim_array< GUINT > &collided_results) const
returns the indices of the primitives in the m_primitive_manager
Definition: gim_box_set.h:336
gim_pair_set
A pairset array.
Definition: gim_box_set.h:64
GIM_TREE_TREE_COLLIDER::find_collision
void find_collision(BOX_SET_CLASS0 *boxset1, const btTransform &trans1, BOX_SET_CLASS1 *boxset2, const btTransform &trans2, gim_pair_set &collision_pairs, bool complete_primitive_tests=true)
Definition: gim_box_set.h:633
gim_array::resize
void resize(GUINT size, bool call_constructor=true, const T &fillData=T())
Definition: gim_array.h:287
GIM_BOX_TREE_TEMPLATE_SET::m_primitive_manager
_GIM_PRIMITIVE_MANAGER_PROTOTYPE m_primitive_manager
Definition: gim_box_set.h:214
gim_tri_collision.h
gim_pair_set::push_pair_inv
void push_pair_inv(GUINT index1, GUINT index2)
Definition: gim_box_set.h:75
G_UINT_INFINITY
#define G_UINT_INFINITY
A very very high value.
Definition: gim_math.h:53
GIM_BOX_TREE_NODE::m_bound
GIM_AABB m_bound
Definition: gim_box_set.h:107
gim_pair_set::gim_pair_set
gim_pair_set()
Definition: gim_box_set.h:67
GIM_BOX_TREE::setNodeBound
void setNodeBound(GUINT nodeindex, const GIM_AABB &bound)
Definition: gim_box_set.h:181
gim_pair_set::push_pair
void push_pair(GUINT index1, GUINT index2)
Definition: gim_box_set.h:70
GIM_AABB::appy_transform
void appy_transform(const btTransform &trans)
Apply a transform to an AABB.
Definition: gim_box_collision.h:322
GIM_TREE_TREE_COLLIDER::GIM_TREE_TREE_COLLIDER
GIM_TREE_TREE_COLLIDER()
Definition: gim_box_set.h:478
GIM_BOX_TREE_TEMPLATE_SET::boxQuery
bool boxQuery(const GIM_AABB &box, gim_array< GUINT > &collided_results) const
returns the indices of the primitives in the m_primitive_manager
Definition: gim_box_set.h:300
GIM_TRIANGLE::m_vertices
btVector3 m_vertices[3]
Definition: gim_tri_collision.h:124
gim_array::size
GUINT size() const
Definition: gim_array.h:143
GIM_BOX_TREE::getLeftNodeIndex
GUINT getLeftNodeIndex(GUINT nodeindex) const
Definition: gim_box_set.h:186
GIM_PRIMITIVE_MANAGER_PROTOTYPE
Prototype Base class for primitive classification.
Definition: gim_box_set.h:87
GIM_PRIMITIVE_MANAGER_PROTOTYPE::get_primitive_count
virtual GUINT get_primitive_count()=0
GIM_BOX_TREE::m_node_array
gim_array< GIM_BOX_TREE_NODE > m_node_array
Definition: gim_box_set.h:132
GIM_PRIMITIVE_MANAGER_PROTOTYPE::is_trimesh
virtual bool is_trimesh()=0
determines if this manager consist on only triangles, which special case will be optimized