C# Class Box2DX.Dynamics.World

The world class manages all physics entities, dynamic simulation, and asynchronous queries.
Inheritance: IDisposable
Show file Open project: danielpcox/Crisis-at-Swiss-Station Class Usage Examples

Public Methods

Method Description
AddController ( Controllers def ) : Controller
CreateBody ( BodyDef def ) : Body

Create a rigid body given a definition. No reference to the definition is retained. @warning This function is locked during callbacks.

CreateJoint ( JointDef def ) : Joint

Create a joint to constrain bodies together. No reference to the definition is retained. This may cause the connected bodies to cease colliding. @warning This function is locked during callbacks.

DestroyBody ( Body b ) : void

Destroy a rigid body given a definition. No reference to the definition is retained. This function is locked during callbacks. @warning This automatically deletes all associated shapes and joints. @warning This function is locked during callbacks.

DestroyJoint ( Joint j ) : void

Destroy a joint. This may cause the connected bodies to begin colliding. @warning This function is locked during callbacks.

Dispose ( ) : void

Destruct the world. All physics entities are destroyed.

GetBodyCount ( ) : int

Get the number of bodies.

GetBodyList ( ) : Body

Get the world body list. With the returned body, use Body.GetNext to get the next body in the world list. A null body indicates the end of the list.

GetContactCount ( ) : int

Get the number of contacts (each may have 0 or more contact points).

GetGroundBody ( ) : Body

The world provides a single static ground body with no collision shapes. You can use this to simplify the creation of joints and static shapes.

GetJointCount ( ) : int

Get the number joints.

GetJointList ( ) : Joint

Get the world joint list. With the returned joint, use Joint.GetNext to get the next joint in the world list. A null joint indicates the end of the list.

GetPairCount ( ) : int

Get the number of broad-phase pairs.

GetProxyCount ( ) : int

Get the number of broad-phase proxies.

InRange ( AABB aabb ) : bool
Query ( AABB aabb, Shape shapes, int maxCount ) : int
Raycast ( Segment segment, Shape shapes, int maxCount, bool solidShapes, object userData ) : int

Query the world for all shapes that intersect a given segment. You provide a shap pointer buffer of specified size. The number of shapes found is returned, and the buffer is filled in order of intersection.

RaycastOne ( Segment segment, float &lambda, Vec2 &normal, bool solidShapes, object userData ) : Shape

Performs a raycast as with Raycast, finding the first intersecting shape.

Refilter ( Shape shape ) : void

Re-filter a shape. This re-runs contact filtering on a shape.

RemoveController ( Controllers controller ) : void
SetBoundaryListener ( BoundaryListener listener ) : void

Register a broad-phase boundary listener.

SetContactFilter ( ContactFilter filter ) : void

Register a contact filter to provide specific control over collision. Otherwise the default filter is used (b2_defaultFilter).

SetContactListener ( ContactListener listener ) : void

Register a contact event listener

SetContinuousPhysics ( bool flag ) : void

Enable/disable continuous physics. For testing.

SetDebugDraw ( DebugDraw debugDraw ) : void

Register a routine for debug drawing. The debug draw functions are called inside the World.Step method, so make sure your renderer is ready to consume draw commands when you call Step().

SetDestructionListener ( DestructionListener listener ) : void

Register a destruction listener.

SetWarmStarting ( bool flag ) : void

Enable/disable warm starting. For testing.

Step ( float dt, int velocityIterations, int positionIteration ) : void

Take a time step. This performs collision detection, integration, and constraint solution.

Validate ( ) : void

Perform validation of internal data structures.

World ( AABB worldAABB, Vec2 gravity, bool doSleep ) : System

Construct a world object.

Private Methods

Method Description
DrawDebugData ( ) : void
DrawJoint ( Joint joint ) : void
DrawShape ( Shape shape, XForm xf, Color color, bool core ) : void
RaycastSortKey ( object data ) : float
Solve ( TimeStep step ) : void
SolveTOI ( TimeStep step ) : void

Method Details

AddController() public method

public AddController ( Controllers def ) : Controller
def Controllers
return Box2DX.Dynamics.Controllers.Controller

CreateBody() public method

Create a rigid body given a definition. No reference to the definition is retained. @warning This function is locked during callbacks.
public CreateBody ( BodyDef def ) : Body
def BodyDef
return Body

CreateJoint() public method

Create a joint to constrain bodies together. No reference to the definition is retained. This may cause the connected bodies to cease colliding. @warning This function is locked during callbacks.
public CreateJoint ( JointDef def ) : Joint
def JointDef
return Joint

DestroyBody() public method

Destroy a rigid body given a definition. No reference to the definition is retained. This function is locked during callbacks. @warning This automatically deletes all associated shapes and joints. @warning This function is locked during callbacks.
public DestroyBody ( Body b ) : void
b Body
return void

DestroyJoint() public method

Destroy a joint. This may cause the connected bodies to begin colliding. @warning This function is locked during callbacks.
public DestroyJoint ( Joint j ) : void
j Joint
return void

Dispose() public method

Destruct the world. All physics entities are destroyed.
public Dispose ( ) : void
return void

GetBodyCount() public method

Get the number of bodies.
public GetBodyCount ( ) : int
return int

GetBodyList() public method

Get the world body list. With the returned body, use Body.GetNext to get the next body in the world list. A null body indicates the end of the list.
public GetBodyList ( ) : Body
return Body

GetContactCount() public method

Get the number of contacts (each may have 0 or more contact points).
public GetContactCount ( ) : int
return int

GetGroundBody() public method

The world provides a single static ground body with no collision shapes. You can use this to simplify the creation of joints and static shapes.
public GetGroundBody ( ) : Body
return Body

GetJointCount() public method

Get the number joints.
public GetJointCount ( ) : int
return int

GetJointList() public method

Get the world joint list. With the returned joint, use Joint.GetNext to get the next joint in the world list. A null joint indicates the end of the list.
public GetJointList ( ) : Joint
return Joint

GetPairCount() public method

Get the number of broad-phase pairs.
public GetPairCount ( ) : int
return int

GetProxyCount() public method

Get the number of broad-phase proxies.
public GetProxyCount ( ) : int
return int

InRange() public method

public InRange ( AABB aabb ) : bool
aabb Box2DX.Collision.AABB
return bool

Query() public method

public Query ( AABB aabb, Shape shapes, int maxCount ) : int
aabb Box2DX.Collision.AABB
shapes Box2DX.Collision.Shape
maxCount int
return int

Raycast() public method

Query the world for all shapes that intersect a given segment. You provide a shap pointer buffer of specified size. The number of shapes found is returned, and the buffer is filled in order of intersection.
public Raycast ( Segment segment, Shape shapes, int maxCount, bool solidShapes, object userData ) : int
segment Segment Defines the begin and end point of the ray cast, from p1 to p2. /// Use Segment.Extend to create (semi-)infinite rays.
shapes Shape A user allocated shape pointer array of size maxCount (or greater).
maxCount int The capacity of the shapes array.
solidShapes bool Determines if shapes that the ray starts in are counted as hits.
userData object Passed through the worlds contact filter, with method RayCollide. This can be used to filter valid shapes.
return int

RaycastOne() public method

Performs a raycast as with Raycast, finding the first intersecting shape.
public RaycastOne ( Segment segment, float &lambda, Vec2 &normal, bool solidShapes, object userData ) : Shape
segment Segment Defines the begin and end point of the ray cast, from p1 to p2. /// Use Segment.Extend to create (semi-)infinite rays.
lambda float Returns the hit fraction. You can use this to compute the contact point /// p = (1 - lambda) * segment.p1 + lambda * segment.p2.
normal Vec2 Returns the normal at the contact point. If there is no intersection, the normal is not set.
solidShapes bool Determines if shapes that the ray starts in are counted as hits.
userData object
return Shape

Refilter() public method

Re-filter a shape. This re-runs contact filtering on a shape.
public Refilter ( Shape shape ) : void
shape Shape
return void

RemoveController() public method

public RemoveController ( Controllers controller ) : void
controller Controllers
return void

SetBoundaryListener() public method

Register a broad-phase boundary listener.
public SetBoundaryListener ( BoundaryListener listener ) : void
listener BoundaryListener
return void

SetContactFilter() public method

Register a contact filter to provide specific control over collision. Otherwise the default filter is used (b2_defaultFilter).
public SetContactFilter ( ContactFilter filter ) : void
filter ContactFilter
return void

SetContactListener() public method

Register a contact event listener
public SetContactListener ( ContactListener listener ) : void
listener ContactListener
return void

SetContinuousPhysics() public method

Enable/disable continuous physics. For testing.
public SetContinuousPhysics ( bool flag ) : void
flag bool
return void

SetDebugDraw() public method

Register a routine for debug drawing. The debug draw functions are called inside the World.Step method, so make sure your renderer is ready to consume draw commands when you call Step().
public SetDebugDraw ( DebugDraw debugDraw ) : void
debugDraw DebugDraw
return void

SetDestructionListener() public method

Register a destruction listener.
public SetDestructionListener ( DestructionListener listener ) : void
listener DestructionListener
return void

SetWarmStarting() public method

Enable/disable warm starting. For testing.
public SetWarmStarting ( bool flag ) : void
flag bool
return void

Step() public method

Take a time step. This performs collision detection, integration, and constraint solution.
public Step ( float dt, int velocityIterations, int positionIteration ) : void
dt float The amount of time to simulate, this should not vary.
velocityIterations int
positionIteration int
return void

Validate() public method

Perform validation of internal data structures.
public Validate ( ) : void
return void

World() public method

Construct a world object.
public World ( AABB worldAABB, Vec2 gravity, bool doSleep ) : System
worldAABB AABB A bounding box that completely encompasses all your shapes.
gravity Vec2 The world gravity vector.
doSleep bool Improve performance by not simulating inactive bodies.
return System