Box2D Symbian

As a project for school I ported Box2D to Symbian and created a simple demo.
I recorded a video: http://www.n-joy.cz/#/video/box2d-symbian/r5wyddh3ievp14lf/
At first I wanted to create some vehicle demo, but I was not able to make it stable and fast...

It runs at 25Hz, 10 iterations. One simulation step takes 15ms when using fixed-point numbers and 25ms when using floats. So, it is definitely usable for Symbian phones.
However, it is still a lot slower then my (very simple and stupid) J2ME engine, but resulting simulation is far better 🙂

The porting was pretty straightforward thanks to Erin's good work. It helped a lot that he didn't use STL. Now it is enough to simply copy all the sources into the folder and it compiles and runs on emulator:)

BUT. Because Symbian on AMR processors doesn't support global data (and it means also static variables in classes and functions), I had to do a lot dirty things into the source code to make it work 🙁
I enclosed the changes into
//SYMBIAN
...
//~SYMBIAN
marks, so maybe there could be some automated way to make some kind of patch.
Or maybe Erin could rewrite his code that he does not use static and global data anymore 😀

I also made some changed regarding fixed-point numbers, these are marked with
(already in patch by 0xtob)
//HARDWIRE
...
//~HARDWIRE
and
(new changes)
//HARDWIRE2
...
//~HARDWIRE2


You can download it here (project for Carbide C++): http://www.hardwire.cz/download/B2Test_Symb.zip
Cool! I'm guessing the main issue is the contact registers. This shouldn't be too hard to make non-global.

Unfortunately I can't support the Symbian port in the main tree. Otherwise there would be an explosion of platform specific stuff: Symbian, DS, GP-32, etc.
Erin Catto wrote:
Cool! I'm guessing the main issue is the contact registers. This shouldn't be too hard to make non-global.

Not at all, I avoided contact register by simply creating few functions with switch statements which return the same things as are in the registers.
The biggest problem were two static variabiles in b2World, s_enablePositionCorrection and s_enableWarmStarting because I had to give it as a parameter to each function which used it.
And also ZERO vector and identity matrix caused some troubles because when I used fixed-numbers I emulated them by Fixed class...and even when the ZERO vector was constant instance of the Fixed class it was still global data :/

Erin Catto wrote:
Unfortunately I can't support the Symbian port in the main tree. Otherwise there would be an explosion of platform specific stuff: Symbian, DS, GP-32, etc.

I see, but all what has to be done to make it work is not to use static and global variables 🙂
But I certainly know you have many other things in your TODO list 🙂

BTW it is really very well written, I expected much much bigger troubles!
Quote:
I see, but all what has to be done to make it work is not to use static and global variables


Ok, I added this to the TODO list.

If you'd like to tackle this after 2.0 comes out, I'll accept a patch.
Well, I just got around to doing a port of this nice-looking library with your latest version to S60 5.0.

The nice part is it just compiles and runs (on the emulator) with no problems. It took me about 20 minutes to generate the Symbian project machinery and port the helloworld executable. I think I should be OK for static variables now too, the rules have relaxed a little on this platform in recent years.

Does anyone know how I can tell if the output from helloworld is correct?

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