Motor Physics: 50 dancing boxes

move mouse inside stage, press ‘w’ key to wiggle the floor

This is a follow up to the post about the SI-Solver from the Box2D engine. The revised demo shows a worst case scenario with 50 stacked boxes. It took great effort to max out performance, but I think it’s fast enough now, especially when realizing that the engine does a lot of computations each frame to make things stable (for example 50 sequential impulse computations per box). Performance is top priority, because a physics system which sucks up all processing time doesn’t leave room for rendering, AI and other game engine elements and hence is useless for more complex games.

I still see a lot potential to make it faster, probably in the range of 30-70%, but I won’t go into that for now. Instead I’m concentrating on putting the engine pieces together and adding forces, constraints and user interactivity. Enough with just bouncing stuff!

As a side note, I also decoupled the simulation from the frame rate (which I should have done a long time ago), so the physics attempts to run at a constant rate, which is very important for games. The example above is limited to 60fps so it tries to update the simulation every ~16ms. When the fps counter shows more than 60fps, there is still processing time available.

10 thoughts on “Motor Physics: 50 dancing boxes”

  1. Great work on that, I’m can’t wait till the day your engine will be released. tried some others, but yours will probably blow them away very quick…

  2. with the new Flash Player Update 3 Beta 1 I’m getting now 80fps (2.1Ghz P-Mobile, no Dual Core), that is an increase of 20fps. This is because rendering is now even faster using some sort of GPU acceleration, and it should be even better on dual core systems. Maybe someone could post their results.

  3. Hi

    As a fresh user i only wanted to say hello to everyone else who uses this site :D

Comments are closed.