new vs old builds

Hi everyone,

This might be useful for people that are considering upgrading, I'll give my experiences upgrading box2d v-2.0.1 to the latest trunk on google code.
My time breakdown was like this:
60% - Changing the code to use the new fixtures instead of the shapes.
25% - changes to the collision processing
10% - one of my functions used the world->query function, which seems to have been changed to a callback process... that didnt fit well with what I needed, so I wrote my own query routine (probably slower, as it just iterates through the world body list, using b2Distance).
5% - trying to find the new SetMassFromShapes function, and then realizing it doesn't exist anymore (I believe its done automatically with one of the overloaded createfixture() calls, but i converted my code to set the mass seperately.

Performance observations: I did a small amount of performance testing comparing the two box2d versions. My setup is vc2008, c++, with a custom built engine running directx9. The testing I did was entirely observational, and not at all scientific. Its based on the core running speed of my engine with a defined number of physics objects being implemented.
I noticed a 5-10% speed increase in the broad phase/step speed for the new version, which became more apparent as more physics objects were added.
Adding/removing a lot of bodies seemed a bit slower in the new release, not sure why this is the case.

I could do some proper profiling if people would find it useful.

Also, I didnt notice any problems with the new version. For me, the two different versions produce exactly the same output.

Dan
I'm guessing body creation got slower due to the way mass properties are computed. Users seem to want a lot flexibility on mass properties.

I'm glad to hear the broad-phase performance improved.
I think my time was split up pretty similarly.
I thought the callback was asynchronous at first, but when I discovered it was in fact synchronous it made my life a lot easier. The new query code actually reduced my core query code to a few lines simple and readable lines instead of 15-20 before.
I was able to optimize it a lot for my case, since I only care about the amount of fixtures the query returns, for now at least.
But its not that hard to process all the fixtures some more.

Great work on the Box2D boristhebrave and Eric btw, it has really helped us develop our iphone game. Will post link when its available in the app store 🙂 (now waiting review)

Sincere regards,
Ævar Örn Kvaran
Gogogic ehf.
Hi!

"25% - changes to the collision processing"

Can anyone explain these differences?

Thanks a lot for your time.
These differences are basically from the old Contact Add, Persist, Remove using b2ContactPoint, to using contactBegin, contactEnd, Presolve and PostSolve callback functions, using a new type called b2Contact.
Most of the time changing this was getting the info I needed from this new type, like the exact position of the collision and collision speed.
Not as straight forward as it used to be but feel free to ask me any questions if you are lost.
skrekkur wrote:
These differences are basically from the old Contact Add, Persist, Remove using b2ContactPoint, to using contactBegin, contactEnd, Presolve and PostSolve callback functions, using a new type called b2Contact.
Most of the time changing this was getting the info I needed from this new type, like the exact position of the collision and collision speed.
Not as straight forward as it used to be but feel free to ask me any questions if you are lost.


skrekkur, I'm having the same problems.
I have a rectagle and a circle colliding
Analyzing this
b2Manifold* mainfold=contact->GetManifold();
I see mainfold tells me the exact point in local coordinates of my rectagle. But how can I get the exact contact point on my circle?

Can you help me or show me your code?
Thanks in advance.
I am a bit late at the party. I just updated our game iBlast Moki to use the latest box2d (rev 31) and I also noticed that the forces and the torque of a body are not reset at the beginning of every step.
Is this a wanted behavior?
Yes, some people want to do multiple sub-steps per frame with the same force set. You now need to call b2World::ResetForces after the step.
Thanks Erin,

I love the new SDK, the callback mechanism for QueryAABB is so much better. No need to preallocate memory anymore.
Also I found that 2 bugs reported by our players have been fixed with the latest which is also great. Thanks for the great work.

I am not a big fan of this ClearForces() as this will iterate through all the objects several times per frame which is not as performant as before, but that's easy to fix on our side.
I will likely make force clearing a non-mandatory step soon. Instead there will be a flag to enable/disable automatic force clearing.

Original thread: https://box2d.org/forum/viewtopic.php?t=3947