Performance issues with large static ribs in Box2D

I want to support very large worlds in the game that I am making. This is usually not a problem because I can drop most of the world because it is not immediately visible. However, Box2D does not seem to be like my idea!

Currently, my area consists of 1000 regional figures. However, this alone works fine: Even after adding only a few (~ 25) dynamic objects (small circles), performance drops dramatically!

  • Why does this happen, a dynamic tree should invalidate all unaffected static terrain forms very early and without penalties, right?
  • (How) can I get around this?
+5
source share
1 answer

The answer is that the shapes of the ribs do not collide with other shapes of the ribs.

From the manual:

Edge shapes are line segments. They are designed to be a static free form environment for your game. The main limitation 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 the two colliding forms has volume. The extreme forms do not have volume, so an edge collision is impossible.

So, despite the fact that you have many edge forms, since they do not collide with each other, you do not see a decrease in performance. After adding some objects, box2d starts checking for conflicts.

+1
source

All Articles