dimforge / bevy_rapier

Official Rapier plugin for the Bevy game engine.
https://rapier.rs
Apache License 2.0
1.23k stars 259 forks source link

Simple straight collisions cause loss of momentum, eventually stopping motion entirely #350

Open krodyrobi opened 1 year ago

krodyrobi commented 1 year ago

So I've hit some funkyness with the conservation of energy during simulations.

Windows 10

Mac OS (latest ventura)

All forces (restitution, dampening, gravity, friction etc) are configured to keep the system going forever but in reality the ball eventually stops completely. I'm aware that the window in bevy may be throttled but by default it runs as fast as it can.

Tried using fixed timestep, increasing frequency etc. nothing really worked. Saw integration parameters but from reading about them not sure what I could try.

What I noticed is that swapping workspaces, minimizing windows exhacerbates the loss but it happens regardles, extreemly noticeable on mac.

[dependencies]
bevy = "0.10.0"
bevy_rapier2d = "0.21.0"

[profile.dev]
opt-level = 1
[profile.dev.package."*"]
opt-level = 3

main.rs

recording log-release-workspace-switch.txt log-release-same-workspace-but-minimizing.txt

Vrixyz commented 3 months ago

Would be interesting to know if the issue is still happening ; the origin could be in winit, bevy_winit, or bevy_rapier integration 🤔