Skip to content

Commit

Permalink
Merge pull request #509 from lmontaut/topic/devel/broadphase-clear-co…
Browse files Browse the repository at this point in the history
…llision-data

Broadphase clear collision data
  • Loading branch information
jcarpent authored Jan 4, 2024
2 parents 948a826 + 38b5d56 commit 6d776ba
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
20 changes: 20 additions & 0 deletions include/hpp/fcl/broadphase/default_broadphase_callbacks.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -183,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;
Expand All @@ -193,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;
Expand Down
6 changes: 4 additions & 2 deletions python/broadphase/broadphase.cc
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,15 @@ void exposeBroadPhase() {
.def(dv::init<CollisionData>())
.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>("DistanceData", bp::no_init)
.def(dv::init<DistanceData>())
.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();

Expand Down

0 comments on commit 6d776ba

Please sign in to comment.