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

Add world.queueUpdate #307

Merged
merged 1 commit into from
Dec 24, 2024
Merged

Add world.queueUpdate #307

merged 1 commit into from
Dec 24, 2024

Conversation

shakiba
Copy link
Collaborator

@shakiba shakiba commented Dec 23, 2024

Currently several methods such as world.destroyBody() are locked when a simulation step is progress and can not be called.

The new function can be used to queue a callback to be called after an ongoing simulation step. For example:

world.on("pre-solve", () => {
  // handle collision
  world.queueUpdate((world) => {
    world.destroyBody(bullet);
  })
}

If a simulation step is not in progress, the callback is called immediately.

this.m_step_callback.push(callback);
}
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the important part

@shakiba shakiba force-pushed the shakiba/world-queue-update branch from 9afc6d8 to f136db3 Compare December 23, 2024 17:58
@shakiba shakiba changed the title Add world.queueUpdate to queue and defer updates after current simulation step Add world.queueUpdate Dec 23, 2024
@shakiba shakiba force-pushed the shakiba/world-queue-update branch from 34ad7c4 to 1a1528e Compare December 24, 2024 14:07
@shakiba shakiba force-pushed the shakiba/world-queue-update branch from 1a1528e to a0dd4c3 Compare December 24, 2024 14:10
@shakiba shakiba merged commit f0127f4 into master Dec 24, 2024
2 checks passed
@shakiba shakiba deleted the shakiba/world-queue-update branch December 24, 2024 16:28
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