Aether.Physics2D
1.6
|
The world class manages all physics entities, dynamic simulation, and asynchronous queries. More...
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] |
The world class manages all physics entities, dynamic simulation, and asynchronous queries.
Initializes a new instance of the World class.
gravity | The gravity. |
World | ( | IBroadPhase | broadPhase | ) |
Initializes a new instance of the World class.
|
virtual |
Add a rigid body. Warning: This method is locked during callbacks.
System.InvalidOperationException | Thrown when the world is Locked/Stepping. |
void Add | ( | Controller | controller | ) |
Warning: This method is locked during callbacks.
System.InvalidOperationException | Thrown when the world is Locked/Stepping. |
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.
joint | The joint. |
System.InvalidOperationException | Thrown when the world is Locked/Stepping. |
void Clear | ( | ) |
Warning: This method is locked during callbacks.
System.InvalidOperationException | Thrown when the world is Locked/Stepping. |
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.
Path CreateChain | ( | Vector2 | start, |
Vector2 | end, | ||
float | linkWidth, | ||
float | linkHeight, | ||
int | numberOfLinks, | ||
float | linkDensity, | ||
bool | attachRopeJoint | ||
) |
Creates a chain.
world | The world. |
start | The start. |
end | The end. |
linkWidth | The width. |
linkHeight | The height. |
numberOfLinks | The number of links. |
linkDensity | The link density. |
attachRopeJoint | 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. |
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
callback | A user implemented callback class. |
aabb | The aabb query box. |
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
callback | A user implemented callback class. |
aabb | The aabb query box. |
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
callback | A user implemented callback class. |
point1 | The ray starting point. |
point2 | The ray ending point. |
|
virtual |
Destroy a rigid body. Warning: This automatically deletes all associated shapes and joints. Warning: This method is locked during callbacks.
body | The body. |
System.InvalidOperationException | Thrown when the world is Locked/Stepping. |
void Remove | ( | Controller | controller | ) |
Warning: This method is locked during callbacks.
System.InvalidOperationException | Thrown when the world is Locked/Stepping. |
void Remove | ( | Joint | joint | ) |
Destroy a joint. This may cause the connected bodies to begin colliding. Warning: This method is locked during callbacks.
joint | The joint. |
System.InvalidOperationException | Thrown when the world is Locked/Stepping. |
void ShiftOrigin | ( | Vector2 | newOrigin | ) |
Shift the world origin. Useful for large worlds. The body shift formula is: position -= newOrigin
newOrigin | the new origin with respect to the old origin Warning: Calling this method mid-update might cause a crash. |
void Step | ( | float | dt | ) |
Take a time step. This performs collision detection, integration, and consraint solution. Warning: This method is locked during callbacks.
dt | The amount of time to simulate in seconds, this should not vary. |
System.InvalidOperationException | Thrown when the world is Locked/Stepping. |
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.
dt | The amount of time to simulate in seconds, this should not vary. |
System.InvalidOperationException | Thrown when the world is Locked/Stepping. |
void Step | ( | TimeSpan | dt | ) |
Take a time step. This performs collision detection, integration, and consraint solution.
dt | The amount of time to simulate, this should not vary. |
void Step | ( | TimeSpan | dt, |
ref SolverIterations | iterations | ||
) |
Take a time step. This performs collision detection, integration, and consraint solution.
dt | The amount of time to simulate, this should not vary. |
BodyDelegate BodyAdded |
Fires whenever a body has been added
readonly BodyCollection BodyList |
Get the world body list.
The head of the world body list.
BodyDelegate BodyRemoved |
Fires whenever a body has been removed
readonly ContactManager ContactManager |
Get the contact manager for testing.
The contact manager.
ControllerDelegate ControllerAdded |
Fires every time a controller is added to the World.
ControllerDelegate ControllerRemoved |
Fires every time a controlelr is removed form the World.
FixtureDelegate FixtureAdded |
Fires whenever a fixture has been added
FixtureDelegate FixtureRemoved |
Fires whenever a fixture has been removed
JointDelegate JointAdded |
Fires whenever a joint has been added
readonly JointCollection JointList |
Get the world joint list.
The joint list.
JointDelegate JointRemoved |
Fires whenever a joint has been removed
object Tag |
Set the user data. Use this to store your application specific data.
The user data.
|
get |
Get the number of contacts (each may have 0 or more contact points).
The contact count.
|
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)
|
getset |
If false, the whole simulation stops. It still processes added and removed geometries.
|
getset |
Change the global gravity vector.
The gravity.
|
get |
Is the world locked (in the middle of a time step).
|
get |
Get the number of broad-phase proxies.
The proxy count.