Defines timing-related simulation settings.

Namespace: DigitalRune.Physics.Settings
Assembly: DigitalRune.Physics (in DigitalRune.Physics.dll) Version: 1.5.0.0 (1.5.0.9503)

Syntax

C#
public class TimingSettings
Visual Basic
Public Class TimingSettings
Visual C++
public ref class TimingSettings

Remarks

Each call of Simulation.Update(TimeSpan) advances the simulation state by a given time. The time by which the simulation should be advanced is called a "time step". Internally the time step specified in the parameter of Update(TimeSpan) is divided into sub time steps (internal time steps) of constant size. This constant size is FixedTimeStep. That means, if the user calls Simulation.Update(1.0f / 30.0f) and FixedTimeStep is 1/60 (default), the simulation will perform to time steps with 1/60 s.

If the user calls Simulation.Update(1.0f / 120.0f), the simulation will perform no simulation update because the time step is less than FixedTimeStep. But the time is not "lost". When the user calls Simulation.Update(1.0f / 120.0f) the next time, the simulation will make a single time step with 1/60 s. The simulation class makes sure that all simulation updates use fixed time steps internally and that overall no simulation time is lost.

The number of time steps per Update(TimeSpan) call is actually limited by MaxNumberOfSteps. This is necessary to avoid a typical problem in game physics: Example: There are too many physical objects in the game. One frame of the game took 0.016 ms to compute. The simulation is called with Simulation.Update(0.016) and it performs 1 time step internally. Because there are too many objects, this frame took 0.034 ms to compute. In the next frame Simulation.Update(0.034) is called and the simulation performs 2 time steps internally - which takes even more time... Each frame the simulation must make more internal time steps to keep up with the elapsed time, and eventually the frame rate of the game will go towards 0. To avoid this scenario the maximal number of allowed sub time steps is limited - practically this means that time is lost and the simulation moves objects in slow motion. Slow motion at a low frame rate is better than real-time at 0 frames per second.

Simulation Quality and Timing: Per default the simulation makes time steps of 1/60 seconds (60 Hz). Increasing the time step size makes the simulation faster and less stable. Decreasing the time step size makes the simulation slower and more accurate and stable - higher box stacks are possible, less jittering, less interpenetrations of objects.

Inheritance Hierarchy

System..::..Object
  DigitalRune.Physics.Settings..::..TimingSettings

See Also