bevy_xpbd icon indicating copy to clipboard operation
bevy_xpbd copied to clipboard

Rigidbodies never sleep

Open Klohger opened this issue 1 year ago • 1 comments

Whenever a rigidbody begins sleeping, it immediately gets woken up. I've tried debugging, and I'm guessing the problem is that the change of external forces needs to be checked if they're above the sleeping threshold. I'm not exactly an expert when it comes to physics engines, so I cannot exactly say where the fault lies.

Klohger avatar Apr 03 '24 12:04 Klohger

I think this issue might've been introduced by automatically inserted apply_deferred systems added in Bevy 0.13. The sleeping logic was previously relying on some rather questionable and precise scheduling, and there might be some new apply_deferred systems that break it. I'll try to look into this more to verify.

Either way, I think the sleeping logic should be partially rewritten as it's currently not very robust or optimal. I have plans to experiment with "simulation islands", which would both increase parallelization and help handle sleeping properly.

Jondolf avatar Apr 03 '24 12:04 Jondolf

This was partially fixed by the solver rework (#385) in Avian 0.1. Bodies should now fall asleep again, but only if they're not interacting with other dynamic bodies. I'll close this, and open a separate issue for simulation islands soon

Jondolf avatar Jul 06 '24 01:07 Jondolf