rapier icon indicating copy to clipboard operation
rapier copied to clipboard

Internal edges in tri-mesh generate strange contacts

Open jeffparsons opened this issue 4 years ago • 1 comments

This is a follow-up to https://github.com/dimforge/bevy_rapier/pull/51

It appears that internal edges in tri-mesh colliders can sometimes generate contacts that don't faithfully reflect the geometry of the mesh. Quoting @sebcrozet from the linked PR:

The problem you are experiencing here is likely caused by the common physics-engine problem called the "internal edges problem". Basically, your ball hits the edges between two triangles, and this edge contact ends up having a normal that is not parallel to the adjacent triangles faces' normals. So this deviates the ball from its trajectory since it is as if the floor isn't actually flat.

This problem can be demonstrated by tweaking an example from the bevy_rapier repository: https://github.com/dimforge/bevy_rapier/blob/master/bevy_rapier3d/examples/static_trimesh3.rs

Here is a video of the intended behaviour:

https://user-images.githubusercontent.com/321861/105569292-c107f800-5d94-11eb-92da-496ec31f5aa1.mp4

If you reduce the number of ramp segments to 3, you'll see this instead:

https://user-images.githubusercontent.com/321861/105569487-01b44100-5d96-11eb-8996-ed0b38032ee1.mp4

Each of the balls appears to get "stuck" on an internal edge of the ramp mesh and roll along it instead of straight down the ramp, even though each pair of triangles that makes each segment is a "perfectly" (as much as they can be with floats) flat plane.

jeffparsons avatar Jan 24 '21 21:01 jeffparsons

@sebcrozet I had a go at creating a much more minimal reproduction for this issue (two triangles, one ball) using rapier_testbed3d, but I couldn't get it to render my tri-mesh. Is that expected, or did I probably do something wrong?

I'd be happy to port it to bevy_rapier instead if you don't mind that; I just figured it might be nice to avoid the bevy dependency when talking about the issue in this repo.

jeffparsons avatar Jan 24 '21 22:01 jeffparsons

Fix in Rapier 0.16.

sebcrozet avatar Jan 01 '23 17:01 sebcrozet