Hey,
I've now done speed tests with rectangles instead of balls, and here
box2d is performing even better.
http://wiki.laptop.org/go/Physic_Engines/Speed_Tests
Jeremy Fitzhardinge wrote:
Chris Hager wrote:
Hey all,
Josh and I now made some speed tests with both 2D physics engines -
Box2D and Chipmunk - and here are some results. One warning though:
The tests were made with Python, and for Box2D there's a library
compiled with swig, whereas Chipmunk's interface is done with ctypes.
This may change the results to Box2D's advantage, but is justifiable
as our interest right now is which performs better with Python and on
the xo laptop.
In the end, Box2D performs quite a bit better than Chipmunk, although
it has a ways larger library and many more functions. On a XO Laptop
(build 650), the Box2D engine can easily handle 50 elements - almost
twice what we got from Chipmunk.
Have you done any profiling to see where the time is going? I did
some investigation about how hard it would be to make Chipmunk use
3dnow to get some vectorization; I came to the conclusion that it was
definitely possible if it helps any of the hotspots. But I haven't
measured to see where the time is going.
After studying the test results, the hotspot definitely is the drawing
with pygame. If you simply disable the pygame drawing things, the speed
multiplies by 2 or 3.
On my machine, the pygame drawing get's really slow at around 200
elements, on the xo laptop, the framerate drops below 30 with ~ 50 balls
or 18 polygons. Just with the physic calculations and without the
drawing, box2d has full performance (40fps), which only drops with 60
polygons.
But as you suggest, my suspicion is that a lot of the time is being
lost in the python binding, and a higher-level interface would allow
it to perform better.
I think with SWIG it's maybe the most we can get out of it.
How do the physics models themselves compare?
The only difference I noticed so far is that Box2D calculates in MKS
(meter-kilo-seconds), and we have to do the translation to pixels by hand.
J
___
Devel mailing list
Devel@lists.laptop.org
http://lists.laptop.org/listinfo/devel