Exception when querying data from a disposed PhysicsBody

Hi everyone,

Please see here: https://playground.babylonjs.com/#Z8HTUN#1337

I am still chasing why this is possible** in my local project (obviously there should not be a call to anything after the body has been disposed). But I do not think Babylon should crash like that. Particularly, if the the calling code runs in a render loop observable, the entire app crashes :frowning:

User hotfix would be try/catch and/or if( PhysicsBody.isDisposed )

Best wishes
Joe


**Babylon does auto-dispose a physics body that is attached to the disposed mesh. The disposal happens indirectly in PhysicsEngineComponent.ts via a Object.defineProperty(TransformNode.prototype, "physicsBody",..) and there via an onDispose observable. Thumbs up to Codex.

cc @Cedric

Adding such checks, in all physics methods will make the package grow (a lot) and performance will degrade. So, we let the check responsability to the user. You get a crash that you have to fix. silently failing will be more difficult to track and debug issues. Or user, as you say, can use a try/catch block.