I'd like to support very large worlds in the game that I'm making. This is not a problem usually, because I can cull most of the world as it is not visible all at once. However, Box2D doesn't seem to like my idea!
My terrain currently consists of about 1000 edge shapes. This alone seems to work fine, however: Even after I add only a few (~25) dynamic objects (small circles), the performance is decreasing dramatically!
The answer is because edge shapes do not collide with other edge shapes.
From the manual:
Edge shapes are line segments. These are provided to assist in making a free-form static environment for your game. A major limitation of edge shapes is that they can collide with circles and polygons but not with themselves. The collision algorithms used by Box2D require that at least one of two colliding shapes have volume. Edge shapes have no volume, so edge-edge collision is not possible.
So even though you have many edge shapes, as they do not collide with each other, you aren't seeing a performance drop. Once you add some objects, then box2d starts checking for collisions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With