Skip to content

Commit 780152e

Browse files
Check the metric extend of the occupied part of the octomap during broadphase
1 parent f4018b4 commit 780152e

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

include/fcl/broadphase/broadphase_dynamic_AABB_tree-inl.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -904,6 +904,9 @@ void DynamicAABBTreeCollisionManager<S>::collide(CollisionObject<S>* obj, void*
904904
if(!octree_as_geometry_collide)
905905
{
906906
const OcTree<S>* octree = static_cast<const OcTree<S>*>(obj->collisionGeometry().get());
907+
908+
if (!dtree.getRoot()->bv.overlap(octree->getOccupiedMetricBV())) return;
909+
907910
detail::dynamic_AABB_tree::collisionRecurse(dtree.getRoot(), octree, octree->getRoot(), octree->getRootBV(), obj->getTransform(), cdata, callback);
908911
}
909912
else

include/fcl/geometry/octree/octree-inl.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,15 @@ void OcTree<S>::computeLocalAABB()
9090
this->aabb_radius = (this->aabb_local.min_ - this->aabb_center).norm();
9191
}
9292

93+
template <typename S>
94+
AABB<S> OcTree<S>::getOccupiedMetricBV() const
95+
{
96+
S x_min, y_min, z_min, x_max, y_max, z_max;
97+
tree->getMetricMin(x_min, y_min, z_min);
98+
tree->getMetricMax(x_max, y_max, z_max);
99+
return AABB<S>(Vector3<S>(x_min, y_min, z_min), Vector3<S>(x_max, y_max, z_max));
100+
}
101+
93102
//==============================================================================
94103
template <typename S>
95104
AABB<S> OcTree<S>::getRootBV() const

include/fcl/geometry/octree/octree.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,13 @@ class FCL_EXPORT OcTree : public CollisionGeometry<S>
8484
/// @brief compute the AABB<S> for the octree in its local coordinate system
8585
void computeLocalAABB();
8686

87+
/// @brief get the metric extend of the occupied part of the tree
88+
///
89+
/// note that getMetricMin/getMetricMax can only cache the result of this
90+
/// expensive operation if called non-const. Ie make sure to call either one
91+
/// of them once after each update to the octomap!
92+
AABB<S> getOccupiedMetricBV() const;
93+
8794
/// @brief get the bounding volume for the root
8895
AABB<S> getRootBV() const;
8996

0 commit comments

Comments
 (0)