phaser icon indicating copy to clipboard operation
phaser copied to clipboard

Fix: `convertTilemapLayer` creating composite bodies unintentionally

Open EddieCameron opened this issue 3 years ago • 1 comments

This PR (delete as applicable)

  • Fixes a bug

Describe the changes below:

There is an edge case that could cause a crash when using convertTilemapLayers to create Matter.js bodies from a Tilemap. If any tiles had multiple colliders and you were providing some body creation options, the parts property in the options would be modified and then concatenated with any bodies created after it. This would mean that some tiles would be combined when they shouldn't be, and on large maps would eventually hang once the convex hull got too big/complex.

This PR just clones the options object before modifying it. You may already have a favoured way of doing this.

EddieCameron avatar Jan 24 '22 10:01 EddieCameron

Maybe Clone() instead.

samme avatar Jan 26 '22 17:01 samme

Thanks for this. I have implemented your fix and credited you in the Change Log.

photonstorm avatar Apr 12 '23 02:04 photonstorm