Box2D API Changes

BlitzMax Forums/Brucey's Modules/Box2D API Changes

Brucey(Posted 2008) [#1]
I haven't committed them to SVN yet, but the latest Box2D source has some changes to the API.

b2World.DoStep() changes to :
	Method DoStep(timeStep:Float, velocityIterations:Int, positionIterations:Int)

Note that this separates the iterations into separate for velocity and position. I expect this allows you to fine-tune the engine somewhat.

In joints, the GetReactionForce() and GetReactionTorque() now include a delta-time parameter, which you can apparently use to get more accurate readings for a given point in time.

The DoStep() change will break your code. According to the docs :
The suggested iteration count for Box2D is 10 for both velocity and position. You can tune this number to your liking, just keep in mind that this has a trade-off between speed and accuracy. Using fewer iterations increases performance but accuracy suffers. Likewise, using more iterations decreases performance but improves the quality of your simulation.


I'll let you know when I upload the changes :-)


Armitage 1982(Posted 2008) [#2]
That's a good new feature.
I wish having more time left to finish my project so far.

I stay tuned to this thread Brucey ;)


Brucey(Posted 2008) [#3]
Okay... latest code is in SVN now.

Still need to update the documentation re: the new API... but please let me know if there's anything obvious broken or otherwise.

:-)


Armitage 1982(Posted 2008) [#4]
So I update my code and everything seems working fine for the moment.
Even the collision *bug* :-)

As we speak about interation I'm wondering one thing on project created with Box2D.
I can't see any informations about the fixed rate logic.
Probably because Box2D is doing this itself to ensure good simulation result.

This fixed rate is welcome in my game but currently I just develop my ideas without ever think about this important aspect.
I will probably ask this inside the Box2d forum but do you think it's a bad idea with Box2d (fixed rate logic?) to be cycle based ?


Brucey(Posted 2008) [#5]
The box2d forum is probably the better place to ask such deep questions ;-)


There's a new release of the Box2d available. (If you are sync'd up with SVN, you can keep using that if you want).


Rico(Posted 2008) [#6]
Hi - I've downloaded and compiled the New Box2d release. Brucey what do you mean by 'game breaker'? I'm worried my game is broken! I changed the Do Step command to the new version and now my game crashes (Assert failed). Do I need to do anything else apart from change the DoStep command? (My game was working with the previous version of Box2D)
All the examples work ok.

Thank you.


Brucey(Posted 2008) [#7]
Make sure you do a full build of your app, rather than quick build, just in case any old stuff has been left in your build.


Rico(Posted 2008) [#8]
I'm doing a full build. I've been commenting out bits of the code, and it works if I comment my Prismatic joints out. Its obviously something with the way I'm setting them up - since some of the examples use Prismatic Joints and they work good . It didn't generate a problem in the previous build though. I'll let you know when I isolate the problem - it was probably something I shouldn't have been doing, but the previous version let me get away with. Anyway I'll get back to you.


Brucey(Posted 2008) [#9]
Does it crash on anything specific? ie. The same bit all the time?


Rico(Posted 2008) [#10]
Phew - Well I've found the problem. If you use SetFixedRotation(True) with a Prismatic Joint it crashes. Its does the same in the examples.
Thing is you don't need to fix the rotation (I just assumed you did need to), since bodys attached to this type of joint do not rotate anyway. Although I don't know why it would crash on the new version and not the old one, maybe there's been some slight changes.
BTW what does Warmstarting and Validate(), and Position Correction do? - it doesn't explain them in the docs. Just a brief explanation would be helpful.

Thank you - Rico


Brucey(Posted 2008) [#11]
If you use SetFixedRotation(True) with a Prismatic Joint it crashes

I've tried it myself.
It's not really crashing... It fails with an assertion :

b2Assert(det != 0.0f);

in b2Math.cpp,
b2Vec2 b2Mat33::Solve22(const b2Vec2& b) const

So I'm guessing you shouldn't be setting fixed rotation to a body that is connected to a joint?

Or, maybe it's a bug... :-p

BTW what does Warmstarting and Validate(), and Position Correction do?

They all appear to be methods for testing the integrity of the engine. So not really something you need to be calling. Specifically what they do... I dunno. You'd have to look at the C++ source :-)