C# Класс Box2DX.Dynamics.World

The world class manages all physics entities, dynamic simulation, and asynchronous queries.
Наследование: IDisposable
Показать файл Открыть проект Примеры использования класса

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

Метод Описание
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.

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

Метод Описание
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

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

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

public AddController ( Controllers def ) : Controller
def Controllers
Результат Box2DX.Dynamics.Controllers.Controller

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

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

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

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

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

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

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

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

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

Destruct the world. All physics entities are destroyed.
public Dispose ( ) : void
Результат void

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

Get the number of bodies.
public GetBodyCount ( ) : int
Результат int

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

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

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

Get the number of contacts (each may have 0 or more contact points).
public GetContactCount ( ) : int
Результат int

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

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

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

Get the number joints.
public GetJointCount ( ) : int
Результат int

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

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

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

Get the number of broad-phase pairs.
public GetPairCount ( ) : int
Результат int

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

Get the number of broad-phase proxies.
public GetProxyCount ( ) : int
Результат int

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

public InRange ( AABB aabb ) : bool
aabb Box2DX.Collision.AABB
Результат bool

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

public Query ( AABB aabb, Shape shapes, int maxCount ) : int
aabb Box2DX.Collision.AABB
shapes Box2DX.Collision.Shape
maxCount int
Результат int

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

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

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

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

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

Re-filter a shape. This re-runs contact filtering on a shape.
public Refilter ( Shape shape ) : void
shape Shape
Результат void

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

public RemoveController ( Controllers controller ) : void
controller Controllers
Результат void

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

Register a broad-phase boundary listener.
public SetBoundaryListener ( BoundaryListener listener ) : void
listener BoundaryListener
Результат void

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

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

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

Register a contact event listener
public SetContactListener ( ContactListener listener ) : void
listener ContactListener
Результат void

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

Enable/disable continuous physics. For testing.
public SetContinuousPhysics ( bool flag ) : void
flag bool
Результат void

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

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

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

Register a destruction listener.
public SetDestructionListener ( DestructionListener listener ) : void
listener DestructionListener
Результат void

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

Enable/disable warm starting. For testing.
public SetWarmStarting ( bool flag ) : void
flag bool
Результат void

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

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

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

Perform validation of internal data structures.
public Validate ( ) : void
Результат void

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

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