Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle sleeping logic before physics #425

Merged
merged 1 commit into from
Jul 13, 2024
Merged

Handle sleeping logic before physics #425

merged 1 commit into from
Jul 13, 2024

Conversation

Jondolf
Copy link
Owner

@Jondolf Jondolf commented Jul 13, 2024

Objective

Currently, sleeping and waking is handled after physics. This leads to a one frame delay before bodies are woken up by things like velocity changes or applied external forces. It can even cause ExternalImpulse to do nothing, because the body is only woken up by the time the impulse should've already been applied and cleared.

Solution

Run sleeping logic before physics. User changes are detected by comparing component change ticks to a LastPhysicsTick resource. This refactor also lets us get rid of the PhysicsChangeTicks component, which was previously stored and updated for all physics entities.

PhysicsStepSet::Sleeping now technically doesn't have much sleeping logic anymore, but that can be reworked in a follow-up.

@Jondolf Jondolf added the bugfix label Jul 13, 2024
@Jondolf Jondolf merged commit 0d1f73b into main Jul 13, 2024
4 checks passed
@Jondolf Jondolf deleted the wake-before-physics branch July 13, 2024 20:56
@Jondolf Jondolf added C-Bug Something isn't working A-Dynamics Relates to rigid body dynamics: motion, mass, constraint solving, joints, CCD, and so on and removed bugfix labels Jul 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Dynamics Relates to rigid body dynamics: motion, mass, constraint solving, joints, CCD, and so on C-Bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant