bepu / bepuphysics2

Pure C# 3D real time physics simulation library, now with a higher version number.
Apache License 2.0
2.4k stars 274 forks source link

MeshReduction tends to overaggressively filter by query box #149

Closed RossNordby closed 3 years ago

RossNordby commented 3 years ago

The bounding box of the query shape used to collect triangles to test in the mesh is also used to prune out speculative contacts that are too far away to be relevant (by bounds/velocity heuristics). Since contact reduction relies on queried triangles to correct/remove contacts, and because contacts outside the bounds may not be reduced due to the lack of queried triangles, this filtering process helps avoid ghost collisions.

However, it can also cause valuable speculative contacts to be removed. This is most pressing during resting contact under load. There is no significant velocity to expand the bounding box when resting, so the bounding box will be tight. It is possible for contacts to be created with near zero depth right at the border of the query bounds. A numerical breeze could result in a previously loaded contact being lost. Under load, especially dynamically changing load, this can cause jank.

The filtering process cannot be adjusted in isolation; adding an epsilon to it would lead to the aforementioned ghost collisions. The query box can, however, be epsilon expanded. This should have no significant impact on performance, but it does require a reasonable selection of scaled epsilon.

RossNordby commented 3 years ago

As of c91287b565c5c1e025b75d5be43126b1c4caa5b0, the epsilon is implemented.

See #155 for possible future improvements.

RossNordby commented 3 years ago

And now the entire filter mechanism is gone! 8a3461db2b1650f2a37d4b80f2b2d0566fcd82f3