C# Class FarseerPhysics.Dynamics.World

The world class manages all physics entities, dynamic simulation, and asynchronous queries.
Inheritance: IRayCastCallback
Mostra file Open project: prime31/Nez Class Usage Examples

Public Properties

Property Type Description
AwakeBodySet HashSet
addRemoveTime float
bodyList List
breakableBodyList List
contactManager ContactManager
contactsUpdateTime float
continuousPhysicsTime float
controllerList List
controllersUpdateTime float
enabled bool
gravity Vector2
island Island
jointList List
newContactsTime float
onBodyAdded BodyDelegate
onBodyRemoved BodyDelegate
onControllerAdded ControllerDelegate
onControllerRemoved ControllerDelegate
onFixtureAdded FixtureDelegate
onFixtureRemoved FixtureDelegate
onJointAdded JointDelegate
onJointRemoved JointDelegate
solveUpdateTime float
updateTime float

Public Methods

Method Description
World ( Vector2 gravity ) : System

Initializes a new instance of the World class.

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.

clear ( ) : void
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.

overlapCircle ( Vector2 center, float radius ) : void
processAddedBodies ( ) : void
processAddedJoints ( ) : void
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.

processRemovedBodies ( ) : void
processRemovedJoints ( ) : void
queryAABB ( AABB &aabb ) : List

Query the world for all fixtures that potentially overlap the provided AABB. Use the overload with a callback for filtering and better performance.

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

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

rayCast ( Vector2 point1, Vector2 point2 ) : List
rayCast ( Func 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. 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

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.

removeJoint ( Joint joint, bool doCheck ) : void
shiftOrigin ( Vector2 newOrigin ) : void
solve ( TimeStep &timeStep ) : void
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.

Private Methods

Method Description
addBody ( Body body ) : void

Add a rigid body.

queryAABBCallbackWrapper ( int proxyId ) : bool
rayCastCallbackWrapper ( RayCastInput rayCastInput, int proxyId ) : float
testPointAllCallback ( Fixture fixture ) : bool
testPointCallback ( Fixture fixture ) : bool

Method Details

World() public method

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

addBreakableBody() public method

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

addController() public method

public addController ( Controller controller ) : void
controller FarseerPhysics.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 FarseerPhysics.Dynamics.Joints.Joint The joint.
return void

clear() public method

public clear ( ) : void
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

overlapCircle() public method

public overlapCircle ( Vector2 center, float radius ) : void
center Vector2
radius float
return void

processAddedBodies() public method

public processAddedBodies ( ) : void
return void

processAddedJoints() public method

public processAddedJoints ( ) : 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

processRemovedBodies() public method

public processRemovedBodies ( ) : void
return void

processRemovedJoints() public method

public processRemovedJoints ( ) : void
return void

queryAABB() public method

Query the world for all fixtures that potentially overlap the provided AABB. Use the overload with a callback for filtering and better performance.
public queryAABB ( AABB &aabb ) : List
aabb AABB The aabb query box.
return List

queryAABB() public method

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
public queryAABB ( bool>.Func callback, AABB &aabb ) : void
callback bool>.Func A user implemented callback class.
aabb AABB The aabb query box.
return void

rayCast() public method

public rayCast ( Vector2 point1, Vector2 point2 ) : List
point1 Vector2
point2 Vector2
return List

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. 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
public rayCast ( Func callback, Vector2 point1, Vector2 point2 ) : void
callback Func 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 Controller
return void

removeJoint() public method

Destroy a joint. This may cause the connected bodies to begin colliding.
public removeJoint ( Joint joint ) : void
joint Joint The joint.
return void

removeJoint() public method

public removeJoint ( Joint joint, bool doCheck ) : void
joint Joint
doCheck bool
return void

shiftOrigin() public method

public shiftOrigin ( Vector2 newOrigin ) : void
newOrigin Vector2
return void

solve() public method

public solve ( TimeStep &timeStep ) : void
timeStep TimeStep
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

Property Details

AwakeBodySet public_oe property

public HashSet AwakeBodySet
return HashSet

addRemoveTime public_oe property

public float addRemoveTime
return float

bodyList public_oe property

Get the world body list.
public List bodyList
return List

breakableBodyList public_oe property

public List breakableBodyList
return List

contactManager public_oe property

Get the contact manager for testing.
public ContactManager,FarseerPhysics.Dynamics contactManager
return ContactManager

contactsUpdateTime public_oe property

public float contactsUpdateTime
return float

continuousPhysicsTime public_oe property

public float continuousPhysicsTime
return float

controllerList public_oe property

public List controllerList
return List

controllersUpdateTime public_oe property

public float controllersUpdateTime
return float

enabled public_oe property

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

gravity public_oe property

Change the global gravity vector.
public Vector2 gravity
return Vector2

island public_oe property

public Island island
return Island

jointList public_oe property

Get the world joint list.
public List jointList
return List

newContactsTime public_oe property

public float newContactsTime
return float

onBodyAdded public_oe property

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

onBodyRemoved public_oe property

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

onControllerAdded public_oe property

Fires every time a controller is added to the World.
public ControllerDelegate onControllerAdded
return ControllerDelegate

onControllerRemoved public_oe property

Fires every time a controlelr is removed form the World.
public ControllerDelegate onControllerRemoved
return ControllerDelegate

onFixtureAdded public_oe property

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

onFixtureRemoved public_oe property

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

onJointAdded public_oe property

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

onJointRemoved public_oe property

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

solveUpdateTime public_oe property

public float solveUpdateTime
return float

updateTime public_oe property

public float updateTime
return float