sofa icon indicating copy to clipboard operation
sofa copied to clipboard

[Collision.Detection] Give current intersection methods as parameter to intersection functions

Open fredroy opened this issue 2 years ago • 3 comments

The design of Intersection/Intersector is really "special" in the sense that:

  • Intersection class is the BaseObject in the graph doing stuff
  • Intersector is container of functions for canIntersect/intersect method between different primitives.

And it was made such as one could add more intersect() method for new primitives for an existing "Intersection", e.g MinProximityIntersection and MeshMinProximityIntersection, which add triangles, etc methods to MinProximityIntersection. Note that even if it is called "Intersection" it is not a "Intersection" 🤪 There is kind of mechanism with a IntersectorCreator/IntersectorFactory which does the "plugin" automatically. The problem is that the intersector gets a pointer to its intersection at the load-time (when the dll is loaded). The intersector needs the intersection to get alarm/contact distance (defined for all Intersection) or custom parameters (useSurfaceNormal for MinProximityIntersection)

Consequence: if there are multiple simulation (in multiple thread) in the same time, a different thread will get a pointer to an other Intersection while doing its intersect code.

In the end, this PR modifies all the intersect/canIntersect functions to get the intersection method (as if they were static functions in reality) and avoid race conditions. The pipeline needs also to be modified.

[The first version of this branch was using a IntersectionParameters storing alarm, contact distance and given as const ref, but it could not handle custom parameters]

Still need to be done:

  • compat/warnings, etc
  • all broad/narrow phases to be modified

By submitting this pull request, I acknowledge that
I have read, understand, and agree SOFA Developer Certificate of Origin (DCO).


Reviewers will merge this pull-request only if

  • it builds with SUCCESS for all platforms on the CI.
  • it does not generate new warnings.
  • it does not generate new unit test failures.
  • it does not generate new scene test failures.
  • it does not break API compatibility.
  • it is more than 1 week old (or has fast-merge label).

fredroy avatar Mar 12 '24 14:03 fredroy

[ci-build][with-all-tests]

fredroy avatar Mar 15 '24 08:03 fredroy

[ci-build][with-all-tests]

fredroy avatar Mar 19 '24 04:03 fredroy

[ci-build][with-all-tests][force-full-build]

fredroy avatar Mar 20 '24 02:03 fredroy