Haufen

vorherig nächste


Demonstration of a pile of objects falling into a corner using the 2D Rigid Body Physics Engine.

This is a good stress test for the physics engine. Click the add block button to add more blocks. Eventually the simulation will be unable to keep up with real time.

To see whether the simulation is keeping up with real time click the show clock button. The clock shows two second hands: the red hand tracks real time and the blue hand tracks simulation time. When the red hand is ahead of the blue hand it means the simulation has fallen behind real time.

The connected blocks checkbox includes two blocks that are connected by joints. Those are a good test of the ability to to keep joints together during a series of violent collisions.

Enabling the endless loop checkbox causes the simulation to be rebuilt every few seconds. The period is set by the loop time amount. This allows running the simulation over and over which is a good way to test the physics engine with many random situations.

The main performance challenge is when the blocks have settled down and are all lying in contact. Enable the show forces checkbox to see how hard the physics engine is working to figure out the many contact forces.

The physics engine performance is proportional to the the number of connected contacts raised to the fourth power. Here is an experiment that shows this:

  1. Set the number of blocks to 15, and notice that the simulation cannot keep up with real time once the blocks have settled into the corner. With 15 blocks there are around 60 contact forces, and 60^4 = 12,960,000.
  2. Enable the two piles checkbox. Now the simulation can keep up with real time because there are two piles instead of one. With 7 or 8 blocks in each pile there are around 30 contacts in each pile, and 2*(30^4) = 1,620,000 which is an order of magnitude less calculations needed.

Also available: source code, documentation and how to customize.

This web page was first published November 2016.

vorherig nächste Valid HTML 4.01