pmndrs/p2-es

Improve handling of adding and removing objects while stepping

Opened this issue · 2 comments

If an object (body, constraint, spring) is added or removed from the world while the world is stepping, an error is thrown.

Developers need to work around this by scheduling changes to run after the step.

Can we improve this? e.g.

  • Emit contact events after stepping, reducing the likelihood of this scenario
  • Defer changes to post step, instead of throwing an error

Change for deferring addition/removal of objects while stepping is in next: eabee3f

For the moment the change for deferring addition/removal of objects while stepping has been reverted: 46f179e

I'm not confident it was the best approach. The ideal solution is to make changes to support adding bodies during a step. e.g. cannon-es does not have this limitation, we should check how it handles this.