Page 1 of 1

Lots of static bodies

Posted: Tue Feb 06, 2018 5:43 pm
by jeremywsmith
In a tile-based game with a world of 200x200 there may be up to 1000+ walls; each consuming a small tile. These wall bodys are just static square bodies; however I have found that the performance drops significantly with worlds with walls.

Are there any optimisation steps I can take here, other than combining adjacent walls into one polygone (which I may end up doing.)?


Re: Lots of static bodies

Posted: Wed Feb 07, 2018 7:02 am
by TMNCorp
You have answered your own question already. There are convex shape algorithms online that can help you splitting your tilemap in as few single convex shapes as possible.

Other then that, I noticed that dyn4j is mixing static, kinematic and dynamic objects. So there is certainly an overhead involved with an increasing number of body parts.

Re: Lots of static bodies

Posted: Thu Feb 08, 2018 4:17 pm
by William
Correct. You should reduce the number of bodies in the scene as much as possible.

To that end, there are a number of ways to do that, the first by combining adjacent convex shapes into a single convex or body.

The next step would be to ask yourself if you need all the bodies in the world at the same time. For example, an old school platformer game really only needs to simulate the immediate vicinity of the player. Another option might be to split the simulation into separately simulated regions.

Re: Lots of static bodies

Posted: Tue May 01, 2018 10:32 am
by assofohdz

I have the same requirement - is there any specific keywords I should google? I can't seem to find these algorithms.

Kind regards,