Chapter 8. Physical Simulation

Physical simulation allows simulated agents to behave in a physically realistic fashion. This means that agents in the simulated world can be configured to behave just as real objects do, according to the laws of physics. If a ball is placed in the air above a floor, for example, physical simulation can be used to make the ball realistically fall toward the floor and bounce. Among other things, physical simulation can be used for realistic simulation of robots, vehicles and animals. The current version of breve uses portions of the excellent ODE physical simulation engine.

Even though it is incredibly useful, physical simulation can add complexity and potential instabilities to a simulation. This chapter begins with the section When to Use Physical Simulation (the section called “When to Use Physical Simulation”), which discusses when it is appropriate to use physical simulation and possible alternatives to full physical simulation. You should read this section first to help you decide whether physical simulation is necessary for your simulation.

When to Use Physical Simulation

In many circumstances, users wish to write simulations that use certain aspects of physics, but not others. In these situations it is tempting to enable physical simulation, but this often opens the door to other sorts of complications. Physical simulation is slower, more complicated and inherently less stable than non-physical simulation. It is often far more effective to use "pseudo-physics" in which you implement some physical simulation features without enabling full physical simulation.

One example is a simulation which requires gravity for "ballistic" (non-Multibody Real) objects. Though the effects of gravity can be enabled using physical simulation, a more robust and far more efficient approach is to simply set a constant acceleration of (0, -9.8, 0). By disabling the physical simulation engine and setting a constant acceleration, a great deal of complexity can be avoided.

Another example is two objects that stick together and behave as a single entity. Though this can be simulated as a MultiBody object, if other aspects of physical simulation are not required, it may be better to enforce the relationship between the objects manually at each time-step by making one of the objects move itself to maintain a certain position relative to the other.

It's often unclear which technique should be used, but many users tend to err on the side of enabling physics which is the more complicated solution. True physical simulation is typically necessary only when dealing with physically realistic jointed bodies, such as a simulated robot or simulated animal. You should be aware of the pros and cons of true physical simulation and consider using your own "pseudo-physics" instead.