Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Broadphase clear collision data #509

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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