bevy_rapier icon indicating copy to clipboard operation
bevy_rapier copied to clipboard

Perpetual jitter/contact clip bouncing with angular velocity

Open atlv24 opened this issue 2 years ago • 3 comments

Minimal reproduction

I think there might be some scheduling weirdness with the default rapier3d setup, it seems that angular velocity is being applied to rotation after contact resolution for that frame, or maybe i misunderstand how render updates vs physics updates are being run. the behavior i am observing is that

Setup

A dynamic convex hull resembling a ball is a few units above a flat static floor. A dynamic cone is a few units above the hull, a bit off-center. Gravity will pull both objects down towards the floor.

Expected behavior

There is an initial linear impact of the hull against the floor. The hull is perfectly balanced on its tip. The cone falls and hits the hull off-axis. The hull topples as it gains angular velocity. Another side of the hull hits the floor and does not visibly clip into the floor because contact resolution is complete before the frame is rendered. Some of the hull's energy is lost in the process. Eventually both the hull and the cone lose all energy and stop moving, and get marked asleep.

Observed behavior

Initial linear impact behaves correctly. The hull topples over as the cone hits it off-axis and gains angular velocity. The hull momentarily clips into the floor and renders that way for at least a frame before bouncing back out and correcting, with as much or more energy as before. The hull gets stuck in an infinite micro-angular-bouncing loop and jitters perpetually. Neither the cone nor the hull get marked asleep.

No combination or Restitution/Friction/Dampening or erp value adjustments seems to fix this.

atlv24 avatar Sep 05 '22 23:09 atlv24

This repro could be even simpler by spawning the hull with an initial angular velocity and getting rid of the cone setup.

The behavior is also easier to observe with an orthographic camera.

rparrett avatar Sep 09 '22 14:09 rparrett

The linked reproduction no longer reachable, is it still an issue ?

Vrixyz avatar May 24 '24 09:05 Vrixyz

I changed my username, the url is now https://gist.github.com/atlv24/1c524f734cc109946f12a4294a2f5b5e

atlv24 avatar May 27 '24 06:05 atlv24