Thanks Ihar,
We are currently 90% done with the porting of Box2D revision 218 to C#. All the code is ported, but there are a few errors (pointers that have not been ported, C++ specific code and the like). We already have dinedal (a few posts up) joined the project but we would like more eyes to make it as good a port as possible.
If anyone wants to join in, feel free to contact me using private message on the boards.
I just spent some time optimising Box2DX for the Xbox 360. Previously I found it almost unusable on the xbox with anything more than 25 objects. However after applying the tricks below I started to get some very good performance.
* I Removed almost all heap allocation in box2dx. This meant using memory pools, converting structs to classes, and moving array allocations out of methods (arrays are always allocated on the heap in c#). The garbage collector on the xbox sucks, and Box2dx causes huge amounts of GC latency.
* In performance critical areas such as the contact solver and the joint solvers that I am using, I replaced vector overloaded operators with Add(ref v1, ref v2, out result) style methods. This gave a pretty huge speed boost, C# overloaded operators are terrible on the xbox as they are never inlined and require tons of argument copying.
* Made the islands solve in different threads. Not sure about this one, wasn't hard to do, but only gives a performance boost under certain circumstances which I haven't really tested yet.
I had a go at using fixed point arithmetic class like the box2d DS version, but the overloaded operator overhead hugely overshadowed any performance gain. I guess if someone has more patience than me they can try using methods instead of operators for the maths.
Even if you decide that the memory and overloaded operators are to much work, I do have one request in the next version of box2dx:
Please do not delete the memory de-allocations, instead just comment them out, this makes it much easier when adding memory pools to work out when an object is ready to be destroyed.
@Convolous: Your additions sounds great and I would be more than happy to include them in Farseer Physics Engine. Box2DX should stay as close to Box2D as possible in my opinion, but the call is really up to Ihar3d.
@All: I need some help with the port at the moment. Box2D is about to be released and it would be great if we could have a C# port out soon after. The status of the port right now is that it works like a charm, but it have a few bugs. The bugs are port related and should be easy to fix.
The guys on the team currently working on Box2DX have been non-responsive for a period of time because of other stuff. That is the life of an open-source project, so I'm looking for someone to work with me to get the port up and running. If you are interested, I would be more than happy to hear from you.
Hello All!
As you can see Box2DX was not updated long time, this took place by different reasons. Now I found developer who wish to help reanimate Box2DX.
There are Box2D.XNA and Farseer, based on Box2D. They both are pretty good, in actual state and working fine 🙂
Reason to start Box2DX project was to create C# port which will be maximum closest to original Box2D, and without using XNA.
So I just want to investigate is there necessity in this port, to decide to continue developing or not.
Thanks in advance.
At this point it would be easiest to take Box2D.XNA and replace XNA's math types. You could resurect Box2DX in an afternoon.