Skip to content

fix: RigidBody::sleep puts its whole island to sleep - #1081

Open
kylegrahammatzen wants to merge 2 commits into
dimforge:masterfrom
kylegrahammatzen:fix/manual-sleep-whole-island
Open

kylegrahammatzen wants to merge 2 commits into
dimforge:masterfrom
kylegrahammatzen:fix/manual-sleep-whole-island

Conversation

@kylegrahammatzen

@kylegrahammatzen kylegrahammatzen commented Nov 21, 2026 •

Copy link
Copy Markdown

Calling RigidBody::sleep on a body that touches awake bodies only set its flag, and since islands sleep as a whole, the body kept being simulated with the bodies it touches while is_sleeping reported true, then froze in the air once they separated.

Now the call puts the body's whole island to sleep at the next step, where it is, and it does nothing when a body of that island can't sleep then, which is the case for a kinematic body in motion, a body with sleeping turned off and a body that was woken up in the same step.

Bodies that fall asleep on their own behave as before, and the existing determinism tests pass with the same hashes.

@kylegrahammatzen
kylegrahammatzen marked this pull request as draft November 21, 2026 16:31
It used to set the flag only, so a body touching awake bodies kept being
simulated while is_sleeping reported true, then froze in the air once they
separated.

Islands sleep whole, so the call is now a request to put the body's island to
sleep. It is settled when the step applies the user changes: the island is
split first if it lost constraints, and goes to sleep right then, where it is.
The request is dropped when a body of the island cannot sleep: one woken up in
the same step, a kinematic body in motion, one that never sleeps, or a soft
body.
@kylegrahammatzen
kylegrahammatzen force-pushed the fix/manual-sleep-whole-island branch from 9a45d0c to 41c8681 Compare November 21, 2026 17:35
@kylegrahammatzen
kylegrahammatzen marked this pull request as ready for review November 21, 2026 17:36

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant