I would like to have a collision detection module in my tracking pipeline, detecting when two different meshes collide/interpenetrate or if there is a self-penetration of an articulated mesh. Based on the depth of the penetration there should be a penalization that combats this phenomenon. I should get a list of the colliding faces/vertices in order to do so.
After examining several options, I decided to start working with CGAL.
In this link there is an interesting answer pointing to some examples. (this and this). The examples use AABBs (Axis-Aligned Bounding Boxes), which is the proposed way for non-rigid meshes, since a frequent update of them is needed. The examples are clear for the self-intersection case, but the following are not very clear to me:
- Apart from creating a B.Box for each triangles, I guess that there is no tree structure created under the hood to speed up the search process. Is it so? If yes, any hint to do so?
- In case of 2 separate meshes, I guess it's not nice to merge all triangles/boxes in one vector and follow the examples (though it is mentioned here as a solution, it doesn't sound so elegant). Any hint for a nice practice? Should one mix these examples, by creating trees of triangles/boxes? Although for the AABB tree it is mentioned that:
Note that this component is not suited to the problem of finding all intersecting pairs of objects. We refer to the component Intersecting Sequences of dD Iso-oriented Boxes which can find all intersecting pairs of iso-oriented boxes.