C# Класс Jitter.World

This class brings 'dynamics' and 'collisions' together. It handles all bodies and constraints.
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
AddBody ( RigidBody body ) : void

Adds a RigidBody to the world.

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

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

Clear ( ) : void

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

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.

World ( CollisionSystem collision ) : System

Create a new instance of the World class.

Приватные методы

Метод Описание
ArbiterCallback ( object obj ) : void
BuildIslands ( ) : 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
MergeIslands ( RigidBody body0, RigidBody body1 ) : void
RemoveBody ( RigidBody body, bool removeMassPoints ) : bool
UpdateArbiterContacts ( Arbiter arbiter ) : void
UpdateContacts ( ) : void

Описание методов

AddBody() публичный Метод

Adds a RigidBody to the world.
public AddBody ( RigidBody body ) : void
body RigidBody The body which should be added.
Результат void

AddBody() публичный Метод

public AddBody ( SoftBody body ) : void
body Jitter.Dynamics.SoftBody
Результат void

AddConstraint() публичный Метод

Add a Constraint to the world. Fast, O(1).
public AddConstraint ( Constraint constraint ) : void
constraint Constraint The constraint which should be removed.
Результат void

Clear() публичный Метод

Removes all objects from the world and removes all memory cached objects.
public Clear ( ) : void
Результат void

RemoveBody() публичный Метод

Removes a RigidBody from the world.
public RemoveBody ( RigidBody body ) : bool
body RigidBody The body which should be removed.
Результат bool

RemoveBody() публичный Метод

public RemoveBody ( SoftBody body ) : bool
body Jitter.Dynamics.SoftBody
Результат bool

RemoveConstraint() публичный Метод

Add a Constraint to the world. Fast, O(1).
public RemoveConstraint ( Constraint constraint ) : bool
constraint Constraint The constraint which should be added.
Результат bool

ResetResourcePools() публичный Метод

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
Результат void

SetDampingFactors() публичный Метод

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
Результат void

SetInactivityThreshold() публичный Метод

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.
Результат void

SetIterations() публичный Метод

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.
Результат void

Step() публичный Метод

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.
Результат void

Step() публичный Метод

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.
Результат void

World() публичный Метод

Create a new instance of the World class.
public World ( CollisionSystem collision ) : System
collision Jitter.Collision.CollisionSystem The collisionSystem which is used to detect /// collisions. See for example: /// or . ///
Результат System