Simulation Class |
Namespace: DigitalRune.Physics
The Simulation type exposes the following members.
Name | Description | |
---|---|---|
Simulation |
Initializes a new instance of the Simulation class.
|
Name | Description | |
---|---|---|
Equals | (Inherited from Object.) | |
Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) | |
GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) | |
GetNextTimeStep |
Gets the size of the next simulation time step.
| |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) | |
OnSubTimeStepFinished |
Raises the SubTimeStepFinished event.
| |
ToString | Returns a string that represents the current object. (Inherited from Object.) | |
Update(Single) |
Advances the simulation by the given time.
| |
Update(TimeSpan) |
Advances the simulation by the given time.
|
Name | Description | |
---|---|---|
CollisionDomain |
Gets the collision domain.
| |
Constraints |
Gets the constraints.
| |
ContactConstraints |
Gets the contact constraints.
| |
ForceEffects |
Gets the force effects that act on the rigid bodies.
| |
IslandManager |
Gets the SimulationIslandManager.
| |
ResponseFilter |
Gets or sets the collision response filter.
| |
RigidBodies |
Gets the rigid bodies.
| |
Settings |
Gets or sets the simulation settings.
| |
TargetTime |
Gets the target time to which the simulation Time should advance.
| |
Time |
Gets the current simulation time.
| |
TimeScaling |
Gets or sets the time scaling.
|
Name | Description | |
---|---|---|
SubTimeStepFinished |
Occurs when an internal time step has finished.
|
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.