dimforge / rapier

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

jittering and jumpyness with sharp convex hulls (rapier3d-compat) #455

Closed drcmda closed 1 year ago

drcmda commented 1 year ago

Convex hulls seem to be a lot less prone to resting, the jumpyness/jittering is sometimes out of control. It seems to get worse when the geometry is sharp or has long, pointy tips. Here's an example:

https://user-images.githubusercontent.com/2223602/218308164-e4c9065f-557b-48d9-b3b8-b553934b5b20.mp4

This is using https://github.com/pmndrs/react-three-rapier which runs "@dimforge/rapier3d-compat": "0.11.1"

And a small repro: https://codesandbox.io/s/quiet-mountain-bi1cvj?file=/src/App.js

Mik-pe commented 1 year ago

I also have this issue but using native rapier3d.

@sebcrozet

I think I managed to reproduce this in the rapier3d "convex_polyhedron" example. in convex_polyhedron3.rs from current master (2e929bbc):

diff --git a/examples3d/convex_polyhedron3.rs b/examples3d/convex_polyhedron3.rs
index 980720a..2b6f03b 100644
--- a/examples3d/convex_polyhedron3.rs
+++ b/examples3d/convex_polyhedron3.rs
@@ -26,7 +26,7 @@ pub fn init_world(testbed: &mut Testbed) {
     /*
      * Create the polyhedra
      */
-    let num = 5;
+    let num = 1;
     let scale = 2.0;
     let border_rad = 0.1;

@@ -46,7 +46,7 @@ pub fn init_world(testbed: &mut Testbed) {
                 let z = k as f32 * shift - centerz;

                 let mut points = Vec::new();
-                for _ in 0..10 {
+                for _ in 0..1000 {
                     let pt: Point<f32> = distribution.sample(&mut rng);
                     points.push(pt * scale);
                 }

Do the triangles get too dense in the convex collider? Attached screen recording from this diff:

https://user-images.githubusercontent.com/5653426/220146907-d1e391a0-cfe9-4f1c-9952-04189d3fc587.mp4