C# Class Project290.Physics.Dynamics.World

The world class manages all physics entities, dynamic simulation, and asynchronous queries.
Show file Open project: scastle/Solitude Class Usage Examples

Public Properties

Property Type Description
BodyAdded BodyDelegate
BodyRemoved BodyDelegate
Enabled bool
FixtureAdded FixtureDelegate
FixtureRemoved FixtureDelegate
Gravity Vector2
Island Island
JointAdded JointDelegate
JointRemoved JointDelegate

Public Methods

Method Description
AddBody ( Body body ) : void

Create a rigid body.

AddBreakableBody ( BreakableBody breakableBody ) : void
AddController ( Controller controller ) : void
AddJoint ( Joint joint ) : void

Create a joint to constrain bodies together. This may cause the connected bodies to cease colliding.

ClearForces ( ) : void

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.

ProcessChanges ( ) : void

All adds and removes are cached by the World duing a World step. To process the changes before the world updates again, call this method.

QueryAABB ( bool>.Func callback, AABB &aabb ) : void

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

RayCast ( RayCastCallback callback, Vector2 point1, Vector2 point2 ) : void

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.

RemoveBody ( Body body ) : void

Destroy a rigid body. Warning: This automatically deletes all associated shapes and joints.

RemoveBreakableBody ( BreakableBody breakableBody ) : void
RemoveController ( Controller controller ) : void
RemoveJoint ( Joint joint ) : void

Destroy a joint. This may cause the connected bodies to begin colliding.

Step ( float dt ) : void

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

TestPoint ( Vector2 point ) : Fixture
TestPointAll ( Vector2 point ) : List

Returns a list of fixtures that are at the specified point.

World ( Vector2 gravity ) : System

Initializes a new instance of the World class.

Private Methods

Method Description
ProcessAddedBodies ( ) : void
ProcessAddedJoints ( ) : void
ProcessRemovedBodies ( ) : void
ProcessRemovedJoints ( ) : void
QueryAABBCallbackWrapper ( int proxyId ) : bool
RayCastCallbackWrapper ( RayCastInput &input, int proxyId ) : float
Solve ( TimeStep &step ) : void
SolveTOI ( TimeStep &step ) : void

Find TOI contacts and solve them.

Method Details

AddBody() public method

Create a rigid body.
public AddBody ( Body body ) : void
body Body
return void

AddBreakableBody() public method

public AddBreakableBody ( BreakableBody breakableBody ) : void
breakableBody BreakableBody
return void

AddController() public method

public AddController ( Controller controller ) : void
controller Project290.Physics.Controllers.Controller
return void

AddJoint() public method

Create a joint to constrain bodies together. This may cause the connected bodies to cease colliding.
public AddJoint ( Joint joint ) : void
joint Project290.Physics.Dynamics.Joints.Joint The joint.
return void

ClearForces() public method

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.
public ClearForces ( ) : void
return void

ProcessChanges() public method

All adds and removes are cached by the World duing a World step. To process the changes before the world updates again, call this method.
public ProcessChanges ( ) : void
return void

QueryAABB() public method

Query the world for all fixtures that potentially overlap the provided AABB.
public QueryAABB ( bool>.Func callback, AABB &aabb ) : void
callback bool>.Func A user implemented callback class.
aabb Project290.Physics.Collision.AABB The aabb query box.
return void

RayCast() public method

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.
public RayCast ( RayCastCallback callback, Vector2 point1, Vector2 point2 ) : void
callback RayCastCallback A user implemented callback class.
point1 Vector2 The ray starting point.
point2 Vector2 The ray ending point.
return void

RemoveBody() public method

Destroy a rigid body. Warning: This automatically deletes all associated shapes and joints.
public RemoveBody ( Body body ) : void
body Body The body.
return void

RemoveBreakableBody() public method

public RemoveBreakableBody ( BreakableBody breakableBody ) : void
breakableBody BreakableBody
return void

RemoveController() public method

public RemoveController ( Controller controller ) : void
controller Project290.Physics.Controllers.Controller
return void

RemoveJoint() public method

Destroy a joint. This may cause the connected bodies to begin colliding.
public RemoveJoint ( Joint joint ) : void
joint Project290.Physics.Dynamics.Joints.Joint The joint.
return void

Step() public method

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

TestPoint() public method

public TestPoint ( Vector2 point ) : Fixture
point Vector2
return Fixture

TestPointAll() public method

Returns a list of fixtures that are at the specified point.
public TestPointAll ( Vector2 point ) : List
point Vector2 The point.
return List

World() public method

Initializes a new instance of the World class.
public World ( Vector2 gravity ) : System
gravity Vector2 The gravity.
return System

Property Details

BodyAdded public property

Fires whenever a body has been added
public BodyDelegate BodyAdded
return BodyDelegate

BodyRemoved public property

Fires whenever a body has been removed
public BodyDelegate BodyRemoved
return BodyDelegate

Enabled public property

If false, the whole simulation stops. It still processes added and removed geometries.
public bool Enabled
return bool

FixtureAdded public property

Fires whenever a fixture has been added
public FixtureDelegate FixtureAdded
return FixtureDelegate

FixtureRemoved public property

Fires whenever a fixture has been removed
public FixtureDelegate FixtureRemoved
return FixtureDelegate

Gravity public property

Change the global gravity vector.
public Vector2 Gravity
return Vector2

Island public property

public Island,Project290.Physics.Dynamics Island
return Island

JointAdded public property

Fires whenever a joint has been added
public JointDelegate JointAdded
return JointDelegate

JointRemoved public property

Fires whenever a joint has been removed
public JointDelegate JointRemoved
return JointDelegate