Table of Contents

Class PhysicsWorld

Namespace
Fantas.Physics
Assembly
Fantas.dll

The PhysicsWorld provides:

Global values such as Gravity. Connecting PhysicsBodies with the AddJoint(PhysicsJoint) method. Raising events when PhysicsBody begin or end contact with each other(DidBeginContact, DidEndContact).

public sealed class PhysicsWorld
Inheritance
PhysicsWorld
Inherited Members

Properties

DefaultCollisionHandler

event when two bodies contact begin

public ContactHandler DefaultCollisionHandler { get; }

Property Value

ContactHandler

Gravity

Gravitational acceleration

public Vector2 Gravity { get; set; }

Property Value

Vector2

Iterations

Number of iterations to be used by impulse solver The default value is 10, for a more precise use a higher value For a faster solver use a lower value (This only affect Chipmunk/MonoGame backend)

public int Iterations { get; set; }

Property Value

int

Speed

The speed at which the physics simulation runs.

public float Speed { get; set; }

Property Value

float

Methods

AddJoint(PhysicsJoint)

Add joint to world

public void AddJoint(PhysicsJoint joint)

Parameters

joint PhysicsJoint

EnumarateBodies(PointF)

Enumerate all physical bodies at point

public PhysicsBody[] EnumarateBodies(PointF point)

Parameters

point PointF

Returns

PhysicsBody[]

EnumarateBodies(PointF, int)

Enumerate all physical bodies at point that match the filter

public PhysicsBody[] EnumarateBodies(PointF point, int categories)

Parameters

point PointF
categories int

Returns

PhysicsBody[]

EnumarateBodies(RectangleF)

Enumerate all physical bodies inside the rectangle

public PhysicsBody[] EnumarateBodies(RectangleF rect)

Parameters

rect RectangleF

Returns

PhysicsBody[]

EnumarateBodies(RectangleF, int)

Enumerate all physical bodies inside the rectangle and match the filter

public PhysicsBody[] EnumarateBodies(RectangleF rect, int categories)

Parameters

rect RectangleF
categories int

Returns

PhysicsBody[]

GetBody(PointF)

Returns the first PhysicsBody found that contains a point.

public PhysicsBody GetBody(PointF point)

Parameters

point PointF

Returns

PhysicsBody

GetBody(PointF, int)

Get the physical body at point that match the filter mask

public PhysicsBody GetBody(PointF point, int category)

Parameters

point PointF
category int

Returns

PhysicsBody

GetBody(RectangleF)

Returns the first PhysicsBody whose shape intersects a rectangle.

public PhysicsBody GetBody(RectangleF rect)

Parameters

rect RectangleF

Returns

PhysicsBody

GetBody(RectangleF, int)

Get the first body inside the rectangle bound that match the filter

public PhysicsBody GetBody(RectangleF rect, int category)

Parameters

rect RectangleF
category int

Returns

PhysicsBody

GetPairCollisionHandler(int, int)

event when two bodies contact begin

public ContactHandler GetPairCollisionHandler(int collisionTypeA, int collisionTypeB)

Parameters

collisionTypeA int
collisionTypeB int

Returns

ContactHandler

Raycast(PointF, PointF)

Returns the first PhysicsBody that intersects a ray defined by two points.

public RaycastHit Raycast(PointF rayStart, PointF rayEnd)

Parameters

rayStart PointF
rayEnd PointF

Returns

RaycastHit

Raycast(PointF, PointF, int)

Return the first body that intersect with the raycast

public RaycastHit Raycast(PointF rayStart, PointF rayEnd, int categories)

Parameters

rayStart PointF
rayEnd PointF
categories int

Returns

RaycastHit

RaycastBodies(PointF, PointF)

Get all bodies that intersect the raycast

public RaycastHit[] RaycastBodies(PointF rayStart, PointF rayEnd)

Parameters

rayStart PointF
rayEnd PointF

Returns

RaycastHit[]

RaycastBodies(PointF, PointF, int)

Get all bodies that intersect the raycast and match the filter

public RaycastHit[] RaycastBodies(PointF rayStart, PointF rayEnd, int categories)

Parameters

rayStart PointF
rayEnd PointF
categories int

Returns

RaycastHit[]

RemoveAllJoints()

Removes all PhysicsJoints.

public void RemoveAllJoints()

RemoveJoint(PhysicsJoint)

Removes the specified PhysicsJoint.

public void RemoveJoint(PhysicsJoint joint)

Parameters

joint PhysicsJoint