BorisTheBrave wrote:
The Java version has to deal with multithreading, but has a GC that can better cope with local things.
This is definitely true, but it's worth pointing out that even using a recent JVM with the advanced GC that it has (which is highly optimized for short-lived objects), the primary bottleneck for JBox2d is
still temporary object allocation, at least once you take graphics out of the equation. So to me, "optimizing" is pretty much equivalent to getting rid of those allocations/gcs, and this is likely even more true using AS3.
Quote:
You can see there's a lot to do. It's not been a high priority amongst development, but if you'd like to see it improve, it's certainly the sort of thing that can see incremental improvement, and with plenty of low hanging fruit.
Indeed. Focus on the contact solver and collision detection and you can get some unbelievable speed gains with very little effort; I wouldn't be surprised to hear that a couple hours work could double the physics speed (that has happened a couple of times now with Java - the latest round, which I did not do myself, rocketed my benchmark test case from 250 fps to 450 fps, and before that even happened I'd already done most of the "easy" inlinings!). Just don't waste time cutting out things that are called once per-body or anything like that (i.e. ignore the b2Body class completely), the ones you want to worry about are the things that happen per-contact-per-iteration, at least at first.
One thing that might make things a
little trickier is that in Java you can use Eclipse to get the harder inlines done (a lot of the stuff involving matrix transformations can be nasty to do by hand), since it's able to automatically inline stuff; I'm not sure if the AS3 has equivalent functionality, which might slow things down a little bit.