38 #ifndef FCL_BROAD_PHASE_DYNAMIC_AABB_TREE_ARRAY_INL_H 39 #define FCL_BROAD_PHASE_DYNAMIC_AABB_TREE_ARRAY_INL_H 41 #include "fcl/broadphase/broadphase_dynamic_AABB_tree_array.h" 44 #include "fcl/geometry/octree/octree.h" 52 class DynamicAABBTreeCollisionManager_Array<double>;
57 namespace dynamic_AABB_tree_array
64 bool collisionRecurse_(
65 typename DynamicAABBTreeCollisionManager_Array<S>::DynamicAABBNode* nodes1,
67 const OcTree<S>* tree2,
68 const typename OcTree<S>::OcTreeNode* root2,
69 const AABB<S>& root2_bv,
70 const Transform3<S>& tf2,
72 CollisionCallBack<S> callback)
74 typename DynamicAABBTreeCollisionManager_Array<S>::DynamicAABBNode* root1 = nodes1 + root1_id;
79 CollisionObject<S>* obj1 =
static_cast<CollisionObject<S>*
>(root1->data);
84 convertBV(root1->bv, Transform3<S>::Identity(), obb1);
87 if(obb1.overlap(obb2))
89 Box<S>* box =
new Box<S>();
91 constructBox(root2_bv, tf2, *box, box_tf);
93 box->cost_density = tree2->getDefaultOccupancy();
95 CollisionObject<S> obj2(std::shared_ptr<CollisionGeometry<S>>(box), box_tf);
96 return callback(obj1, &obj2, cdata);
102 if(collisionRecurse_<S>(nodes1, root1->children[0], tree2,
nullptr, root2_bv, tf2, cdata, callback))
104 if(collisionRecurse_<S>(nodes1, root1->children[1], tree2,
nullptr, root2_bv, tf2, cdata, callback))
110 else if(root1->isLeaf() && !tree2->nodeHasChildren(root2))
112 CollisionObject<S>* obj1 =
static_cast<CollisionObject<S>*
>(root1->data);
113 if(!tree2->isNodeFree(root2) && !obj1->isFree())
116 convertBV(root1->bv, Transform3<S>::Identity(), obb1);
119 if(obb1.overlap(obb2))
121 Box<S>* box =
new Box<S>();
122 Transform3<S> box_tf;
123 constructBox(root2_bv, tf2, *box, box_tf);
125 box->cost_density = root2->getOccupancy();
126 box->threshold_occupied = tree2->getOccupancyThres();
128 CollisionObject<S> obj2(std::shared_ptr<CollisionGeometry<S>>(box), box_tf);
129 return callback(obj1, &obj2, cdata);
137 convertBV(root1->bv, Transform3<S>::Identity(), obb1);
140 if(tree2->isNodeFree(root2) || !obb1.overlap(obb2))
return false;
142 if(!tree2->nodeHasChildren(root2) || (!root1->isLeaf() && (root1->bv.size() > root2_bv.size())))
144 if(collisionRecurse_(nodes1, root1->children[0], tree2, root2, root2_bv, tf2, cdata, callback))
146 if(collisionRecurse_(nodes1, root1->children[1], tree2, root2, root2_bv, tf2, cdata, callback))
151 for(
unsigned int i = 0; i < 8; ++i)
153 if(tree2->nodeChildExists(root2, i))
155 const typename OcTree<S>::OcTreeNode* child = tree2->getNodeChild(root2, i);
157 computeChildBV(root2_bv, i, child_bv);
159 if(collisionRecurse_(nodes1, root1_id, tree2, child, child_bv, tf2, cdata, callback))
165 computeChildBV(root2_bv, i, child_bv);
166 if(collisionRecurse_<S>(nodes1, root1_id, tree2,
nullptr, child_bv, tf2, cdata, callback))
176 template <
typename S,
typename Derived>
177 bool collisionRecurse_(
178 typename DynamicAABBTreeCollisionManager_Array<S>::DynamicAABBNode* nodes1,
180 const OcTree<S>* tree2,
181 const typename OcTree<S>::OcTreeNode* root2,
182 const AABB<S>& root2_bv,
183 const Eigen::MatrixBase<Derived>& translation2,
185 CollisionCallBack<S> callback)
187 typename DynamicAABBTreeCollisionManager_Array<S>::DynamicAABBNode* root1 = nodes1 + root1_id;
192 CollisionObject<S>* obj1 =
static_cast<CollisionObject<S>*
>(root1->data);
196 const AABB<S>& root_bv_t =
translate(root2_bv, translation2);
197 if(root1->bv.overlap(root_bv_t))
199 Box<S>* box =
new Box<S>();
200 Transform3<S> box_tf;
201 Transform3<S> tf2 = Transform3<S>::Identity();
202 tf2.translation() = translation2;
203 constructBox(root2_bv, tf2, *box, box_tf);
205 box->cost_density = tree2->getDefaultOccupancy();
207 CollisionObject<S> obj2(std::shared_ptr<CollisionGeometry<S>>(box), box_tf);
208 return callback(obj1, &obj2, cdata);
214 if(collisionRecurse_<S>(nodes1, root1->children[0], tree2,
nullptr, root2_bv, translation2, cdata, callback))
216 if(collisionRecurse_<S>(nodes1, root1->children[1], tree2,
nullptr, root2_bv, translation2, cdata, callback))
222 else if(root1->isLeaf() && !tree2->nodeHasChildren(root2))
224 CollisionObject<S>* obj1 =
static_cast<CollisionObject<S>*
>(root1->data);
225 if(!tree2->isNodeFree(root2) && !obj1->isFree())
227 const AABB<S>& root_bv_t =
translate(root2_bv, translation2);
228 if(root1->bv.overlap(root_bv_t))
230 Box<S>* box =
new Box<S>();
231 Transform3<S> box_tf;
232 Transform3<S> tf2 = Transform3<S>::Identity();
233 tf2.translation() = translation2;
234 constructBox(root2_bv, tf2, *box, box_tf);
236 box->cost_density = root2->getOccupancy();
237 box->threshold_occupied = tree2->getOccupancyThres();
239 CollisionObject<S> obj2(std::shared_ptr<CollisionGeometry<S>>(box), box_tf);
240 return callback(obj1, &obj2, cdata);
247 const AABB<S>& root_bv_t =
translate(root2_bv, translation2);
248 if(tree2->isNodeFree(root2) || !root1->bv.overlap(root_bv_t))
return false;
250 if(!tree2->nodeHasChildren(root2) || (!root1->isLeaf() && (root1->bv.size() > root2_bv.size())))
252 if(collisionRecurse_(nodes1, root1->children[0], tree2, root2, root2_bv, translation2, cdata, callback))
254 if(collisionRecurse_(nodes1, root1->children[1], tree2, root2, root2_bv, translation2, cdata, callback))
259 for(
unsigned int i = 0; i < 8; ++i)
261 if(tree2->nodeChildExists(root2, i))
263 const typename OcTree<S>::OcTreeNode* child = tree2->getNodeChild(root2, i);
265 computeChildBV(root2_bv, i, child_bv);
267 if(collisionRecurse_(nodes1, root1_id, tree2, child, child_bv, translation2, cdata, callback))
273 computeChildBV(root2_bv, i, child_bv);
274 if(collisionRecurse_<S>(nodes1, root1_id, tree2,
nullptr, child_bv, translation2, cdata, callback))
284 template <
typename S>
285 bool distanceRecurse_(
typename DynamicAABBTreeCollisionManager_Array<S>::DynamicAABBNode* nodes1,
size_t root1_id,
const OcTree<S>* tree2,
const typename OcTree<S>::OcTreeNode* root2,
const AABB<S>& root2_bv,
const Transform3<S>& tf2,
void* cdata, DistanceCallBack<S> callback, S& min_dist)
287 typename DynamicAABBTreeCollisionManager_Array<S>::DynamicAABBNode* root1 = nodes1 + root1_id;
288 if(root1->isLeaf() && !tree2->nodeHasChildren(root2))
290 if(tree2->isNodeOccupied(root2))
292 Box<S>* box =
new Box<S>();
293 Transform3<S> box_tf;
294 constructBox(root2_bv, tf2, *box, box_tf);
295 CollisionObject<S> obj(std::shared_ptr<CollisionGeometry<S>>(box), box_tf);
296 return callback(
static_cast<CollisionObject<S>*
>(root1->data), &obj, cdata, min_dist);
301 if(!tree2->isNodeOccupied(root2))
return false;
303 if(!tree2->nodeHasChildren(root2) || (!root1->isLeaf() && (root1->bv.size() > root2_bv.size())))
308 S d1 = aabb2.distance((nodes1 + root1->children[0])->bv);
309 S d2 = aabb2.distance((nodes1 + root1->children[1])->bv);
315 if(distanceRecurse_(nodes1, root1->children[1], tree2, root2, root2_bv, tf2, cdata, callback, min_dist))
321 if(distanceRecurse_(nodes1, root1->children[0], tree2, root2, root2_bv, tf2, cdata, callback, min_dist))
329 if(distanceRecurse_(nodes1, root1->children[0], tree2, root2, root2_bv, tf2, cdata, callback, min_dist))
335 if(distanceRecurse_(nodes1, root1->children[1], tree2, root2, root2_bv, tf2, cdata, callback, min_dist))
342 for(
unsigned int i = 0; i < 8; ++i)
344 if(tree2->nodeChildExists(root2, i))
346 const typename OcTree<S>::OcTreeNode* child = tree2->getNodeChild(root2, i);
348 computeChildBV(root2_bv, i, child_bv);
352 S d = root1->bv.distance(aabb2);
356 if(distanceRecurse_(nodes1, root1_id, tree2, child, child_bv, tf2, cdata, callback, min_dist))
367 template <
typename S,
typename Derived>
368 bool distanceRecurse_(
369 typename DynamicAABBTreeCollisionManager_Array<S>::DynamicAABBNode* nodes1,
371 const OcTree<S>* tree2,
372 const typename OcTree<S>::OcTreeNode* root2,
373 const AABB<S>& root2_bv,
374 const Eigen::MatrixBase<Derived>& translation2,
376 DistanceCallBack<S> callback,
379 typename DynamicAABBTreeCollisionManager_Array<S>::DynamicAABBNode* root1 = nodes1 + root1_id;
380 if(root1->isLeaf() && !tree2->nodeHasChildren(root2))
382 if(tree2->isNodeOccupied(root2))
384 Box<S>* box =
new Box<S>();
385 Transform3<S> box_tf;
386 Transform3<S> tf2 = Transform3<S>::Identity();
387 tf2.translation() = translation2;
388 constructBox(root2_bv, tf2, *box, box_tf);
389 CollisionObject<S> obj(std::shared_ptr<CollisionGeometry<S>>(box), box_tf);
390 return callback(
static_cast<CollisionObject<S>*
>(root1->data), &obj, cdata, min_dist);
395 if(!tree2->isNodeOccupied(root2))
return false;
397 if(!tree2->nodeHasChildren(root2) || (!root1->isLeaf() && (root1->bv.size() > root2_bv.size())))
399 const AABB<S>& aabb2 =
translate(root2_bv, translation2);
401 S d1 = aabb2.distance((nodes1 + root1->children[0])->bv);
402 S d2 = aabb2.distance((nodes1 + root1->children[1])->bv);
408 if(distanceRecurse_(nodes1, root1->children[1], tree2, root2, root2_bv, translation2, cdata, callback, min_dist))
414 if(distanceRecurse_(nodes1, root1->children[0], tree2, root2, root2_bv, translation2, cdata, callback, min_dist))
422 if(distanceRecurse_(nodes1, root1->children[0], tree2, root2, root2_bv, translation2, cdata, callback, min_dist))
428 if(distanceRecurse_(nodes1, root1->children[1], tree2, root2, root2_bv, translation2, cdata, callback, min_dist))
435 for(
unsigned int i = 0; i < 8; ++i)
437 if(tree2->nodeChildExists(root2, i))
439 const typename OcTree<S>::OcTreeNode* child = tree2->getNodeChild(root2, i);
441 computeChildBV(root2_bv, i, child_bv);
443 const AABB<S>& aabb2 =
translate(child_bv, translation2);
444 S d = root1->bv.distance(aabb2);
448 if(distanceRecurse_(nodes1, root1_id, tree2, child, child_bv, translation2, cdata, callback, min_dist))
462 template <
typename S>
463 bool collisionRecurse(
typename DynamicAABBTreeCollisionManager_Array<S>::DynamicAABBNode* nodes1,
size_t root1_id,
464 typename DynamicAABBTreeCollisionManager_Array<S>::DynamicAABBNode* nodes2,
size_t root2_id,
465 void* cdata, CollisionCallBack<S> callback)
467 typename DynamicAABBTreeCollisionManager_Array<S>::DynamicAABBNode* root1 = nodes1 + root1_id;
468 typename DynamicAABBTreeCollisionManager_Array<S>::DynamicAABBNode* root2 = nodes2 + root2_id;
469 if(root1->isLeaf() && root2->isLeaf())
471 if(!root1->bv.overlap(root2->bv))
return false;
472 return callback(
static_cast<CollisionObject<S>*
>(root1->data), static_cast<CollisionObject<S>*>(root2->data), cdata);
475 if(!root1->bv.overlap(root2->bv))
return false;
477 if(root2->isLeaf() || (!root1->isLeaf() && (root1->bv.size() > root2->bv.size())))
479 if(collisionRecurse(nodes1, root1->children[0], nodes2, root2_id, cdata, callback))
481 if(collisionRecurse(nodes1, root1->children[1], nodes2, root2_id, cdata, callback))
486 if(collisionRecurse(nodes1, root1_id, nodes2, root2->children[0], cdata, callback))
488 if(collisionRecurse(nodes1, root1_id, nodes2, root2->children[1], cdata, callback))
495 template <
typename S>
496 bool collisionRecurse(
typename DynamicAABBTreeCollisionManager_Array<S>::DynamicAABBNode* nodes,
size_t root_id, CollisionObject<S>* query,
void* cdata, CollisionCallBack<S> callback)
498 typename DynamicAABBTreeCollisionManager_Array<S>::DynamicAABBNode* root = nodes + root_id;
501 if(!root->bv.overlap(query->getAABB()))
return false;
502 return callback(
static_cast<CollisionObject<S>*
>(root->data), query, cdata);
505 if(!root->bv.overlap(query->getAABB()))
return false;
507 int select_res = implementation_array::select(query->getAABB(), root->children[0], root->children[1], nodes);
509 if(collisionRecurse(nodes, root->children[select_res], query, cdata, callback))
512 if(collisionRecurse(nodes, root->children[1-select_res], query, cdata, callback))
519 template <
typename S>
520 bool selfCollisionRecurse(
typename DynamicAABBTreeCollisionManager_Array<S>::DynamicAABBNode* nodes,
size_t root_id,
void* cdata, CollisionCallBack<S> callback)
522 typename DynamicAABBTreeCollisionManager_Array<S>::DynamicAABBNode* root = nodes + root_id;
523 if(root->isLeaf())
return false;
525 if(selfCollisionRecurse(nodes, root->children[0], cdata, callback))
528 if(selfCollisionRecurse(nodes, root->children[1], cdata, callback))
531 if(collisionRecurse(nodes, root->children[0], nodes, root->children[1], cdata, callback))
538 template <
typename S>
539 bool distanceRecurse(
typename DynamicAABBTreeCollisionManager_Array<S>::DynamicAABBNode* nodes1,
size_t root1_id,
540 typename DynamicAABBTreeCollisionManager_Array<S>::DynamicAABBNode* nodes2,
size_t root2_id,
541 void* cdata, DistanceCallBack<S> callback, S& min_dist)
543 typename DynamicAABBTreeCollisionManager_Array<S>::DynamicAABBNode* root1 = nodes1 + root1_id;
544 typename DynamicAABBTreeCollisionManager_Array<S>::DynamicAABBNode* root2 = nodes2 + root2_id;
545 if(root1->isLeaf() && root2->isLeaf())
547 CollisionObject<S>* root1_obj =
static_cast<CollisionObject<S>*
>(root1->data);
548 CollisionObject<S>* root2_obj =
static_cast<CollisionObject<S>*
>(root2->data);
549 return callback(root1_obj, root2_obj, cdata, min_dist);
552 if(root2->isLeaf() || (!root1->isLeaf() && (root1->bv.size() > root2->bv.size())))
554 S d1 = root2->bv.distance((nodes1 + root1->children[0])->bv);
555 S d2 = root2->bv.distance((nodes1 + root1->children[1])->bv);
561 if(distanceRecurse(nodes1, root1->children[1], nodes2, root2_id, cdata, callback, min_dist))
567 if(distanceRecurse(nodes1, root1->children[0], nodes2, root2_id, cdata, callback, min_dist))
575 if(distanceRecurse(nodes1, root1->children[0], nodes2, root2_id, cdata, callback, min_dist))
581 if(distanceRecurse(nodes1, root1->children[1], nodes2, root2_id, cdata, callback, min_dist))
588 S d1 = root1->bv.distance((nodes2 + root2->children[0])->bv);
589 S d2 = root1->bv.distance((nodes2 + root2->children[1])->bv);
595 if(distanceRecurse(nodes1, root1_id, nodes2, root2->children[1], cdata, callback, min_dist))
601 if(distanceRecurse(nodes1, root1_id, nodes2, root2->children[0], cdata, callback, min_dist))
609 if(distanceRecurse(nodes1, root1_id, nodes2, root2->children[0], cdata, callback, min_dist))
615 if(distanceRecurse(nodes1, root1_id, nodes2, root2->children[1], cdata, callback, min_dist))
625 template <
typename S>
626 bool distanceRecurse(
typename DynamicAABBTreeCollisionManager_Array<S>::DynamicAABBNode* nodes,
size_t root_id, CollisionObject<S>* query,
void* cdata, DistanceCallBack<S> callback, S& min_dist)
628 typename DynamicAABBTreeCollisionManager_Array<S>::DynamicAABBNode* root = nodes + root_id;
631 CollisionObject<S>* root_obj =
static_cast<CollisionObject<S>*
>(root->data);
632 return callback(root_obj, query, cdata, min_dist);
635 S d1 = query->getAABB().distance((nodes + root->children[0])->bv);
636 S d2 = query->getAABB().distance((nodes + root->children[1])->bv);
642 if(distanceRecurse(nodes, root->children[1], query, cdata, callback, min_dist))
648 if(distanceRecurse(nodes, root->children[0], query, cdata, callback, min_dist))
656 if(distanceRecurse(nodes, root->children[0], query, cdata, callback, min_dist))
662 if(distanceRecurse(nodes, root->children[1], query, cdata, callback, min_dist))
671 template <
typename S>
672 bool selfDistanceRecurse(
typename DynamicAABBTreeCollisionManager_Array<S>::DynamicAABBNode* nodes,
size_t root_id,
void* cdata, DistanceCallBack<S> callback, S& min_dist)
674 typename DynamicAABBTreeCollisionManager_Array<S>::DynamicAABBNode* root = nodes + root_id;
675 if(root->isLeaf())
return false;
677 if(selfDistanceRecurse(nodes, root->children[0], cdata, callback, min_dist))
680 if(selfDistanceRecurse(nodes, root->children[1], cdata, callback, min_dist))
683 if(distanceRecurse(nodes, root->children[0], nodes, root->children[1], cdata, callback, min_dist))
693 template <
typename S>
694 bool collisionRecurse(
typename DynamicAABBTreeCollisionManager_Array<S>::DynamicAABBNode* nodes1,
size_t root1_id,
const OcTree<S>* tree2,
const typename OcTree<S>::OcTreeNode* root2,
const AABB<S>& root2_bv,
const Transform3<S>& tf2,
void* cdata, CollisionCallBack<S> callback)
696 if(tf2.linear().isIdentity())
697 return collisionRecurse_(nodes1, root1_id, tree2, root2, root2_bv, tf2.translation(), cdata, callback);
699 return collisionRecurse_(nodes1, root1_id, tree2, root2, root2_bv, tf2, cdata, callback);
703 template <
typename S>
704 bool distanceRecurse(
typename DynamicAABBTreeCollisionManager_Array<S>::DynamicAABBNode* nodes1,
size_t root1_id,
const OcTree<S>* tree2,
const typename OcTree<S>::OcTreeNode* root2,
const AABB<S>& root2_bv,
const Transform3<S>& tf2,
void* cdata, DistanceCallBack<S> callback, S& min_dist)
706 if(tf2.linear().isIdentity())
707 return distanceRecurse_(nodes1, root1_id, tree2, root2, root2_bv, tf2.translation(), cdata, callback, min_dist);
709 return distanceRecurse_(nodes1, root1_id, tree2, root2, root2_bv, tf2, cdata, callback, min_dist);
719 template <
typename S>
720 DynamicAABBTreeCollisionManager_Array<S>::DynamicAABBTreeCollisionManager_Array()
721 : tree_topdown_balance_threshold(dtree.bu_threshold),
722 tree_topdown_level(dtree.topdown_level)
724 max_tree_nonbalanced_level = 10;
725 tree_incremental_balance_pass = 10;
726 tree_topdown_balance_threshold = 2;
727 tree_topdown_level = 0;
732 octree_as_geometry_collide =
true;
733 octree_as_geometry_distance =
false;
737 template <
typename S>
741 if(other_objs.empty())
return;
750 table.rehash(other_objs.size());
751 for(
size_t i = 0,
size = other_objs.size(); i <
size; ++i)
753 leaves[i].bv = other_objs[i]->getAABB();
754 leaves[i].parent = dtree.NULL_NODE;
755 leaves[i].children[1] = dtree.NULL_NODE;
756 leaves[i].data = other_objs[i];
757 table[other_objs[i]] = i;
760 int n_leaves = other_objs.size();
762 dtree.init(leaves, n_leaves, tree_init_level);
769 template <
typename S>
772 size_t node = dtree.insert(obj->
getAABB(), obj);
777 template <
typename S>
780 size_t node = table[obj];
786 template <
typename S>
791 int num = dtree.size();
798 int height = dtree.getMaxHeight();
801 if(height - std::log((S)num) / std::log(2.0) < max_tree_nonbalanced_level)
802 dtree.balanceIncremental(tree_incremental_balance_pass);
804 dtree.balanceTopdown();
811 template <
typename S>
814 for(
auto it = table.cbegin(), end = table.cend(); it != end; ++it)
817 size_t node = it->second;
818 dtree.getNodes()[node].bv = obj->
getAABB();
828 template <
typename S>
831 const auto it = table.find(updated_obj);
832 if(it != table.end())
834 size_t node = it->second;
835 if(!dtree.getNodes()[node].bv.equal(updated_obj->
getAABB()))
836 dtree.update(node, updated_obj->
getAABB());
842 template <
typename S>
845 update_(updated_obj);
850 template <
typename S>
853 for(
size_t i = 0,
size = updated_objs.size(); i <
size; ++i)
854 update_(updated_objs[i]);
859 template <
typename S>
867 template <
typename S>
870 objs.resize(this->
size());
871 std::transform(table.begin(), table.end(), objs.begin(), std::bind(&DynamicAABBTable::value_type::first, std::placeholders::_1));
875 template <
typename S>
878 if(
size() == 0)
return;
884 if(!octree_as_geometry_collide)
886 const OcTree<S>* octree =
static_cast<const OcTree<S>*
>(obj->
collisionGeometry().get());
887 detail::dynamic_AABB_tree_array::collisionRecurse(dtree.getNodes(), dtree.getRoot(), octree, octree->getRoot(), octree->getRootBV(), obj->
getTransform(), cdata, callback);
890 detail::dynamic_AABB_tree_array::collisionRecurse(dtree.getNodes(), dtree.getRoot(), obj, cdata, callback);
895 detail::dynamic_AABB_tree_array::collisionRecurse(dtree.getNodes(), dtree.getRoot(), obj, cdata, callback);
900 template <
typename S>
903 if(
size() == 0)
return;
904 S min_dist = std::numeric_limits<S>::max();
910 if(!octree_as_geometry_distance)
912 const OcTree<S>* octree =
static_cast<const OcTree<S>*
>(obj->
collisionGeometry().get());
913 detail::dynamic_AABB_tree_array::distanceRecurse(dtree.getNodes(), dtree.getRoot(), octree, octree->getRoot(), octree->getRootBV(), obj->
getTransform(), cdata, callback, min_dist);
916 detail::dynamic_AABB_tree_array::distanceRecurse(dtree.getNodes(), dtree.getRoot(), obj, cdata, callback, min_dist);
921 detail::dynamic_AABB_tree_array::distanceRecurse(dtree.getNodes(), dtree.getRoot(), obj, cdata, callback, min_dist);
926 template <
typename S>
929 if(
size() == 0)
return;
930 detail::dynamic_AABB_tree_array::selfCollisionRecurse(dtree.getNodes(), dtree.getRoot(), cdata, callback);
934 template <
typename S>
937 if(
size() == 0)
return;
938 S min_dist = std::numeric_limits<S>::max();
939 detail::dynamic_AABB_tree_array::selfDistanceRecurse(dtree.getNodes(), dtree.getRoot(), cdata, callback, min_dist);
943 template <
typename S>
947 if((
size() == 0) || (other_manager->
size() == 0))
return;
948 detail::dynamic_AABB_tree_array::collisionRecurse(dtree.getNodes(), dtree.getRoot(), other_manager->dtree.getNodes(), other_manager->dtree.getRoot(), cdata, callback);
952 template <
typename S>
956 if((
size() == 0) || (other_manager->
size() == 0))
return;
957 S min_dist = std::numeric_limits<S>::max();
958 detail::dynamic_AABB_tree_array::distanceRecurse(dtree.getNodes(), dtree.getRoot(), other_manager->dtree.getNodes(), other_manager->dtree.getRoot(), cdata, callback, min_dist);
962 template <
typename S>
965 return dtree.empty();
969 template <
typename S>
976 template <
typename S>
Class for hierarchy tree structure.
Definition: hierarchy_tree_array.h:61
void getObjects(std::vector< CollisionObject< S > * > &objs) const
return the objects managed by the manager
Definition: broadphase_dynamic_AABB_tree_array-inl.h:868
void convertBV(const BV1 &bv1, const Transform3< typename BV1::S > &tf1, BV2 &bv2)
Convert a bounding volume of type BV1 in configuration tf1 to bounding volume of type BV2 in identity...
Definition: utility-inl.h:934
Main namespace.
Definition: broadphase_bruteforce-inl.h:45
void registerObject(CollisionObject< S > *obj)
add one object to the manager
Definition: broadphase_dynamic_AABB_tree_array-inl.h:770
void clear()
clear the manager
Definition: broadphase_dynamic_AABB_tree_array-inl.h:860
AABB< S > translate(const AABB< S > &aabb, const Eigen::MatrixBase< Derived > &t)
translate the center of AABB by t
Definition: AABB-inl.h:345
size_t size() const
the number of objects managed by the manager
Definition: broadphase_dynamic_AABB_tree-inl.h:966
virtual void registerObjects(const std::vector< CollisionObject< S > * > &other_objs)
add objects to the manager
Definition: broadphase_collision_manager-inl.h:66
bool(*)(CollisionObject< S > *o1, CollisionObject< S > *o2, void *cdata) CollisionCallBack
Callback for collision between two objects. Return value is whether can stop now. ...
Definition: broadphase_collision_manager.h:53
bool(*)(CollisionObject< S > *o1, CollisionObject< S > *o2, void *cdata, S &dist) DistanceCallBack
Callback for distance between two objects, Return value is whether can stop now, also return the mini...
Definition: broadphase_collision_manager.h:60
void unregisterObject(CollisionObject< S > *obj)
remove one object from the manager
Definition: broadphase_dynamic_AABB_tree_array-inl.h:778
Definition: broadphase_dynamic_AABB_tree_array.h:55
void distance(CollisionObject< S > *obj, void *cdata, DistanceCallBack< S > callback) const
perform distance computation between one object and all the objects belonging to the manager ...
Definition: broadphase_dynamic_AABB_tree_array-inl.h:901
size_t size() const
the number of objects managed by the manager
Definition: broadphase_dynamic_AABB_tree_array-inl.h:970
const Transform3< S > & getTransform() const
get object's transform
Definition: collision_object-inl.h:170
const std::shared_ptr< const CollisionGeometry< S > > & collisionGeometry() const
get geometry from the object instance
Definition: collision_object-inl.h:243
const AABB< S > & getAABB() const
get the AABB in world space
Definition: collision_object-inl.h:111
Definition: node_base_array.h:53
the object for collision or distance computation, contains the geometry and the transform information...
Definition: collision_object.h:51
Base class for broad phase collision. It helps to accelerate the collision/distance between N objects...
Definition: broadphase_collision_manager.h:66
void collide(CollisionObject< S > *obj, void *cdata, CollisionCallBack< S > callback) const
perform collision test between one object and all the objects belonging to the manager ...
Definition: broadphase_dynamic_AABB_tree_array-inl.h:876
void registerObjects(const std::vector< CollisionObject< S > * > &other_objs)
add objects to the manager
Definition: broadphase_dynamic_AABB_tree_array-inl.h:738
bool empty() const
whether the manager is empty
Definition: broadphase_dynamic_AABB_tree_array-inl.h:963
void update()
update the condition of manager
Definition: broadphase_dynamic_AABB_tree_array-inl.h:812
void setup()
initialize the manager, related with the specific type of manager
Definition: broadphase_dynamic_AABB_tree-inl.h:783
void setup()
initialize the manager, related with the specific type of manager
Definition: broadphase_dynamic_AABB_tree_array-inl.h:787