org.jbox2d.dynamics
Class World

java.lang.Object
  extended by org.jbox2d.dynamics.World

public class World
extends java.lang.Object


Field Summary
static boolean ENABLE_POSITION_CORRECTION
           
static boolean ENABLE_TOI
           
static boolean ENABLE_WARM_STARTING
           
 boolean m_allowSleep
           
 int m_bodyCount
           
 Body m_bodyList
           
 BoundaryListener m_boundaryListener
           
 BroadPhase m_broadPhase
           
 int m_contactCount
           
 ContactFilter m_contactFilter
           
 Contact m_contactList
          Do not access, won't be useful!
 ContactListener m_contactListener
           
 DebugDraw m_debugDraw
           
 DestructionListener m_destructionListener
           
 Vec2 m_gravity
           
 Body m_groundBody
           
 int m_jointCount
           
 Joint m_jointList
           
 boolean m_lock
           
 int m_positionIterationCount
           
 
Constructor Summary
World(AABB worldAABB, Vec2 gravity, boolean doSleep)
          Construct a world object.
 
Method Summary
 Body createDynamicBody(BodyDef def)
          Create a dynamic rigid body given a definition.
 Joint createJoint(JointDef def)
          Create a joint to constrain bodies together.
 Body createStaticBody(BodyDef def)
          Create a static rigid body given a definition.
 void destroyBody(Body b)
          Destroy a rigid body given a definition.
 void destroyJoint(Joint j)
          Destroy a joint.
 void drawDebugData()
          For internal use
 void drawJoint(Joint joint)
          For internal use
 void drawShape(Shape shape, XForm xf, javax.vecmath.Color3f color, boolean core)
          For internal use
 Body getBodyList()
          Get the world body list.
 Body getGroundBody()
          The world provides a single static ground body with no collision shapes.
 Joint getJointList()
          Get the world joint list.
 Shape[] query(AABB aabb, int maxCount)
          Query the world for all shapes that potentially overlap the provided AABB up to max count.
 void setDebugDraw(DebugDraw debugDraw)
          Register a routine for debug drawing.
 void setFilter(ContactFilter filter)
          Register a contact filter to provide specific control over collision.
 void setListener(BoundaryListener listener)
          Register a broad-phase boundary listener.
 void setListener(ContactListener listener)
          Register a contact event listener
 void setListener(DestructionListener listener)
          Register a destruction listener.
 void solve(TimeStep step)
          For internal use
 void solveTOI(TimeStep step)
          For internal use: find TOI contacts and solve them.
 void step(float dt, int iterations)
          Take a time step.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_lock

public boolean m_lock

m_broadPhase

public BroadPhase m_broadPhase

m_bodyList

public Body m_bodyList

m_contactList

public Contact m_contactList
Do not access, won't be useful!


m_jointList

public Joint m_jointList

m_bodyCount

public int m_bodyCount

m_contactCount

public int m_contactCount

m_jointCount

public int m_jointCount

m_gravity

public Vec2 m_gravity

m_allowSleep

public boolean m_allowSleep

m_groundBody

public Body m_groundBody

m_positionIterationCount

public int m_positionIterationCount

ENABLE_POSITION_CORRECTION

public static boolean ENABLE_POSITION_CORRECTION

ENABLE_WARM_STARTING

public static boolean ENABLE_WARM_STARTING

ENABLE_TOI

public static boolean ENABLE_TOI

m_destructionListener

public DestructionListener m_destructionListener

m_boundaryListener

public BoundaryListener m_boundaryListener

m_contactFilter

public ContactFilter m_contactFilter

m_contactListener

public ContactListener m_contactListener

m_debugDraw

public DebugDraw m_debugDraw
Constructor Detail

World

public World(AABB worldAABB,
             Vec2 gravity,
             boolean doSleep)
Construct a world object.

Parameters:
worldAABB - a bounding box that completely encompasses all your shapes.
gravity - the world gravity vector.
doSleep - improve performance by not simulating inactive bodies.
Method Detail

getGroundBody

public Body getGroundBody()
The world provides a single static ground body with no collision shapes. You can use this to simplify the creation of joints and static shapes.


getBodyList

public Body getBodyList()
Get the world body list. With the returned body, use Body.getNext() to get the next body in the world list. A NULL body indicates the end of the list.

Returns:
the head of the world body list.

getJointList

public Joint getJointList()
Get the world joint list. With the returned joint, use Joint.getNext() to get the next joint in the world list. A NULL joint indicates the end of the list.

Returns:
the head of the world joint list.

setListener

public void setListener(DestructionListener listener)
Register a destruction listener.


setListener

public void setListener(BoundaryListener listener)
Register a broad-phase boundary listener.


setFilter

public void setFilter(ContactFilter filter)
Register a contact filter to provide specific control over collision. Otherwise the default filter is used (b2_defaultFilter).


setListener

public void setListener(ContactListener listener)
Register a contact event listener


setDebugDraw

public void setDebugDraw(DebugDraw debugDraw)
Register a routine for debug drawing. The debug draw functions are called inside the World.step() method, so make sure your renderer is ready to consume draw commands when you call step().


createStaticBody

public Body createStaticBody(BodyDef def)
Create a static rigid body given a definition. No reference to the definition is retained.
Warning: This function is locked during callbacks.


createDynamicBody

public Body createDynamicBody(BodyDef def)
Create a dynamic rigid body given a definition. No reference to the definition is retained.
Warning: This function is locked during callbacks.


destroyBody

public void destroyBody(Body b)
Destroy a rigid body given a definition. No reference to the definition is retained. This function is locked during callbacks.
Warning: This automatically deletes all associated shapes and joints.
Warning: This function is locked during callbacks.


createJoint

public Joint createJoint(JointDef def)
Create a joint to constrain bodies together. No reference to the definition is retained. This may cause the connected bodies to cease colliding.
Warning This function is locked during callbacks.


destroyJoint

public void destroyJoint(Joint j)
Destroy a joint. This may cause the connected bodies to begin colliding.
Warning: This function is locked during callbacks.


step

public void step(float dt,
                 int iterations)
Take a time step. This performs collision detection, integration, and constraint solution.

Parameters:
dt - the amount of time to simulate, this should not vary.
iterations - the number of iterations to be used by the constraint solver.

query

public Shape[] query(AABB aabb,
                     int maxCount)
Query the world for all shapes that potentially overlap the provided AABB up to max count. The number of shapes found is returned.

Parameters:
aabb - the query box.
maxCount - the capacity of the shapes array.
Returns:
array of shapes overlapped, up to maxCount in length

solve

public void solve(TimeStep step)
For internal use


solveTOI

public void solveTOI(TimeStep step)
For internal use: find TOI contacts and solve them.


drawShape

public void drawShape(Shape shape,
                      XForm xf,
                      javax.vecmath.Color3f color,
                      boolean core)
For internal use


drawJoint

public void drawJoint(Joint joint)
For internal use


drawDebugData

public void drawDebugData()
For internal use