flexible-collision-library / fcl

Flexible Collision Library
https://flexible-collision-library.github.io/
Other
1.39k stars 417 forks source link

Problem with deformable mesh and BroadPhaseCollisionManager #577

Closed mahaarbo closed 1 year ago

mahaarbo commented 2 years ago

Hi!

I'm testing out collision checking for a deformable mesh, and have run into a strange problem. If I define two collision objects, one is a box as an fcl::Box at a fixed location, and the other is a BVHModel<OBBRSSd> representing a box that stretches using replaceSubModel to update the location of the vertices, then I can test for collisions correctly using the narrowphase collide function. If I try to use a BroadPhaseCollisionManager where I have registered the mesh collision object however, it does not report the collisions correctly.

Is this a known problem?

Code used to test this: broadphase_mesh_problem.cpp

Compiled with fcl version 0.7.0.

mahaarbo commented 1 year ago

After some testing, the problem comes from replaceSubModel not causing the collision geometry, the collision object or the broad phase collision manager to recompute the AABBs involved. A workaround is to call computeLocalAABB on the collision geometry, and computeAABB on the collision object, and then update on the relevant broadphase manager after replacing the submodel.

This is an edge use-case that incurs extra computations for the most common use-cases if added, so I'll just close this issue.