From 6ba66b96ef4c12fb4bbd07cbf8294745d578dbc3 Mon Sep 17 00:00:00 2001 From: Louis Montaut Date: Thu, 4 Jan 2024 15:03:42 +0100 Subject: [PATCH 1/3] [Broadphase] add `clear` method to collision data --- .../fcl/broadphase/default_broadphase_callbacks.h | 12 ++++++++++++ python/broadphase/broadphase.cc | 6 ++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/include/hpp/fcl/broadphase/default_broadphase_callbacks.h b/include/hpp/fcl/broadphase/default_broadphase_callbacks.h index c34a871ec..0d9ff2c31 100644 --- a/include/hpp/fcl/broadphase/default_broadphase_callbacks.h +++ b/include/hpp/fcl/broadphase/default_broadphase_callbacks.h @@ -64,6 +64,12 @@ struct CollisionData { /// @brief Whether the collision iteration can stop bool done; + + /// @brief Clears the CollisionData + void clear() { + result.clear(); + done = false; + } }; /// @brief Distance data stores the distance request and the result given by @@ -79,6 +85,12 @@ struct DistanceData { /// @brief Whether the distance iteration can stop bool done; + + /// @brief Clears the DistanceData + void clear() { + result.clear(); + done = false; + } }; /// @brief Provides a simple callback for the collision query in the diff --git a/python/broadphase/broadphase.cc b/python/broadphase/broadphase.cc index 8f4dac9bf..49953bcb0 100644 --- a/python/broadphase/broadphase.cc +++ b/python/broadphase/broadphase.cc @@ -90,13 +90,15 @@ void exposeBroadPhase() { .def(dv::init()) .DEF_RW_CLASS_ATTRIB(CollisionData, request) .DEF_RW_CLASS_ATTRIB(CollisionData, result) - .DEF_RW_CLASS_ATTRIB(CollisionData, done); + .DEF_RW_CLASS_ATTRIB(CollisionData, done) + .DEF_CLASS_FUNC(CollisionData, clear); bp::class_("DistanceData", bp::no_init) .def(dv::init()) .DEF_RW_CLASS_ATTRIB(DistanceData, request) .DEF_RW_CLASS_ATTRIB(DistanceData, result) - .DEF_RW_CLASS_ATTRIB(DistanceData, done); + .DEF_RW_CLASS_ATTRIB(DistanceData, done) + .DEF_CLASS_FUNC(DistanceData, clear); BroadPhaseCollisionManagerWrapper::expose(); From 46f204ffac187155b4ec707f0e226faac0383a02 Mon Sep 17 00:00:00 2001 From: Louis Montaut Date: Thu, 4 Jan 2024 15:26:58 +0100 Subject: [PATCH 2/3] [broadphase] clear data in init of default callback --- include/hpp/fcl/broadphase/default_broadphase_callbacks.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/hpp/fcl/broadphase/default_broadphase_callbacks.h b/include/hpp/fcl/broadphase/default_broadphase_callbacks.h index 0d9ff2c31..bf240fded 100644 --- a/include/hpp/fcl/broadphase/default_broadphase_callbacks.h +++ b/include/hpp/fcl/broadphase/default_broadphase_callbacks.h @@ -195,6 +195,10 @@ bool defaultDistanceFunction(CollisionObject* o1, CollisionObject* o2, /// @brief Default collision callback to check collision between collision /// objects. struct HPP_FCL_DLLAPI CollisionCallBackDefault : CollisionCallBackBase { + /// @brief Initialize the callback. + /// Clears the collision result and sets the done boolean to false. + void init() { data.clear(); } + bool collide(CollisionObject* o1, CollisionObject* o2); CollisionData data; @@ -205,6 +209,10 @@ struct HPP_FCL_DLLAPI CollisionCallBackDefault : CollisionCallBackBase { /// @brief Default distance callback to check collision between collision /// objects. struct HPP_FCL_DLLAPI DistanceCallBackDefault : DistanceCallBackBase { + /// @brief Initialize the callback. + /// Clears the distance result and sets the done boolean to false. + void init() { data.clear(); } + bool distance(CollisionObject* o1, CollisionObject* o2, FCL_REAL& dist); DistanceData data; From 38b5d564798cb81393914fcbea4e2af8f4dc456d Mon Sep 17 00:00:00 2001 From: Justin Carpentier Date: Thu, 4 Jan 2024 17:06:56 +0100 Subject: [PATCH 3/3] changelog: update --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 91adae9bc..0e64e814b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### Fixed - CachedMeshLoader checks file last modification time. +- Fix call to clear methods for {Collision,Distance}Data inside init function ([#509](https://github.com/humanoid-path-planner/hpp-fcl/pull/509)) ## [2.4.0] - 2023-11-27