C# Class Jitter.JitterWorld

This class brings 'dynamics' and 'collisions' together. It handles all bodies and constraints.
显示文件 Open project: nuclearpidgeon/graphicsproj2 Class Usage Examples

Public Methods

Method Description
AddBody ( RigidBody body ) : void

Adds a RigidBody to the world.

AddBody ( SoftBody body ) : void
AddConstraint ( Constraint constraint ) : void

Add a Constraint to the world.

Clear ( ) : void

Removes all objects from the world and removes all memory cached objects.

JitterWorld ( CollisionSystem collision ) : System

Create a new instance of the World class.

RemoveBody ( RigidBody body ) : bool

Removes a RigidBody from the world.

RemoveBody ( SoftBody body ) : bool
RemoveConstraint ( Constraint constraint ) : bool

Add a Constraint to the world. Fast, O(1).

ResetResourcePools ( ) : void

In Jitter many objects get added to stacks after they were used. If a new object is needed the old object gets removed from the stack and is reused. This saves some time and also garbage collections. Calling this method removes all cached objects from all stacks.

SetDampingFactors ( float angularDamping, float linearDamping ) : void

Every computation Step the angular and linear velocity of a RigidBody gets multiplied by this value.

SetInactivityThreshold ( float angularVelocity, float linearVelocity, float time ) : void

Sets parameters for the RigidBody deactivation process. If the bodies angular velocity is less than the angular velocity threshold and its linear velocity is lower then the linear velocity threshold for a specific time the body gets deactivated. A body can be reactivated by setting RigidBody.IsActive to true. A body gets also automatically reactivated if another moving object hits it or the CollisionIsland the object is in gets activated.

SetIterations ( int iterations, int smallIterations ) : void

Jitter uses an iterativ approach to solve collisions and contacts. You can set the number of iterations Jitter should do. In general the more iterations the more stable a simulation gets but also costs computation time.

The number of iterations for collision and contact should be between 3 - 30. More iterations means more stability and also a longer calculation time.

Step ( float timestep, bool multithread ) : void

Integrates the whole world a timestep further in time.

Step ( float totalTime, bool multithread, float timestep, int maxSteps ) : void

Integrates the whole world several fixed timestep further in time.

Private Methods

Method Description
ArbiterCallback ( object obj ) : void
CheckDeactivation ( ) : void
CollisionDetected ( RigidBody body1, RigidBody body2, Jitter.LinearMath.JVector point1, Jitter.LinearMath.JVector point2, Jitter.LinearMath.JVector normal, float penetration ) : void
HandleArbiter ( int iterations, bool multiThreaded ) : void
Integrate ( bool multithread ) : void
IntegrateCallback ( object obj ) : void
IntegrateForces ( ) : void
RemoveBody ( RigidBody body, bool removeMassPoints ) : bool
UpdateArbiterContacts ( Arbiter arbiter ) : void
UpdateContacts ( ) : void

Method Details

AddBody() public method

Adds a RigidBody to the world.
public AddBody ( RigidBody body ) : void
body RigidBody The body which should be added.
return void

AddBody() public method

public AddBody ( SoftBody body ) : void
body Jitter.Dynamics.SoftBody
return void

AddConstraint() public method

Add a Constraint to the world.
public AddConstraint ( Constraint constraint ) : void
constraint Constraint The constraint which should be removed.
return void

Clear() public method

Removes all objects from the world and removes all memory cached objects.
public Clear ( ) : void
return void

JitterWorld() public method

Create a new instance of the World class.
public JitterWorld ( CollisionSystem collision ) : System
collision Jitter.Collision.CollisionSystem The collisionSystem which is used to detect /// collisions. See for example: /// or . ///
return System

RemoveBody() public method

Removes a RigidBody from the world.
public RemoveBody ( RigidBody body ) : bool
body RigidBody The body which should be removed.
return bool

RemoveBody() public method

public RemoveBody ( SoftBody body ) : bool
body Jitter.Dynamics.SoftBody
return bool

RemoveConstraint() public method

Add a Constraint to the world. Fast, O(1).
public RemoveConstraint ( Constraint constraint ) : bool
constraint Constraint The constraint which should be added.
return bool

ResetResourcePools() public method

In Jitter many objects get added to stacks after they were used. If a new object is needed the old object gets removed from the stack and is reused. This saves some time and also garbage collections. Calling this method removes all cached objects from all stacks.
public ResetResourcePools ( ) : void
return void

SetDampingFactors() public method

Every computation Step the angular and linear velocity of a RigidBody gets multiplied by this value.
public SetDampingFactors ( float angularDamping, float linearDamping ) : void
angularDamping float The factor multiplied with the angular velocity. /// The default value is 0.85.
linearDamping float The factor multiplied with the linear velocity. /// The default value is 0.85
return void

SetInactivityThreshold() public method

Sets parameters for the RigidBody deactivation process. If the bodies angular velocity is less than the angular velocity threshold and its linear velocity is lower then the linear velocity threshold for a specific time the body gets deactivated. A body can be reactivated by setting RigidBody.IsActive to true. A body gets also automatically reactivated if another moving object hits it or the CollisionIsland the object is in gets activated.
public SetInactivityThreshold ( float angularVelocity, float linearVelocity, float time ) : void
angularVelocity float The threshold value for the angular velocity. The default value /// is 0.1.
linearVelocity float The threshold value for the linear velocity. The default value /// is 0.1
time float The threshold value for the time in seconds. The default value is 2.
return void

SetIterations() public method

Jitter uses an iterativ approach to solve collisions and contacts. You can set the number of iterations Jitter should do. In general the more iterations the more stable a simulation gets but also costs computation time.
The number of iterations for collision and contact should be between 3 - 30. More iterations means more stability and also a longer calculation time.
public SetIterations ( int iterations, int smallIterations ) : void
iterations int The number of contact iterations. Default value 10.
smallIterations int The number of contact iteration used for smaller (two and three constraint) systems. Default value 4.
return void

Step() public method

Integrates the whole world a timestep further in time.
public Step ( float timestep, bool multithread ) : void
timestep float The timestep in seconds. /// It should be small as possible to keep the simulation stable. /// The physics simulation shouldn't run slower than 60fps. /// (timestep=1/60).
multithread bool If true the engine uses several threads to /// integrate the world. This is faster on multicore CPUs.
return void

Step() public method

Integrates the whole world several fixed timestep further in time.
public Step ( float totalTime, bool multithread, float timestep, int maxSteps ) : void
totalTime float The time to integrate.
multithread bool If true the engine uses several threads to /// integrate the world. This is faster on multicore CPUs.
timestep float The timestep in seconds. /// It should be small as possible to keep the simulation stable. /// The physics simulation shouldn't run slower than 60fps. /// (timestep=1/60).
maxSteps int The maximum number of substeps. After that Jitter gives up /// to keep up with the given totalTime.
return void