Aether.Physics2D  1.6
World Class Reference

The world class manages all physics entities, dynamic simulation, and asynchronous queries. More...

Collaboration diagram for World:

Public Member Functions

 World ()
 Initializes a new instance of the World class. More...
 
 World (Vector2 gravity)
 Initializes a new instance of the World class. More...
 
 World (IBroadPhase broadPhase)
 Initializes a new instance of the World class. More...
 
virtual void Add (Body body)
 Add a rigid body. Warning: This method is locked during callbacks. More...
 
virtual void Remove (Body body)
 Destroy a rigid body. Warning: This automatically deletes all associated shapes and joints. Warning: This method is locked during callbacks. More...
 
void Add (Joint joint)
 Create a joint to constrain bodies together. This may cause the connected bodies to cease colliding. Warning: This method is locked during callbacks. More...
 
void Remove (Joint joint)
 Destroy a joint. This may cause the connected bodies to begin colliding. Warning: This method is locked during callbacks. More...
 
void Step (TimeSpan dt)
 Take a time step. This performs collision detection, integration, and consraint solution. More...
 
void Step (TimeSpan dt, ref SolverIterations iterations)
 Take a time step. This performs collision detection, integration, and consraint solution. More...
 
void Step (float dt)
 Take a time step. This performs collision detection, integration, and consraint solution. Warning: This method is locked during callbacks. More...
 
void Step (float dt, ref SolverIterations iterations)
 Take a time step. This performs collision detection, integration, and consraint solution. Warning: This method is locked during callbacks. More...
 
void ClearForces ()
 Call this after you are done with time steps to clear the forces. You normally call this after each call to Step, unless you are performing sub-steps. By default, forces will be automatically cleared, so you don't need to call this function. More...
 
void QueryAABB (QueryReportFixtureDelegate callback, AABB aabb)
 Query the world for all fixtures that potentially overlap the provided AABB. More...
 
void QueryAABB (QueryReportFixtureDelegate callback, ref AABB aabb)
 Query the world for all fixtures that potentially overlap the provided AABB. More...
 
void RayCast (RayCastReportFixtureDelegate callback, Vector2 point1, Vector2 point2)
 Ray-cast the world for all fixtures in the path of the ray. Your callback controls whether you get the closest point, any point, or n-points. The ray-cast ignores shapes that contain the starting point. More...
 
void Add (Controller controller)
 Warning: This method is locked during callbacks. More...
 
void Remove (Controller controller)
 Warning: This method is locked during callbacks. More...
 
Fixture TestPoint (Vector2 point)
 
void ShiftOrigin (Vector2 newOrigin)
 
void Clear ()
 Warning: This method is locked during callbacks. More...
 
virtual Body CreateBody (Vector2 position=new Vector2(), float rotation=0, BodyType bodyType=BodyType.Static)
 
Body CreateEdge (Vector2 start, Vector2 end)
 
Body CreateChainShape (Vertices vertices, Vector2 position=new Vector2())
 
Body CreateLoopShape (Vertices vertices, Vector2 position=new Vector2())
 
Body CreateRectangle (float width, float height, float density, Vector2 position=new Vector2(), float rotation=0, BodyType bodyType=BodyType.Static)
 
Body CreateCircle (float radius, float density, Vector2 position=new Vector2(), BodyType bodyType=BodyType.Static)
 
Body CreateEllipse (float xRadius, float yRadius, int edges, float density, Vector2 position=new Vector2(), float rotation=0, BodyType bodyType=BodyType.Static)
 
Body CreatePolygon (Vertices vertices, float density, Vector2 position=new Vector2(), float rotation=0, BodyType bodyType=BodyType.Static)
 
Body CreateCompoundPolygon (List< Vertices > list, float density, Vector2 position=new Vector2(), float rotation=0, BodyType bodyType=BodyType.Static)
 
Body CreateGear (float radius, int numberOfTeeth, float tipPercentage, float toothHeight, float density, Vector2 position=new Vector2(), float rotation=0, BodyType bodyType=BodyType.Static)
 
Body CreateCapsule (float height, float topRadius, int topEdges, float bottomRadius, int bottomEdges, float density, Vector2 position=new Vector2(), float rotation=0, BodyType bodyType=BodyType.Static)
 
Body CreateCapsule (float height, float endRadius, float density, Vector2 position=new Vector2(), float rotation=0, BodyType bodyType=BodyType.Static)
 
Body CreateRoundedRectangle (float width, float height, float xRadius, float yRadius, int segments, float density, Vector2 position=new Vector2(), float rotation=0, BodyType bodyType=BodyType.Static)
 
Body CreateLineArc (float radians, int sides, float radius, bool closed=false, Vector2 position=new Vector2(), float rotation=0, BodyType bodyType=BodyType.Static)
 
Body CreateSolidArc (float density, float radians, int sides, float radius, Vector2 position=new Vector2(), float rotation=0, BodyType bodyType=BodyType.Static)
 
Path CreateChain (Vector2 start, Vector2 end, float linkWidth, float linkHeight, int numberOfLinks, float linkDensity, bool attachRopeJoint)
 Creates a chain. More...
 

Public Attributes

object Tag
 Set the user data. Use this to store your application specific data. More...
 
BodyDelegate BodyAdded
 Fires whenever a body has been added More...
 
BodyDelegate BodyRemoved
 Fires whenever a body has been removed More...
 
FixtureDelegate FixtureAdded
 Fires whenever a fixture has been added More...
 
FixtureDelegate FixtureRemoved
 Fires whenever a fixture has been removed More...
 
JointDelegate JointAdded
 Fires whenever a joint has been added More...
 
JointDelegate JointRemoved
 Fires whenever a joint has been removed More...
 
ControllerDelegate ControllerAdded
 Fires every time a controller is added to the World. More...
 
ControllerDelegate ControllerRemoved
 Fires every time a controlelr is removed form the World. More...
 
readonly ControllerCollection ControllerList
 
readonly ContactManager ContactManager
 Get the contact manager for testing. More...
 
readonly BodyCollection BodyList
 Get the world body list. More...
 
readonly JointCollection JointList
 Get the world joint list. More...
 

Properties

TimeSpan UpdateTime [get]
 
TimeSpan ContinuousPhysicsTime [get]
 
TimeSpan ControllersUpdateTime [get]
 
TimeSpan AddRemoveTime [get]
 
TimeSpan NewContactsTime [get]
 
TimeSpan ContactsUpdateTime [get]
 
TimeSpan SolveUpdateTime [get]
 
int ProxyCount [get]
 Get the number of broad-phase proxies. More...
 
int ContactCount [get]
 Get the number of contacts (each may have 0 or more contact points). More...
 
Vector2 Gravity [get, set]
 Change the global gravity vector. More...
 
bool IsLocked [get]
 Is the world locked (in the middle of a time step). More...
 
ContactListHead ContactList [get]
 Get the world contact list. ContactList is the head of a circular linked list. Use Contact.Next to get the next contact in the world list. A contact equal to ContactList indicates the end of the list. More...
 
bool Enabled [get, set]
 If false, the whole simulation stops. It still processes added and removed geometries. More...
 
Island Island [get]
 

Detailed Description

The world class manages all physics entities, dynamic simulation, and asynchronous queries.

Constructor & Destructor Documentation

◆ World() [1/3]

World ( )

Initializes a new instance of the World class.

◆ World() [2/3]

World ( Vector2  gravity)

Initializes a new instance of the World class.

Parameters
gravityThe gravity.

◆ World() [3/3]

World ( IBroadPhase  broadPhase)

Initializes a new instance of the World class.

Member Function Documentation

◆ Add() [1/3]

virtual void Add ( Body  body)
virtual

Add a rigid body. Warning: This method is locked during callbacks.

Exceptions
System.InvalidOperationExceptionThrown when the world is Locked/Stepping.

◆ Add() [2/3]

void Add ( Controller  controller)

Warning: This method is locked during callbacks.

Exceptions
System.InvalidOperationExceptionThrown when the world is Locked/Stepping.

◆ Add() [3/3]

void Add ( Joint  joint)

Create a joint to constrain bodies together. This may cause the connected bodies to cease colliding. Warning: This method is locked during callbacks.

Parameters
jointThe joint.
Exceptions
System.InvalidOperationExceptionThrown when the world is Locked/Stepping.

◆ Clear()

void Clear ( )

Warning: This method is locked during callbacks.

Exceptions
System.InvalidOperationExceptionThrown when the world is Locked/Stepping.

◆ ClearForces()

void ClearForces ( )

Call this after you are done with time steps to clear the forces. You normally call this after each call to Step, unless you are performing sub-steps. By default, forces will be automatically cleared, so you don't need to call this function.

◆ CreateChain()

Path CreateChain ( Vector2  start,
Vector2  end,
float  linkWidth,
float  linkHeight,
int  numberOfLinks,
float  linkDensity,
bool  attachRopeJoint 
)

Creates a chain.

Parameters
worldThe world.
startThe start.
endThe end.
linkWidthThe width.
linkHeightThe height.
numberOfLinksThe number of links.
linkDensityThe link density.
attachRopeJointCreates a rope joint between start and end. This enforces the length of the rope. Said in another way: it makes the rope less bouncy.
Returns

◆ QueryAABB() [1/2]

void QueryAABB ( QueryReportFixtureDelegate  callback,
AABB  aabb 
)

Query the world for all fixtures that potentially overlap the provided AABB.

Inside the callback: Return true: Continues the query Return false: Terminate the query

Parameters
callbackA user implemented callback class.
aabbThe aabb query box.

◆ QueryAABB() [2/2]

void QueryAABB ( QueryReportFixtureDelegate  callback,
ref AABB  aabb 
)

Query the world for all fixtures that potentially overlap the provided AABB.

Inside the callback: Return true: Continues the query Return false: Terminate the query

Parameters
callbackA user implemented callback class.
aabbThe aabb query box.

◆ RayCast()

void RayCast ( RayCastReportFixtureDelegate  callback,
Vector2  point1,
Vector2  point2 
)

Ray-cast the world for all fixtures in the path of the ray. Your callback controls whether you get the closest point, any point, or n-points. The ray-cast ignores shapes that contain the starting point.

Inside the callback: return -1: ignore this fixture and continue return 0: terminate the ray cast return fraction: clip the ray to this point return 1: don't clip the ray and continue

Parameters
callbackA user implemented callback class.
point1The ray starting point.
point2The ray ending point.

◆ Remove() [1/3]

virtual void Remove ( Body  body)
virtual

Destroy a rigid body. Warning: This automatically deletes all associated shapes and joints. Warning: This method is locked during callbacks.

Parameters
bodyThe body.
Exceptions
System.InvalidOperationExceptionThrown when the world is Locked/Stepping.

◆ Remove() [2/3]

void Remove ( Controller  controller)

Warning: This method is locked during callbacks.

Exceptions
System.InvalidOperationExceptionThrown when the world is Locked/Stepping.

◆ Remove() [3/3]

void Remove ( Joint  joint)

Destroy a joint. This may cause the connected bodies to begin colliding. Warning: This method is locked during callbacks.

Parameters
jointThe joint.
Exceptions
System.InvalidOperationExceptionThrown when the world is Locked/Stepping.

◆ ShiftOrigin()

void ShiftOrigin ( Vector2  newOrigin)

Shift the world origin. Useful for large worlds. The body shift formula is: position -= newOrigin

Parameters
newOriginthe new origin with respect to the old origin Warning: Calling this method mid-update might cause a crash.

◆ Step() [1/4]

void Step ( float  dt)

Take a time step. This performs collision detection, integration, and consraint solution. Warning: This method is locked during callbacks.

Parameters
dtThe amount of time to simulate in seconds, this should not vary.
Exceptions
System.InvalidOperationExceptionThrown when the world is Locked/Stepping.

◆ Step() [2/4]

void Step ( float  dt,
ref SolverIterations  iterations 
)

Take a time step. This performs collision detection, integration, and consraint solution. Warning: This method is locked during callbacks.

Parameters
dtThe amount of time to simulate in seconds, this should not vary.
Exceptions
System.InvalidOperationExceptionThrown when the world is Locked/Stepping.

◆ Step() [3/4]

void Step ( TimeSpan  dt)

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

Parameters
dtThe amount of time to simulate, this should not vary.

◆ Step() [4/4]

void Step ( TimeSpan  dt,
ref SolverIterations  iterations 
)

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

Parameters
dtThe amount of time to simulate, this should not vary.

Member Data Documentation

◆ BodyAdded

BodyDelegate BodyAdded

Fires whenever a body has been added

◆ BodyList

readonly BodyCollection BodyList

Get the world body list.

The head of the world body list.

◆ BodyRemoved

BodyDelegate BodyRemoved

Fires whenever a body has been removed

◆ ContactManager

Get the contact manager for testing.

The contact manager.

◆ ControllerAdded

ControllerDelegate ControllerAdded

Fires every time a controller is added to the World.

◆ ControllerRemoved

ControllerDelegate ControllerRemoved

Fires every time a controlelr is removed form the World.

◆ FixtureAdded

FixtureDelegate FixtureAdded

Fires whenever a fixture has been added

◆ FixtureRemoved

FixtureDelegate FixtureRemoved

Fires whenever a fixture has been removed

◆ JointAdded

JointDelegate JointAdded

Fires whenever a joint has been added

◆ JointList

readonly JointCollection JointList

Get the world joint list.

The joint list.

◆ JointRemoved

JointDelegate JointRemoved

Fires whenever a joint has been removed

◆ Tag

object Tag

Set the user data. Use this to store your application specific data.

The user data.

Property Documentation

◆ ContactCount

int ContactCount
get

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

The contact count.

◆ ContactList

ContactListHead ContactList
get

Get the world contact list. ContactList is the head of a circular linked list. Use Contact.Next to get the next contact in the world list. A contact equal to ContactList indicates the end of the list.

The head of the world contact list.

for (Contact c = World.ContactList.Next; c != World..ContactList; c = c.Next)

◆ Enabled

bool Enabled
getset

If false, the whole simulation stops. It still processes added and removed geometries.

◆ Gravity

Vector2 Gravity
getset

Change the global gravity vector.

The gravity.

◆ IsLocked

bool IsLocked
get

Is the world locked (in the middle of a time step).


◆ ProxyCount

int ProxyCount
get

Get the number of broad-phase proxies.

The proxy count.


The documentation for this class was generated from the following files: