World class

The world class manages all physics entities, dynamic simulation, and asynchronous queries. The world also contains efficient memory management facilities.

Constructors

World(Vector2 gravity, IWorldPool _pool, BroadPhase broadPhase)
World.withGravity(Vector2 gravity)
Construct a world object. [...]
factory
World.withPool(Vector2 gravity, IWorldPool pool)
Construct a world object. [...]
factory
World.withPoolAndStrategy(Vector2 gravity, IWorldPool pool, BroadPhaseStrategy strategy)
factory

Properties

averageLinearVel double
read / write
avs Vec2Array
final
axis Vector2
final
backup1 Sweep
final
backup2 Sweep
final
bodyList Body
read / write
broadphaseTimer Timer
final
cA Vector2
final
cB Vector2
final
center Vector2
final
circCenterMoved Vector2
final
color Color3i
final
contactStacks List<List<ContactRegister>>
read / write
debugDraw DebugDraw
read / write
input RayCastInput
final
island Island
final
liquidColor Color3i
final
liquidLength double
read / write
liquidOffset Vector2
final
stack List<Body>
read / write
step TimeStep
final
stepTimer Timer
final
subStep TimeStep
final
tempBodies List<Body>
final
tempTimer Timer
final
tlvertices Vec2Array
final
toiInput TOIInput
final
toiIsland Island
final
toiOutput TOIOutput
final
v1 Vector2
final
v2 Vector2
final
wqwrapper WorldQueryWrapper
final
wrcwrapper WorldRayCastWrapper
final
xf Transform
final
hashCode int
The hash code for this object. [...]
read-only, inherited
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited

Methods

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. [...]
computeParticleCollisionEnergy() double
Compute the kinetic energy that can be lost by damping force [...]
createBody(BodyDef def) Body
create a rigid body given a definition. No reference to the definition is retained. [...]
createJoint(JointDef def) Joint
create a joint to constrain bodies together. No reference to the definition is retained. This may cause the connected bodies to cease colliding. [...]
createParticle(ParticleDef def) int
Create a particle whose properties have been defined. No reference to the definition is retained. A simulation step must occur before it's possible to interact with a newly created particle. For example, DestroyParticleInShape() will not destroy a particle until Step() has been called. [...]
createParticleGroup(ParticleGroupDef def) ParticleGroup
Create a particle group whose properties have been defined. No reference to the definition is retained. [...]
destroyBody(Body body) → void
destroy a rigid body given a definition. No reference to the definition is retained. This function is locked during callbacks. [...]
destroyJoint(Joint j) → void
destroy a joint. This may cause the connected bodies to begin colliding. [...]
destroyParticle(int index) → void
Destroy a particle. The particle is removed after the next step. [...]
destroyParticleFlag(int index, bool callDestructionListener) → void
Destroy a particle. The particle is removed after the next step. [...]
destroyParticlesInGroup(ParticleGroup group) → void
Destroy particles in a group without enabling the destruction callback for destroyed particles. This function is locked during callbacks. [...]
destroyParticlesInGroupFlag(ParticleGroup group, bool callDestructionListener) → void
Destroy particles in a group. This function is locked during callbacks. [...]
destroyParticlesInShape(Shape shape, Transform xf) int
Destroy particles inside a shape without enabling the destruction callback for destroyed particles. This function is locked during callbacks. For more information see DestroyParticleInShape(Shape&, Transform&,bool). [...]
destroyParticlesInShapeFlag(Shape shape, Transform xf, bool callDestructionListener) int
Destroy particles inside a shape. This function is locked during callbacks. In addition, this function immediately destroys particles in the shape in contrast to DestroyParticle() which defers the destruction until the next simulation step. [...]
drawDebugData() → void
Call this to draw shapes and other debug draw data.
drawJoint(Joint joint) → void
drawParticleSystem(ParticleSystem system) → void
drawShape(Fixture fixture, Transform xf, Color3i color, bool wireframe) → void
forEachBody(void action(Body body)) → void
getAutoClearForces() bool
Get the flag that controls automatic clearing of forces after each time step. [...]
getContactCount() int
Get the number of contacts (each may have 0 or more contact points). [...]
getContactList() Contact
Get the world contact list. With the returned contact, use Contact.getNext to get the next contact in the world list. A null contact indicates the end of the list. [...]
getDestructionListener() DestructionListener
getGravity() Vector2
Get the global gravity vector. [...]
getParticleBodyContactCount() int
getParticleBodyContacts() List<ParticleBodyContact>
Get contacts between particles and bodies [...]
getParticleColorBuffer() List<ParticleColor>
getParticleContactCount() int
getParticleContacts() List<ParticleContact>
Get contacts between particles [...]
getParticleCount() int
Get the number of particles. [...]
getParticleDamping() double
Get damping for particles [...]
getParticleDensity() double
Get the particle density. [...]
getParticleDestructionListener() ParticleDestructionListener
getParticleFlagsBuffer() List<int>
Get the particle data. @return the pointer to the head of the particle data. [...]
getParticleGravityScale() double
Get the particle gravity scale. [...]
getParticleGroupBuffer() List<ParticleGroup>
getParticleGroupCount() int
Get the number of particle groups. [...]
getParticleGroupList() List<ParticleGroup>
Get the world particle group list. With the returned group, use ParticleGroup::GetNext to get the next group in the world list. A NULL group indicates the end of the list. [...]
getParticleMaxCount() int
Get the maximum number of particles. [...]
getParticlePositionBuffer() List<Vector2>
getParticleRadius() double
Get the particle radius. [...]
getParticleUserDataBuffer() List<Object>
getParticleVelocityBuffer() List<Vector2>
getPool() IWorldPool
getProxyCount() int
Get the number of broad-phase proxies. [...]
getTreeBalance() int
Gets the balance of the dynamic tree [...]
getTreeHeight() int
Gets the height of the dynamic tree [...]
getTreeQuality() double
Gets the quality of the dynamic tree [...]
isAllowSleep() bool
isLocked() bool
Is the world locked (in the middle of a time step). [...]
isSubStepping() bool
joinParticleGroups(ParticleGroup groupA, ParticleGroup groupB) → void
Join two particle groups. [...]
popContact(Fixture fixtureA, int indexA, Fixture fixtureB, int indexB) Contact
pushContact(Contact contact) → void
queryAABB(QueryCallback callback, AABB aabb) → void
Query the world for all fixtures that potentially overlap the provided AABB. [...]
queryAABBParticle(ParticleQueryCallback particleCallback, AABB aabb) → void
Query the world for all particles that potentially overlap the provided AABB. [...]
queryAABBTwoCallbacks(QueryCallback callback, ParticleQueryCallback particleCallback, AABB aabb) → void
Query the world for all fixtures and particles 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. [...]
raycastParticle(ParticleRaycastCallback particleCallback, Vector2 point1, Vector2 point2) → void
Ray-cast the world for all particles in the path of the ray. Your callback controls whether you get the closest point, any point, or n-points. [...]
raycastTwoCallBacks(RayCastCallback callback, ParticleRaycastCallback particleCallback, Vector2 point1, Vector2 point2) → void
Ray-cast the world for all fixtures and particles 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. [...]
setAllowSleep(bool flag) → void
setAutoClearForces(bool flag) → void
Set flag to control automatic clearing of forces after each time step. [...]
setContactFilter(ContactFilter filter) → void
Register a contact filter to provide specific control over collision. Otherwise the default filter is used (_defaultFilter). The listener is owned by you and must remain in scope. [...]
setContactListener(ContactListener listener) → void
Register a contact event listener. The listener is owned by you and must remain in scope. [...]
setDebugDraw(DebugDraw debugDraw) → void
Register a routine for debug drawing. The debug draw functions are called inside with World.DrawDebugData method. The debug draw object is owned by you and must remain in scope. [...]
setDestructionListener(DestructionListener listener) → void
Register a destruction listener. The listener is owned by you and must remain in scope. [...]
setGravity(Vector2 gravity) → void
Change the global gravity vector. [...]
setParticleColorBuffer(List<ParticleColor> buffer, int capacity) → void
setParticleDamping(double damping) → void
Damping is used to reduce the velocity of particles. The damping parameter can be larger than 1.0 but the damping effect becomes sensitive to the time step when the damping parameter is large. [...]
setParticleDensity(double density) → void
Change the particle density. [...]
setParticleDestructionListener(ParticleDestructionListener listener) → void
setParticleFlagsBuffer(List<int> buffer, int capacity) → void
Set a buffer for particle data. [...]
setParticleGravityScale(double gravityScale) → void
Change the particle gravity scale. Adjusts the effect of the global gravity vector on particles. Default value is 1.0. [...]
setParticleMaxCount(int count) → void
Set the maximum number of particles. [...]
setParticlePositionBuffer(List<Vector2> buffer, int capacity) → void
setParticleRadius(double radius) → void
Change the particle radius. You should set this only once, on world start. If you change the radius during execution, existing particles may explode, shrink, or behave unexpectedly. [...]
setParticleUserDataBuffer(List<Object> buffer, int capacity) → void
setParticleVelocityBuffer(List<Vector2> buffer, int capacity) → void
setSubStepping(bool subStepping) → void
solve(TimeStep step) → void
solveTOI(TimeStep step) → void
stepDt(double dt, int velocityIterations, int positionIterations) → void
Take a time step. This performs collision detection, integration, and constraint solution. [...]
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
inherited
toString() String
Returns a string representation of this object.
inherited

Operators

operator ==(dynamic other) bool
The equality operator. [...]
inherited

Static Properties

LIQUID_INT int
read / write

Constants

CLEAR_FORCES → const int
0x0004
LOCKED → const int
0x0002
NEW_FIXTURE → const int
0x0001
WORLD_POOL_CONTAINER_SIZE → const int
10
WORLD_POOL_SIZE → const int
100