Click or drag to resize
DigitalRuneTimingSettings Class
Defines timing-related simulation settings.
Inheritance Hierarchy
SystemObject
  DigitalRune.Physics.SettingsTimingSettings

Namespace: DigitalRune.Physics.Settings
Assembly: DigitalRune.Physics (in DigitalRune.Physics.dll) Version: 1.10.0.0 (1.10.0.14427)
Syntax
public class TimingSettings

The TimingSettings type exposes the following members.

Constructors
  NameDescription
Public methodTimingSettings
Initializes a new instance of the TimingSettings class.
Top
Methods
  NameDescription
Public methodEquals
Determines whether the specified Object is equal to the current Object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetHashCode
Serves as a hash function for a particular type.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Top
Properties
  NameDescription
Public propertyFixedTimeStep
Gets or sets the time step size for fixed time steps in seconds.
Public propertyMaxNumberOfSteps
Gets or sets the maximal number of sub-steps performed during one time step.
Top
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.

See Also