Ctrl+K

World

Declaration

public class tainicom.Aether.Physics2D.Dynamics.World

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

Constructors

World

Initializes a new instance of the World class.

void World()

World

Initializes a new instance of the World class.

void World(Vector2 gravity)

Parameters:

Name Type Description
gravity Strawberry.Math.Vector2 The gravity.

World

Initializes a new instance of the World class.

void World(IBroadPhase broadPhase)

Parameters:

Name Type Description
broadPhase tainicom.Aether.Physics2D.Collision.IBroadPhase

Properties

UpdateTime

TimeSpan UpdateTime { get }

ContinuousPhysicsTime

TimeSpan ContinuousPhysicsTime { get }

ControllersUpdateTime

TimeSpan ControllersUpdateTime { get }

AddRemoveTime

TimeSpan AddRemoveTime { get }

NewContactsTime

TimeSpan NewContactsTime { get }

ContactsUpdateTime

TimeSpan ContactsUpdateTime { get }

SolveUpdateTime

TimeSpan SolveUpdateTime { get }

ProxyCount

Get the number of broad-phase proxies.

int ProxyCount { get }

Value: The proxy count.

ContactCount

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

int ContactCount { get }

Value: The contact count.

Gravity

Change the global gravity vector.

Vector2 Gravity { get set }

Value: The gravity.

IsLocked

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

bool IsLocked { get }

ContactList

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.

ContactListHead ContactList { get }

Value: The head of the world contact list.

Enabled

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

bool Enabled { get set }

Island

Island Island { get }

Fields

Tag

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

object Tag

Value: The user data.

BodyAdded

Fires whenever a body has been added

BodyDelegate BodyAdded

BodyRemoved

Fires whenever a body has been removed

BodyDelegate BodyRemoved

FixtureAdded

Fires whenever a fixture has been added

FixtureDelegate FixtureAdded

FixtureRemoved

Fires whenever a fixture has been removed

FixtureDelegate FixtureRemoved

JointAdded

Fires whenever a joint has been added

JointDelegate JointAdded

JointRemoved

Fires whenever a joint has been removed

JointDelegate JointRemoved

ControllerAdded

Fires every time a controller is added to the World.

ControllerDelegate ControllerAdded

ControllerRemoved

Fires every time a controlelr is removed form the World.

ControllerDelegate ControllerRemoved

ControllerList

ControllerCollection ControllerList

ContactManager

Get the contact manager for testing.

ContactManager ContactManager

Value: The contact manager.

BodyList

Get the world body list.

BodyCollection BodyList

Value: The head of the world body list.

JointList

Get the world joint list.

JointCollection JointList

Value: The joint list.

Methods

Add virtual

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

void Add(Body body)

Parameters:

Name Type Description
body tainicom.Aether.Physics2D.Dynamics.Body

Exceptions:

  • System.InvalidOperationException — Thrown when the world is Locked/Stepping.

Remove virtual

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

void Remove(Body body)

Parameters:

Name Type Description
body tainicom.Aether.Physics2D.Dynamics.Body The body.

Exceptions:

  • System.InvalidOperationException — Thrown when the world is Locked/Stepping.

Add

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

void Add(Joint joint)

Parameters:

Name Type Description
joint tainicom.Aether.Physics2D.Dynamics.Joints.Joint The joint.

Exceptions:

  • System.InvalidOperationException — Thrown when the world is Locked/Stepping.

Remove

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

void Remove(Joint joint)

Parameters:

Name Type Description
joint tainicom.Aether.Physics2D.Dynamics.Joints.Joint The joint.

Exceptions:

  • System.InvalidOperationException — Thrown when the world is Locked/Stepping.

Step

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

void Step(TimeSpan dt)

Parameters:

Name Type Description
dt System.TimeSpan The amount of time to simulate, this should not vary.

Step

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

void Step(TimeSpan dt, ref SolverIterations iterations)

Parameters:

Name Type Description
dt System.TimeSpan The amount of time to simulate, this should not vary.
iterations ref tainicom.Aether.Physics2D.Dynamics.SolverIterations

Step

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

void Step(float dt)

Parameters:

Name Type Description
dt System.Single The amount of time to simulate in seconds, this should not vary.

Exceptions:

  • System.InvalidOperationException — Thrown when the world is Locked/Stepping.

Step

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

void Step(float dt, ref SolverIterations iterations)

Parameters:

Name Type Description
dt System.Single The amount of time to simulate in seconds, this should not vary.
iterations ref tainicom.Aether.Physics2D.Dynamics.SolverIterations

Exceptions:

  • System.InvalidOperationException — Thrown when the world is Locked/Stepping.

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.

void ClearForces()

QueryAABB

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

void QueryAABB(QueryReportFixtureDelegate callback, AABB aabb)

Parameters:

Name Type Description
callback tainicom.Aether.Physics2D.Dynamics.QueryReportFixtureDelegate A user implemented callback class.
aabb tainicom.Aether.Physics2D.Collision.AABB The aabb query box.

QueryAABB

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

void QueryAABB(QueryReportFixtureDelegate callback, ref AABB aabb)

Parameters:

Name Type Description
callback tainicom.Aether.Physics2D.Dynamics.QueryReportFixtureDelegate A user implemented callback class.
aabb ref tainicom.Aether.Physics2D.Collision.AABB The aabb query box.

RayCast

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

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

Parameters:

Name Type Description
callback tainicom.Aether.Physics2D.Dynamics.RayCastReportFixtureDelegate A user implemented callback class.
point1 Strawberry.Math.Vector2 The ray starting point.
point2 Strawberry.Math.Vector2 The ray ending point.

Add

Warning: This method is locked during callbacks.

void Add(Controller controller)

Parameters:

Name Type Description
controller tainicom.Aether.Physics2D.Controllers.Controller

Exceptions:

  • System.InvalidOperationException — Thrown when the world is Locked/Stepping.

Remove

Warning: This method is locked during callbacks.

void Remove(Controller controller)

Parameters:

Name Type Description
controller tainicom.Aether.Physics2D.Controllers.Controller

Exceptions:

  • System.InvalidOperationException — Thrown when the world is Locked/Stepping.

TestPoint

Fixture TestPoint(Vector2 point)

Parameters:

Name Type Description
point Strawberry.Math.Vector2

ShiftOrigin

void ShiftOrigin(Vector2 newOrigin)

Parameters:

Name Type Description
newOrigin Strawberry.Math.Vector2

Clear

Warning: This method is locked during callbacks.

void Clear()

Exceptions:

  • System.InvalidOperationException — Thrown when the world is Locked/Stepping.

CreateBody virtual

Body CreateBody(Vector2 position = null, float rotation = 0, BodyType bodyType = 0)

Parameters:

Name Type Description
position Strawberry.Math.Vector2 = null
rotation System.Single = 0
bodyType tainicom.Aether.Physics2D.Dynamics.BodyType = 0

CreateEdge

Body CreateEdge(Vector2 start, Vector2 end)

Parameters:

Name Type Description
start Strawberry.Math.Vector2
end Strawberry.Math.Vector2

CreateChainShape

Body CreateChainShape(Vertices vertices, Vector2 position = null)

Parameters:

Name Type Description
vertices tainicom.Aether.Physics2D.Common.Vertices
position Strawberry.Math.Vector2 = null

CreateLoopShape

Body CreateLoopShape(Vertices vertices, Vector2 position = null)

Parameters:

Name Type Description
vertices tainicom.Aether.Physics2D.Common.Vertices
position Strawberry.Math.Vector2 = null

CreateRectangle

Body CreateRectangle(float width, float height, float density, Vector2 position = null, float rotation = 0, BodyType bodyType = 0)

Parameters:

Name Type Description
width System.Single
height System.Single
density System.Single
position Strawberry.Math.Vector2 = null
rotation System.Single = 0
bodyType tainicom.Aether.Physics2D.Dynamics.BodyType = 0

CreateCircle

Body CreateCircle(float radius, float density, Vector2 position = null, BodyType bodyType = 0)

Parameters:

Name Type Description
radius System.Single
density System.Single
position Strawberry.Math.Vector2 = null
bodyType tainicom.Aether.Physics2D.Dynamics.BodyType = 0

CreateEllipse

Body CreateEllipse(float xRadius, float yRadius, int edges, float density, Vector2 position = null, float rotation = 0, BodyType bodyType = 0)

Parameters:

Name Type Description
xRadius System.Single
yRadius System.Single
edges System.Int32
density System.Single
position Strawberry.Math.Vector2 = null
rotation System.Single = 0
bodyType tainicom.Aether.Physics2D.Dynamics.BodyType = 0

CreatePolygon

Body CreatePolygon(Vertices vertices, float density, Vector2 position = null, float rotation = 0, BodyType bodyType = 0)

Parameters:

Name Type Description
vertices tainicom.Aether.Physics2D.Common.Vertices
density System.Single
position Strawberry.Math.Vector2 = null
rotation System.Single = 0
bodyType tainicom.Aether.Physics2D.Dynamics.BodyType = 0

CreateCompoundPolygon

Body CreateCompoundPolygon(List<Vertices> list, float density, Vector2 position = null, float rotation = 0, BodyType bodyType = 0)

Parameters:

Name Type Description
list System.Collections.Generic.List
density System.Single
position Strawberry.Math.Vector2 = null
rotation System.Single = 0
bodyType tainicom.Aether.Physics2D.Dynamics.BodyType = 0

CreateGear

Body CreateGear(float radius, int numberOfTeeth, float tipPercentage, float toothHeight, float density, Vector2 position = null, float rotation = 0, BodyType bodyType = 0)

Parameters:

Name Type Description
radius System.Single
numberOfTeeth System.Int32
tipPercentage System.Single
toothHeight System.Single
density System.Single
position Strawberry.Math.Vector2 = null
rotation System.Single = 0
bodyType tainicom.Aether.Physics2D.Dynamics.BodyType = 0

CreateCapsule

Body CreateCapsule(float height, float topRadius, int topEdges, float bottomRadius, int bottomEdges, float density, Vector2 position = null, float rotation = 0, BodyType bodyType = 0)

Parameters:

Name Type Description
height System.Single
topRadius System.Single
topEdges System.Int32
bottomRadius System.Single
bottomEdges System.Int32
density System.Single
position Strawberry.Math.Vector2 = null
rotation System.Single = 0
bodyType tainicom.Aether.Physics2D.Dynamics.BodyType = 0

CreateCapsule

Body CreateCapsule(float height, float endRadius, float density, Vector2 position = null, float rotation = 0, BodyType bodyType = 0)

Parameters:

Name Type Description
height System.Single
endRadius System.Single
density System.Single
position Strawberry.Math.Vector2 = null
rotation System.Single = 0
bodyType tainicom.Aether.Physics2D.Dynamics.BodyType = 0

CreateRoundedRectangle

Body CreateRoundedRectangle(float width, float height, float xRadius, float yRadius, int segments, float density, Vector2 position = null, float rotation = 0, BodyType bodyType = 0)

Parameters:

Name Type Description
width System.Single
height System.Single
xRadius System.Single
yRadius System.Single
segments System.Int32
density System.Single
position Strawberry.Math.Vector2 = null
rotation System.Single = 0
bodyType tainicom.Aether.Physics2D.Dynamics.BodyType = 0

CreateLineArc

Body CreateLineArc(float radians, int sides, float radius, bool closed = false, Vector2 position = null, float rotation = 0, BodyType bodyType = 0)

Parameters:

Name Type Description
radians System.Single
sides System.Int32
radius System.Single
closed System.Boolean = false
position Strawberry.Math.Vector2 = null
rotation System.Single = 0
bodyType tainicom.Aether.Physics2D.Dynamics.BodyType = 0

CreateSolidArc

Body CreateSolidArc(float density, float radians, int sides, float radius, Vector2 position = null, float rotation = 0, BodyType bodyType = 0)

Parameters:

Name Type Description
density System.Single
radians System.Single
sides System.Int32
radius System.Single
position Strawberry.Math.Vector2 = null
rotation System.Single = 0
bodyType tainicom.Aether.Physics2D.Dynamics.BodyType = 0

CreateChain

Creates a chain.

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

Parameters:

Name Type Description
start Strawberry.Math.Vector2 The start.
end Strawberry.Math.Vector2 The end.
linkWidth System.Single The width.
linkHeight System.Single The height.
numberOfLinks System.Int32 The number of links.
linkDensity System.Single The link density.
attachRopeJoint System.Boolean Creates a rope joint between start and end. This enforces the length of the rope. Said in another way: it makes the rope less bouncy.