Body.Enabled performance hit

Topics: Developer Forum
Dec 8, 2011 at 10:18 PM

This is with 3.3.1

While creating a body I take a 98% performance load time hit with a body enabled than if I just set it disabled.

 

I've tried to track it, so far I got Creating Proxies -> broad phase adding proxies -> tree adding proxies - > and then to the function InsertLeaf()

And then I don't comprehend any of that so I can't really explore any further.

 

While creating the bodies and having them all disabled it only takes 10% hit from the 2% so it really has no impact when creating the bodies, but having them initially enabled really kills my game when I need to add and maybe even remove bodies.

I read that body creation was time consuming and to use pooling while setting the body.Enabled to true or false. But pooling has no help since setting Enabled is the major problem.

Dec 20, 2011 at 6:07 AM

Interesting, I just ran into this too. I keep a pool of Body objects around and just set them to Enable true/false as I need them. I have a scenario where I'm enabling 50-100 circle bodies, and it is taking over 25ms on the Xbox! Almost all the time is spent in InsertLeaf (stepping through it a few times, I saw it make as many as 41 loops through the while loop in there).

However, by switching to using QuadTreeBroadPhase instead of DynamicTreeBroadPhase (by using the World constructor that takes an AABB), it ends up taking about one tenth the time! So for now it seems I have a solution.

I'm wondering if there is any guidance anywhere on when to use QuadTree vs DynamicTree?

Dec 21, 2011 at 7:31 AM

Awesome! You just made my load time go from 13 seconds to .1 second lol.

Yeah, I'd like to know the pros and cons of Quad Tree and Dynamic Tree. So far this doesn't seem to have any negative effects for what I need.