Exception when double disposing PhysicsAggregate

Hi everyone,

Disposing a PhysicsAggregate a second time throws an exception.

See e.g. https://playground.babylonjs.com/#Z8HTUN#689.

Best wishes
Joe

I reported a similar issue some time ago. The disposable pattern should allow multiple calls. You can see how other parts of the framework allow it:
Babylon.js/packages/dev/core/src/scene.ts at master · BabylonJS/Babylon.js (github.com)

It would be something not too hard to implement, if you were interested in contributing. Here is that PR:
scene.dispose idempotent · BabylonJS/Babylon.js@a83abeb (github.com)

This was my question that had that added:
Disposing Engine before Scene - is it just bad coding? - Bugs - Babylon.js (babylonjs.com)

Thanks for catching this, a fix will be in Idempotent disposing of physics bodies and shapes. by carolhmj · Pull Request #14286 · BabylonJS/Babylon.js (github.com) :slight_smile:

2 Likes