dimforge / rapier

2D and 3D physics engines focused on performance.
https://rapier.rs
Apache License 2.0
3.96k stars 249 forks source link

General stability improvements #625

Closed sebcrozet closed 5 months ago

sebcrozet commented 5 months ago

This PR implements several automatic stability fixes (that you will get automatically just by updating the rapier version), as well as some optional ones. Here is a short summary:

This PR also adds a rust port of several test cases from the Solver2d playground. See the 2D examples files with a name starting with s2d.

(Some of the videos below are low-resolution to stick with github’s 10MB video limit.)

Stacking improvements

General stacking improvements will be obtained automatically by updating to the newest version of rapier.

https://github.com/dimforge/rapier/assets/1734958/945073d9-1a94-4908-abc2-779a8db7127e

Popping effect

The following video shows improvements in handling the "pop" effect due to penetrations. Here, objects were initialized in a penetration state.

https://github.com/dimforge/rapier/assets/1734958/9161862e-3be1-4c73-af68-84a15e744460

Dynamic triangle meshes

The following video shows improvements on handling triangle meshes attached to dynamic rigid-bodies. There is still some research needed before making them completely stable, but this is a step in the right direction.

All the meshes here were initialized with the TriMeshFlags::FIX_INTERNAL_EDGES flag, and are given a contact_skin equal to 0.1.

https://github.com/dimforge/rapier/assets/1734958/e3ab3db7-c77c-43b8-b660-63602ab7448d

Contact skin

The following shows the difference between collisions with and without contact skin. The colliders on the left part of the video were initialized without any contact skin. Colliders on the right were initialized with .contact_skin(0.2). Notice the gaps remaining between colliders on the right.

https://github.com/dimforge/rapier/assets/1734958/7d4fdbdc-953a-4a09-aac6-fd574efec046

Soft CCD

The following shows the effect of soft-CCD. The moving think object is initialized with a velocity of -100.0 along the vertical axis. Left: no soft-CCD, Right: soft-CCD enabled with a max prediction distance of 10.0.

https://github.com/dimforge/rapier/assets/1734958/8a23bb6a-0492-4f5a-92f5-b68fd9928f44