Click or drag to resize
DigitalRuneSimulation Class
Manages a physics simulation.
Inheritance Hierarchy
SystemObject
  DigitalRune.PhysicsSimulation

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

The Simulation type exposes the following members.

Constructors
  NameDescription
Public methodSimulation
Initializes a new instance of the Simulation 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 methodGetNextTimeStep
Gets the size of the next simulation time step.
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.)
Protected methodOnSubTimeStepFinished
Raises the SubTimeStepFinished event.
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Public methodUpdate(Single)
Advances the simulation by the given time.
Public methodUpdate(TimeSpan)
Advances the simulation by the given time.
Top
Fields
  NameDescription
Public fieldWorld
Represents the simulation "world".
Top
Properties
  NameDescription
Public propertyCollisionDomain
Gets the collision domain.
Public propertyConstraints
Gets the constraints.
Public propertyContactConstraints
Gets the contact constraints.
Public propertyForceEffects
Gets the force effects that act on the rigid bodies.
Public propertyIslandManager
Public propertyResponseFilter
Gets or sets the collision response filter.
Public propertyRigidBodies
Gets the rigid bodies.
Public propertySettings
Gets or sets the simulation settings.
Public propertyTargetTime
Gets the target time to which the simulation Time should advance.
Public propertyTime
Gets the current simulation time.
Public propertyTimeScaling
Gets or sets the time scaling.
Top
Events
  NameDescription
Public eventCode exampleSubTimeStepFinished
Occurs when an internal time step has finished.
Top
Remarks

The Simulation owns collections of RigidBodies, Constraints and ForceEffects. All RigidBody, Constraint, and ForceEffect objects need to be added to these collections. All objects in these collections take part in the simulation. Object that are not added to these collections are not simulated.

Advancing the Simulation: To advance the simulation Update(TimeSpan) must be called with the time span by which the simulation time should advance. In Update(TimeSpan) the simulation computes forces and moves the objects to new positions. One step of the simulation is called a "time step". In some cases the simulation will internally subdivide a time step into "sub time steps" or "internal time steps". In most games the Update(TimeSpan) will be called with 1/60 s (60 frames per second) and the simulation will make exactly one time step. See TimingSettings for more information regarding timing.

Collision Detection: The Simulation owns a CollisionDomain. Each RigidBody has a CollisionObject that represents the collision information of the body and is put into the collision domain. You are free to use the CollisionDomain to perform collision queries (e.g. GetContacts(CollisionObject)). You can also add custom CollisionObjects to the collision domain. For example, you can add a collision object to check if rigid bodies or other collision objects enter a certain area.

The collision filter of the CollisionDetection is set to an instance of type CollisionFilter. The filter rules in the CollisionFilter can freely be changed as required by the application. The whole filter can be replaced too, but the new filter should implement the interface ICollisionFilter. If the new collision filter does not implement ICollisionFilter, then automatic collision filtering for constraints does not work (see property CollisionEnabled). Advanced physics modules like ragdoll physics and vehicle physics might also need a collision filter that implements ICollisionFilter.

The UserData of Contacts in this collision domain are used to store references to ContactConstraints. That means, Contact. UserData must not be changed.

The "World" Rigid Body: The simulation owns one special rigid body that represents the "world" of the simulation: World. This rigid body is not contained in the RigidBodies collection and other bodies do not collide with this body. This body is only used to define the space in which the simulation takes place. Rigid bodies that leave the space of this rigid body are automatically removed from the simulation. Per default the Shape of the World body is a box that is 20,000 units long and centered at the world space origin. - If object leave this area, they should be removed. A typical scenario is that an explosion shoots objects into nirvana. When they leave the 20,000 units area, they are removed to safe simulation time. You can adjust the Shape of the world body to the size of the level or the "area of interest".

The second function of the World body is to act as an anchor for Constraints. All constraints are two-body constraints and, for example, if you want to fix a rigid body at a certain position in world space you create a constraint between the rigid body and the world body as the other body.

See Also