Skip to content

Commit f289d25

Browse files
Check the metric extend of the occupied part of the octomap during broadphase
1 parent 3c1dcfe commit f289d25

File tree

3 files changed

+22
-5
lines changed

3 files changed

+22
-5
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: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,16 +88,23 @@ void OcTree<S>::computeLocalAABB()
8888
this->aabb_radius = (this->aabb_local.min_ - this->aabb_center).norm();
8989
}
9090

91+
template <typename S>
92+
AABB<S> OcTree<S>::getOccupiedMetricBV() const
93+
{
94+
S x_min, y_min, z_min, x_max, y_max, z_max;
95+
tree->getMetricMin(x_min, y_min, z_min);
96+
tree->getMetricMax(x_max, y_max, z_max);
97+
return AABB<S>(Vector3<S>(x_min, y_min, z_min), Vector3<S>(x_max, y_max, z_max));
98+
}
99+
91100
//==============================================================================
92101
template <typename S>
93102
AABB<S> OcTree<S>::getRootBV() const
94103
{
95-
S x_min, y_min, z_min, x_max, y_max, z_max;
96-
tree->getMetricMin(x_min, y_min, z_min);
97-
tree->getMetricMax(x_max, y_max, z_max);
104+
S delta = (1 << tree->getTreeDepth()) * tree->getResolution() / 2;
98105

99-
// std::cout << "octree dimensions " << x_min << " " << x_max << " y: " << y_min << " " << y_max << " z: " << z_min << " " << z_max << std::endl;
100-
return AABB<S>(Vector3<S>(x_min, y_min, z_min), Vector3<S>(x_max, y_max, z_max));
106+
// std::cout << "octree size " << delta << std::endl;
107+
return AABB<S>(Vector3<S>(-delta, -delta, -delta), Vector3<S>(delta, delta, delta));
101108
}
102109

103110
//==============================================================================

include/fcl/geometry/octree/octree.h

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

81+
/// @brief get the metric extend of the occupied part of the tree
82+
///
83+
/// note that getMetricMin/getMetricMax can only cache the result of this
84+
/// expensive operation if called non-const. Ie make sure to call either one
85+
/// of them once after each update to the octomap!
86+
AABB<S> getOccupiedMetricBV() const;
87+
8188
/// @brief get the bounding volume for the root
8289
AABB<S> getRootBV() const;
8390

0 commit comments

Comments
 (0)