Class Simulation
public class Simulation : IDisposable- Inheritance
- 
      objectSimulation
- Implements
- Extension Methods
Fields
DisableSimulation
Totally disable the simulation if set to true
public static bool DisableSimulationField Value
OnSimulationCreation
Temporary solution to inject engine flags
public static Simulation.OnSimulationCreationDelegate OnSimulationCreationField Value
Properties
ColliderShapesRenderGroup
public RenderGroup ColliderShapesRenderGroup { get; set; }Property Value
ColliderShapesRendering
Enables or disables the rendering of collider shapes
public bool ColliderShapesRendering { set; }Property Value
ContinuousCollisionDetection
public bool ContinuousCollisionDetection { get; set; }Property Value
CurrentCollisions
Every pair of components currently colliding with each other
public ICollection<Collision> CurrentCollisions { get; }Property Value
FixedTimeStep
By decreasing the size of fixedTimeStep, you are increasing the “resolution” of the simulation. Default is 1.0f / 60.0f or 60fps
public float FixedTimeStep { get; set; }Property Value
Gravity
Gets or sets the gravity.
public Vector3 Gravity { get; set; }Property Value
- Vector3
- The gravity. 
Exceptions
- Exception
- Cannot perform this action when the physics engine is set to CollisionsOnly 
IncludeStaticAgainstStaticCollisions
Should static - static collisions of StaticColliderComponent yield PhysicsComponent.NewCollision() and added to PhysicsComponent.Collisions ?
public bool IncludeStaticAgainstStaticCollisions { get; set; }Property Value
Remarks
Regardless of the state of this value you can still retrieve static-static collisions through CurrentCollisions.
MaxSubSteps
The maximum number of steps that the Simulation is allowed to take each tick. If the engine is running slow (large deltaTime), then you must increase the number of maxSubSteps to compensate for this, otherwise your simulation is “losing” time. It's important that frame DeltaTime is always less than MaxSubSteps*FixedTimeStep, otherwise you are losing time.
[Obsolete("Value is ignored, use MaxTickDuration instead")]
public int MaxSubSteps { get; set; }Property Value
MaxTickDuration
public float MaxTickDuration { get; set; }Property Value
SpeculativeContactRestitution
public bool SpeculativeContactRestitution { get; set; }Property Value
Methods
AddConstraint(Constraint)
Adds the constraint to the engine processing pipeline.
public void AddConstraint(Constraint constraint)Parameters
- constraintConstraint
- The constraint. 
Exceptions
- Exception
- Cannot perform this action when the physics engine is set to CollisionsOnly 
AddConstraint(Constraint, bool)
Adds the constraint to the engine processing pipeline.
public void AddConstraint(Constraint constraint, bool disableCollisionsBetweenLinkedBodies)Parameters
- constraintConstraint
- The constraint. 
- disableCollisionsBetweenLinkedBodiesbool
- if set to - true[disable collisions between linked bodies].
Exceptions
- Exception
- Cannot perform this action when the physics engine is set to CollisionsOnly 
ClearForces()
public void ClearForces()CreateConstraint(ConstraintTypes, RigidbodyComponent, Matrix, bool)
Creates the constraint.
public static Constraint CreateConstraint(ConstraintTypes type, RigidbodyComponent rigidBodyA, Matrix frameA, bool useReferenceFrameA = false)Parameters
- typeConstraintTypes
- The type. 
- rigidBodyARigidbodyComponent
- The rigid body a. 
- frameAMatrix
- The frame a. 
- useReferenceFrameAbool
- if set to - true[use reference frame a].
Returns
Exceptions
- Exception
- Cannot perform this action when the physics engine is set to CollisionsOnly or Both RigidBodies must be valid or A Gear constraint always needs two rigidbodies to be created. 
CreateConstraint(ConstraintTypes, RigidbodyComponent, RigidbodyComponent, Matrix, Matrix, bool)
Creates the constraint.
public static Constraint CreateConstraint(ConstraintTypes type, RigidbodyComponent rigidBodyA, RigidbodyComponent rigidBodyB, Matrix frameA, Matrix frameB, bool useReferenceFrameA = false)Parameters
- typeConstraintTypes
- The type. 
- rigidBodyARigidbodyComponent
- The rigid body a. 
- rigidBodyBRigidbodyComponent
- The rigid body b. 
- frameAMatrix
- The frame a. 
- frameBMatrix
- The frame b. 
- useReferenceFrameAbool
- if set to - true[use reference frame a].
Returns
Exceptions
- Exception
- Cannot perform this action when the physics engine is set to CollisionsOnly or Both RigidBodies must be valid 
CreateHingeConstraint(RigidbodyComponent, Vector3, Vector3, RigidbodyComponent, Vector3, Vector3, bool)
Creates a hinge constraint using a specialized constructor.
public static HingeConstraint CreateHingeConstraint(RigidbodyComponent rigidBodyA, Vector3 pivotInA, Vector3 axisInA, RigidbodyComponent rigidBodyB, Vector3 pivotInB, Vector3 axisInB, bool useReferenceFrameA = false)Parameters
- rigidBodyARigidbodyComponent
- The rigid body a. 
- pivotInAVector3
- Pivot point in body a. 
- axisInAVector3
- Axis in body a. 
- rigidBodyBRigidbodyComponent
- The rigid body b. 
- pivotInBVector3
- Pivot point in body b. 
- axisInBVector3
- Axis in body b. 
- useReferenceFrameAbool
- if set to - true[use reference frame a].
Returns
Exceptions
- Exception
- Cannot perform this action when the physics engine is set to CollisionsOnly or Both RigidBodies must be valid 
CreateHingeConstraint(RigidbodyComponent, Vector3, Vector3, bool)
Creates a hinge constraint using a specialized constructor.
public static HingeConstraint CreateHingeConstraint(RigidbodyComponent rigidBodyA, Vector3 pivotInA, Vector3 axisInA, bool useReferenceFrameA = false)Parameters
- rigidBodyARigidbodyComponent
- The rigid body a. 
- pivotInAVector3
- Pivot point in body a. 
- axisInAVector3
- Axis in body a. 
- useReferenceFrameAbool
- if set to - true[use reference frame a].
Returns
Exceptions
- Exception
- Cannot perform this action when the physics engine is set to CollisionsOnly or RigidBody must be valid 
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()OnSimulationBegin(SimulationArgs)
protected virtual void OnSimulationBegin(Simulation.SimulationArgs e)Parameters
OnSimulationEnd(SimulationArgs)
protected virtual void OnSimulationEnd(Simulation.SimulationArgs e)Parameters
Raycast(Vector3, Vector3, CollisionFilterGroups, CollisionFilterGroupFlags, bool, EFlags)
Raycasts and returns the closest hit
public HitResult Raycast(Vector3 from, Vector3 to, CollisionFilterGroups filterGroup = CollisionFilterGroups.DefaultFilter, CollisionFilterGroupFlags filterFlags = (CollisionFilterGroupFlags)-1, bool hitTriggers = false, EFlags eFlags = EFlags.None)Parameters
- fromVector3
- The starting point of this raycast 
- toVector3
- The end point of this raycast 
- filterGroupCollisionFilterGroups
- The collision group of this raycast 
- filterFlagsCollisionFilterGroupFlags
- The collision group that this raycast can collide with 
- hitTriggersbool
- Whether this test should collide with PhysicsTriggerComponentBase 
- eFlagsEFlags
- Flags that control how this ray test is performed 
Returns
- HitResult
- The result of this test 
Raycast(Vector3, Vector3, out HitResult, CollisionFilterGroups, CollisionFilterGroupFlags, bool, EFlags)
Raycasts, returns true when it hit something
public bool Raycast(Vector3 from, Vector3 to, out HitResult result, CollisionFilterGroups filterGroup = CollisionFilterGroups.DefaultFilter, CollisionFilterGroupFlags filterFlags = (CollisionFilterGroupFlags)-1, bool hitTriggers = false, EFlags eFlags = EFlags.None)Parameters
- fromVector3
- The starting point of this raycast 
- toVector3
- The end point of this raycast 
- resultHitResult
- Information about this test 
- filterGroupCollisionFilterGroups
- The collision group of this raycast 
- filterFlagsCollisionFilterGroupFlags
- The collision group that this raycast can collide with 
- hitTriggersbool
- Whether this test should collide with PhysicsTriggerComponentBase 
- eFlagsEFlags
- Flags that control how this ray test is performed 
Returns
- bool
- True if the test collided with an object in the simulation 
RaycastPenetrating(Vector3, Vector3, ICollection<HitResult>, CollisionFilterGroups, CollisionFilterGroupFlags, bool, EFlags)
Raycasts penetrating any shape the ray encounters. Filtering by CollisionGroup
public void RaycastPenetrating(Vector3 from, Vector3 to, ICollection<HitResult> resultsOutput, CollisionFilterGroups filterGroup = CollisionFilterGroups.DefaultFilter, CollisionFilterGroupFlags filterFlags = (CollisionFilterGroupFlags)-1, bool hitTriggers = false, EFlags eFlags = EFlags.None)Parameters
- fromVector3
- The starting point of this raycast 
- toVector3
- The end point of this raycast 
- resultsOutputICollection<HitResult>
- The collection to add intersections to 
- filterGroupCollisionFilterGroups
- The collision group of this raycast 
- filterFlagsCollisionFilterGroupFlags
- The collision group that this raycast can collide with 
- hitTriggersbool
- Whether this test should collide with PhysicsTriggerComponentBase 
- eFlagsEFlags
- Flags that control how this ray test is performed 
RemoveConstraint(Constraint)
Removes the constraint from the engine processing pipeline.
public void RemoveConstraint(Constraint constraint)Parameters
- constraintConstraint
- The constraint. 
Exceptions
- Exception
- Cannot perform this action when the physics engine is set to CollisionsOnly 
ShapeSweep(ColliderShape, Matrix, Matrix, CollisionFilterGroups, CollisionFilterGroupFlags, bool)
Performs a sweep test using a collider shape and returns the closest hit
public HitResult ShapeSweep(ColliderShape shape, Matrix from, Matrix to, CollisionFilterGroups filterGroup = CollisionFilterGroups.DefaultFilter, CollisionFilterGroupFlags filterFlags = (CollisionFilterGroupFlags)-1, bool hitTriggers = false)Parameters
- shapeColliderShape
- The shape used when testing collisions with colliders in the simulation 
- fromMatrix
- The starting point of this sweep 
- toMatrix
- The end point of this sweep 
- filterGroupCollisionFilterGroups
- The collision group of this shape sweep 
- filterFlagsCollisionFilterGroupFlags
- The collision group that this shape sweep can collide with 
- hitTriggersbool
- Whether this test should collide with PhysicsTriggerComponentBase 
Returns
- HitResult
- The result of this test 
Exceptions
- ArgumentException
- This kind of shape cannot be used for a ShapeSweep. 
ShapeSweepPenetrating(ColliderShape, Matrix, Matrix, ICollection<HitResult>, CollisionFilterGroups, CollisionFilterGroupFlags, bool)
Performs a sweep test using a collider shape and never stops until "to"
public void ShapeSweepPenetrating(ColliderShape shape, Matrix from, Matrix to, ICollection<HitResult> resultsOutput, CollisionFilterGroups filterGroup = CollisionFilterGroups.DefaultFilter, CollisionFilterGroupFlags filterFlags = (CollisionFilterGroupFlags)-1, bool hitTriggers = false)Parameters
- shapeColliderShape
- The shape against which colliders in the simulation will be tested 
- fromMatrix
- The starting point of this sweep 
- toMatrix
- The end point of this sweep 
- resultsOutputICollection<HitResult>
- The collection to add hit results to 
- filterGroupCollisionFilterGroups
- The collision group of this shape sweep 
- filterFlagsCollisionFilterGroupFlags
- The collision group that this shape sweep can collide with 
- hitTriggersbool
- Whether this test should collide with PhysicsTriggerComponentBase 
Exceptions
- ArgumentException
- This kind of shape cannot be used for a ShapeSweep. 
Events
PostTick
Called right after processing a tick of the physics simulation, this may never occur before many updates, or occur multiple times between updates depending on this Simulation properties
public event Simulation.SimulationTickEvent PostTickEvent Type
PreTick
Called right before processing a tick of the physics simulation, this may never occur before many updates, or occur multiple times between updates depending on this Simulation properties
public event Simulation.SimulationTickEvent PreTickEvent Type
SimulationBegin
Called before the physics simulation. This event might not be fired by the main thread.
[Obsolete("The simulation is not guaranteed to tick following this call, use PreTick instead. This is the same thing as Update")]
public event EventHandler<Simulation.SimulationArgs> SimulationBeginEvent Type
SimulationEnd
Called after the physics simulation. This event might not be fired by the main thread.
[Obsolete("The simulation is not guaranteed to have ticked before this call, use PostTick instead. This is the same thing as Update")]
public event EventHandler<Simulation.SimulationArgs> SimulationEnd