quinton-ashley / p5play

JavaScript game engine that uses q5.js/p5.js for graphics and Box2D for physics.
https://p5play.org
GNU Affero General Public License v3.0
654 stars 183 forks source link

Sprites with no colliders or sensors are not fully removed from the physics simulation? #309

Closed quinton-ashley closed 6 months ago

quinton-ashley commented 6 months ago

Removing sprite's colliders should make the physics simulation speed go up but it does nothing. Only removing them makes the physics simulation speed go up.

In p5play I'm destroying the physics body of sprites with no collider or sensors though.

$.world.destroyBody(this.body);
this.body = null;

Here's a minimum reproducible example:

https://aijs.io/editor?user=quinton-ashley&project=noCollidersBug

quinton-ashley commented 6 months ago

I'm pretty sure this is not a bug actually.

The physics simulation doesn't have to do anything with the static colliders and puts them to sleep. Removing them is negligible because the performance difference is only due to drawing the circles or not.

quinton-ashley commented 5 months ago

Here's a proper demo:

https://aijs.io/editor?user=quinton-ashley&project=colliderType_demo