 java.lang.Object

 org.dyn4j.dynamics.World

 All Implemented Interfaces:
DataContainer
,Shiftable
public class World extends java.lang.Object implements Shiftable, DataContainer
Manages the logic of collision detection, resolution, and reporting.Interfacing with dyn4j starts with this class. Create a new instance of this class and add bodies and joints. Then call one of the update or step methods in your game loop to move the physics engine forward in time.
Via the
addListener(Listener)
method, aWorld
instance can have multiple listeners for all the listener types. Some listener types return a boolean to indicate continuing or allowing something, likeCollisionListener
. If, for example, there are multipleCollisionListener
s and any one of them returns false for an event, the collision is skipped. However, all listeners will still be called no matter if the first returned false. Since:
 1.0.0
 Version:
 3.4.0
 Author:
 William Bittle


Field Summary

Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addBody(Body body)
void
addJoint(Joint joint)
void
addListener(Listener listener)
Adds the given listener to the list of listeners.boolean
containsBody(Body body)
Returns true if this world contains the given body.boolean
containsJoint(Joint joint)
Returns true if this world contains the given joint.boolean
containsListener(Listener listener)
Returns true if the given listener is already attached to this world.boolean
convexCast(Convex convex, Transform transform, Vector2 deltaPosition, boolean ignoreSensors, boolean ignoreInactive, boolean all, java.util.List<ConvexCastResult> results)
Performs a linear convex cast on the world, placing any detected collisions into the given results list.boolean
convexCast(Convex convex, Transform transform, Vector2 deltaPosition, boolean ignoreSensors, boolean all, java.util.List<ConvexCastResult> results)
Performs a linear convex cast on the world, placing any detected collisions into the given results list.boolean
convexCast(Convex convex, Transform transform, Vector2 deltaPosition, double deltaAngle, boolean ignoreSensors, boolean ignoreInactive, boolean all, java.util.List<ConvexCastResult> results)
Performs a linear convex cast on the world, placing any detected collisions into the given results list.boolean
convexCast(Convex convex, Transform transform, Vector2 deltaPosition, double deltaAngle, boolean ignoreSensors, boolean all, java.util.List<ConvexCastResult> results)
Performs a linear convex cast on the world, placing any detected collisions into the given results list.boolean
convexCast(Convex convex, Transform transform, Vector2 deltaPosition, double deltaAngle, Filter filter, boolean ignoreSensors, boolean ignoreInactive, boolean all, java.util.List<ConvexCastResult> results)
Performs a linear convex cast on the world, placing any detected collisions into the given results list.boolean
convexCast(Convex convex, Transform transform, Vector2 deltaPosition, double deltaAngle, Body body, boolean ignoreSensors, ConvexCastResult result)
Performs a linear convex cast on the given body, placing a detected collision into the given result object.boolean
convexCast(Convex convex, Transform transform, Vector2 deltaPosition, double deltaAngle, Body body, Filter filter, boolean ignoreSensors, ConvexCastResult result)
Performs a linear convex cast on the given body, placing a detected collision into the given result object.boolean
convexCast(Convex convex, Transform transform, Vector2 deltaPosition, Body body, boolean ignoreSensors, ConvexCastResult result)
Performs a linear convex cast on the given body, placing a detected collision into the given result object.protected void
detect()
Finds new contacts for all bodies in this world.boolean
detect(AABB aabb, boolean ignoreSensors, boolean ignoreInactive, java.util.List<DetectResult> results)
boolean
detect(AABB aabb, boolean ignoreInactive, java.util.List<DetectResult> results)
boolean
detect(AABB aabb, java.util.List<DetectResult> results)
boolean
detect(AABB aabb, Filter filter, boolean ignoreSensors, boolean ignoreInactive, java.util.List<DetectResult> results)
boolean
detect(AABB aabb, Body body, boolean ignoreSensors, java.util.List<DetectResult> results)
Returns true if the givenAABB
overlaps the given body in the world.boolean
detect(AABB aabb, Body body, Filter filter, boolean ignoreSensors, java.util.List<DetectResult> results)
Returns true if the givenAABB
overlaps the given body in the world.boolean
detect(Convex convex, boolean ignoreSensors, boolean ignoreInactive, java.util.List<DetectResult> results)
Returns true if the givenConvex
overlaps a body in the world.boolean
detect(Convex convex, boolean ignoreSensors, java.util.List<DetectResult> results)
Returns true if the givenConvex
overlaps a body in the world.boolean
detect(Convex convex, java.util.List<DetectResult> results)
Returns true if the givenConvex
overlaps a body in the world.boolean
detect(Convex convex, Filter filter, boolean ignoreSensors, boolean ignoreInactive, boolean includeCollisionData, java.util.List<DetectResult> results)
Returns true if the givenConvex
overlaps a body in the world.boolean
detect(Convex convex, Filter filter, boolean ignoreSensors, boolean ignoreInactive, java.util.List<DetectResult> results)
Returns true if the givenConvex
overlaps a body in the world.boolean
detect(Convex convex, Body body, boolean ignoreSensors, java.util.List<DetectResult> results)
Returns true if the givenConvex
overlaps the given body in the world.boolean
detect(Convex convex, Body body, Filter filter, boolean ignoreSensors, boolean includeCollisionData, java.util.List<DetectResult> results)
Returns true if the givenConvex
overlaps the given body in the world.boolean
detect(Convex convex, Body body, Filter filter, boolean ignoreSensors, java.util.List<DetectResult> results)
Returns true if the givenConvex
overlaps the given body in the world.boolean
detect(Convex convex, Transform transform, boolean ignoreSensors, boolean ignoreInactive, java.util.List<DetectResult> results)
Returns true if the givenConvex
overlaps a body in the world.boolean
detect(Convex convex, Transform transform, boolean ignoreSensors, java.util.List<DetectResult> results)
Returns true if the givenConvex
overlaps a body in the world.boolean
detect(Convex convex, Transform transform, java.util.List<DetectResult> results)
Returns true if the givenConvex
overlaps a body in the world.boolean
detect(Convex convex, Transform transform, Filter filter, boolean ignoreSensors, boolean ignoreInactive, boolean includeCollisionData, java.util.List<DetectResult> results)
Returns true if the givenConvex
overlaps a body in the world.boolean
detect(Convex convex, Transform transform, Filter filter, boolean ignoreSensors, boolean ignoreInactive, java.util.List<DetectResult> results)
Returns true if the givenConvex
overlaps a body in the world.boolean
detect(Convex convex, Transform transform, Body body, boolean ignoreSensors, java.util.List<DetectResult> results)
Returns true if the givenConvex
overlaps the given body in the world.boolean
detect(Convex convex, Transform transform, Body body, Filter filter, boolean ignoreSensors, boolean includeCollisionData, java.util.List<DetectResult> results)
Returns true if the givenConvex
overlaps the given body in the world.boolean
detect(Convex convex, Transform transform, Body body, Filter filter, boolean ignoreSensors, java.util.List<DetectResult> results)
Returns true if the givenConvex
overlaps the given body in the world.double
getAccumulatedTime()
Returns the current accumulated time.java.util.List<Body>
getBodies()
Returns an unmodifiable list containing all the bodies in this world.Body
getBody(int index)
Returns theBody
at the given index.int
getBodyCount()
java.util.Iterator<Body>
getBodyIterator()
Returns an iterator for iterating over the bodies in this world.Bounds
getBounds()
Returns the bounds of this world.BroadphaseDetector<Body,BodyFixture>
getBroadphaseDetector()
Returns the broadphase collision detection algorithm.CoefficientMixer
getCoefficientMixer()
Returns theCoefficientMixer
.ContactConstraintSolver
getContactConstraintSolver()
Returns theContactConstraintSolver
.ContactManager
getContactManager()
Returns theContactManager
.BroadphaseFilter<Body,BodyFixture>
getDetectBroadphaseFilter()
Returns theBroadphaseFilter
used when detecting collisions for each time step.Vector2
getGravity()
Returns the acceleration due to gravity.java.util.UUID
getId()
Deprecated.ID schemes should be implemented by the user where needed; since 3.4.0Joint
getJoint(int index)
Returns theJoint
at the given index.int
getJointCount()
java.util.Iterator<Joint>
getJointIterator()
Returns an iterator for iterating over the joints in this world.java.util.List<Joint>
getJoints()
Returns an unmodifiable list containing all the joints in this world.int
getListenerCount()
Returns the total number of listeners attached to this world.<T extends Listener>
intgetListenerCount(java.lang.Class<T> clazz)
Returns the total number of listeners of the given type (or sub types) attached to this world.<T extends Listener>
java.util.List<T>getListeners(java.lang.Class<T> clazz)
Returns the listeners that are of the given type (or sub types) of the given type.<T extends Listener>
voidgetListeners(java.lang.Class<T> clazz, java.util.List<T> listeners)
Returns the listeners of the given type (or sub types) in the given list.ManifoldSolver
getManifoldSolver()
Returns the manifold solver.NarrowphaseDetector
getNarrowphaseDetector()
Returns the narrowphase collision detection algorithm.RaycastDetector
getRaycastDetector()
Returns the raycast detector.Settings
getSettings()
Returns the settings for this world.Step
getStep()
Returns theStep
object used to advance the simulation.TimeOfImpactDetector
getTimeOfImpactDetector()
Returns the time of impact detector.java.lang.Object
getUserData()
Gets the custom user data.boolean
isEmpty()
Returns true if this world doesn't contain any bodies or joints.boolean
isUpdateRequired()
Returns true if upon the next time step the contacts must be updated.boolean
raycast(Ray ray, double maxLength, boolean ignoreSensors, boolean ignoreInactive, boolean all, java.util.List<RaycastResult> results)
boolean
raycast(Ray ray, double maxLength, boolean ignoreSensors, boolean all, java.util.List<RaycastResult> results)
boolean
raycast(Ray ray, double maxLength, Filter filter, boolean ignoreSensors, boolean ignoreInactive, boolean all, java.util.List<RaycastResult> results)
boolean
raycast(Ray ray, Body body, double maxLength, boolean ignoreSensors, RaycastResult result)
Performs a raycast against the givenBody
and returns true if the ray intersects the body.boolean
raycast(Ray ray, Body body, double maxLength, Filter filter, boolean ignoreSensors, RaycastResult result)
Performs a raycast against the givenBody
and returns true if the ray intersects the body.boolean
raycast(Vector2 start, Vector2 end, boolean ignoreSensors, boolean ignoreInactive, boolean all, java.util.List<RaycastResult> results)
boolean
raycast(Vector2 start, Vector2 end, boolean ignoreSensors, boolean all, java.util.List<RaycastResult> results)
boolean
raycast(Vector2 start, Vector2 end, Filter filter, boolean ignoreSensors, boolean ignoreInactive, boolean all, java.util.List<RaycastResult> results)
boolean
raycast(Vector2 start, Vector2 end, Body body, boolean ignoreSensors, RaycastResult result)
Performs a raycast against the givenBody
and returns true if the ray intersects the body.boolean
raycast(Vector2 start, Vector2 end, Body body, Filter filter, boolean ignoreSensors, RaycastResult result)
Performs a raycast against the givenBody
and returns true if the ray intersects the body.void
removeAllBodies()
This is a convenience method for theremoveAllBodiesAndJoints()
method since all joints will be removed when all bodies are removed anyway.void
removeAllBodies(boolean notify)
This is a convenience method for theremoveAllBodiesAndJoints(boolean)
method since all joints will be removed when all bodies are removed anyway.void
removeAllBodiesAndJoints()
Removes all the joints and bodies from this world.void
removeAllBodiesAndJoints(boolean notify)
Removes all the joints and bodies from this world.void
removeAllJoints()
void
removeAllJoints(boolean notify)
int
removeAllListeners()
Removes all the listeners.<T extends Listener>
intremoveAllListeners(java.lang.Class<T> clazz)
Removes all the listeners of the specified type (or sub types).boolean
removeBody(int index)
boolean
removeBody(int index, boolean notify)
boolean
removeBody(Body body)
boolean
removeBody(Body body, boolean notify)
boolean
removeJoint(int index)
boolean
removeJoint(Joint joint)
boolean
removeListener(Listener listener)
Removes the given listener from this world.void
setAccumulatedTime(double elapsedTime)
Sets the current accumulated time.void
setBounds(Bounds bounds)
Sets the bounds of thisWorld
.void
setBroadphaseDetector(BroadphaseDetector<Body,BodyFixture> broadphaseDetector)
Sets the broadphase collision detection algorithm.void
setCoefficientMixer(CoefficientMixer coefficientMixer)
Sets theCoefficientMixer
.void
setContactConstraintSolver(ContactConstraintSolver constraintSolver)
Sets theContactConstraintSolver
for this world.void
setContactManager(ContactManager contactManager)
Sets theContactManager
.void
setDetectBroadphaseFilter(BroadphaseFilter<Body,BodyFixture> filter)
Sets theBroadphaseFilter
used when detecting collisions for each time step.void
setGravity(Vector2 gravity)
Sets the acceleration due to gravity.void
setManifoldSolver(ManifoldSolver manifoldSolver)
Sets the manifold solver.void
setNarrowphaseDetector(NarrowphaseDetector narrowphaseDetector)
Sets the narrowphase collision detection algorithm.void
setRaycastDetector(RaycastDetector raycastDetector)
Sets the raycast detector.void
setSettings(Settings settings)
Sets the dynamics settings for this world.void
setTimeOfImpactDetector(TimeOfImpactDetector timeOfImpactDetector)
Sets the time of impact detector.void
setUpdateRequired(boolean flag)
Sets the update required flag.void
setUserData(java.lang.Object userData)
Sets the custom user data to the given data.void
shift(Vector2 shift)
Shifts the coordinates of the entire world by the given amount.protected void
solveTOI(Body body1, java.util.List<TimeOfImpactListener> listeners)
Solves the time of impact for the givenBody
.protected void
solveTOI(ContinuousDetectionMode mode)
protected void
step()
void
step(int steps)
Performs the given number of simulation steps using the step frequency inSettings
.void
step(int steps, double elapsedTime)
Performs the given number of simulation steps using the given elapsed time for each step.boolean
update(double elapsedTime)
Updates theWorld
.boolean
update(double elapsedTime, double stepElapsedTime)
Updates theWorld
.boolean
update(double elapsedTime, double stepElapsedTime, int maximumSteps)
Updates theWorld
.boolean
update(double elapsedTime, int maximumSteps)
Updates theWorld
.void
updatev(double elapsedTime)
Updates theWorld
.



Field Detail

EARTH_GRAVITY
public static final Vector2 EARTH_GRAVITY
Earths gravity constant

ZERO_GRAVITY
public static final Vector2 ZERO_GRAVITY
Zero gravity constant

id
protected final java.util.UUID id
The world id

settings
protected Settings settings
The dynamics settings for this world

gravity
protected Vector2 gravity
The world gravity vector

broadphaseDetector
protected BroadphaseDetector<Body,BodyFixture> broadphaseDetector

detectBroadphaseFilter
protected BroadphaseFilter<Body,BodyFixture> detectBroadphaseFilter
TheBroadphaseFilter
for detection

narrowphaseDetector
protected NarrowphaseDetector narrowphaseDetector

narrowphasePostProcessor
protected NarrowphasePostProcessor narrowphasePostProcessor

manifoldSolver
protected ManifoldSolver manifoldSolver
TheManifoldSolver

timeOfImpactDetector
protected TimeOfImpactDetector timeOfImpactDetector

raycastDetector
protected RaycastDetector raycastDetector
TheRaycastDetector

contactManager
protected ContactManager contactManager
TheContactManager

coefficientMixer
protected CoefficientMixer coefficientMixer
TheCoefficientMixer

contactConstraintSolver
protected ContactConstraintSolver contactConstraintSolver

timeOfImpactSolver
protected TimeOfImpactSolver timeOfImpactSolver

userData
protected java.lang.Object userData
The application data associated


Constructor Detail

World
public World()
Default constructor.Builds a simulation
World
without bounds.Defaults to using
EARTH_GRAVITY
,DynamicAABBTree
broadphase,Gjk
narrowphase, andClippingManifoldSolver
.Uses the
Capacity.DEFAULT_CAPACITY
capacity object for initialization.

World
public World(Capacity initialCapacity)
Optional constructor.Defaults to using
EARTH_GRAVITY
,DynamicAABBTree
broadphase,Gjk
narrowphase, andClippingManifoldSolver
.The initial capacity specifies the estimated number of bodies that the simulation will have at any one time. This is used to size internal structures to improve performance. The internal structures can grow past the initial capacity.
 Parameters:
initialCapacity
 the initial capacity settings Since:
 3.1.1

World
public World(Bounds bounds)
Optional constructor.Defaults to using
EARTH_GRAVITY
,DynamicAABBTree
broadphase,Gjk
narrowphase, andClippingManifoldSolver
. Parameters:
bounds
 the bounds of theWorld
; can be null

World
public World(Capacity initialCapacity, Bounds bounds)
Full constructor.Defaults to using
EARTH_GRAVITY
,DynamicAABBTree
broadphase,Gjk
narrowphase, andClippingManifoldSolver
.The initial capacity specifies the estimated number of bodies that the simulation will have at any one time. This is used to size internal structures to improve performance. The internal structures can grow past the initial capacity.
 Parameters:
initialCapacity
 the initial capacity settingsbounds
 the bounds of theWorld
; can be null Throws:
java.lang.NullPointerException
 if initialCapacity is null Since:
 3.1.1


Method Detail

update
public boolean update(double elapsedTime)
Updates theWorld
.This method will only update the world given the step frequency contained in the
Settings
object. You can use theStepListener
interface to listen for when a step is actually performed. In addition, this method will return true if a step was performed.This method performs, at maximum, one simulation step. Any remaining time from the previous call of this method is added to the given elapsed time to determine if a step needs to be performed. If the given elapsed time is usually greater than the step frequency, consider using the
update(double, int)
method instead.Alternatively you can call the
updatev(double)
method to use a variable time step. Parameters:
elapsedTime
 the elapsed time in seconds Returns:
 boolean true if the
World
performed a simulation step  See Also:
update(double, int)
,updatev(double)
,getAccumulatedTime()

update
public boolean update(double elapsedTime, int maximumSteps)
Updates theWorld
.This method will only update the world given the step frequency contained in the
Settings
object. You can use theStepListener
interface to listen for when a step is actually performed.Unlike the
update(double)
method, this method will perform more than one step based on the given elapsed time. For example, if the given elapsed time + the remaining time from the last call of this method is 2 * step frequency, then 2 steps will be performed. Use the maximumSteps parameter to put an upper bound on the number of steps performed.Alternatively you can call the
updatev(double)
method to use a variable time step. Parameters:
elapsedTime
 the elapsed time in secondsmaximumSteps
 the maximum number of steps to perform Returns:
 boolean true if the
World
performed at least one simulation step  Since:
 3.1.10
 See Also:
update(double)
,updatev(double)
,getAccumulatedTime()

update
public boolean update(double elapsedTime, double stepElapsedTime)
Updates theWorld
.This method will only update the world given the step frequency contained in the
Settings
object. You can use theStepListener
interface to listen for when a step is actually performed. In addition, this method will return true if a step was performed.This method performs, at maximum, one simulation step. Any remaining time from the previous call of this method is added to the given elapsed time to determine if a step needs to be performed. If the given elapsed time is usually greater than the step frequency, consider using the
update(double, int)
method instead.The stepElapsedTime parameter provides a way for the
World
to continue to update at the frequency defined in theSettings
object, but advance the simulation by the given time.Alternatively you can call the
updatev(double)
method to use a variable time step. Parameters:
elapsedTime
 the elapsed time in secondsstepElapsedTime
 the time, in seconds, that the simulation should be advanced Returns:
 boolean true if the
World
performed at least one simulation step  Since:
 3.2.4
 See Also:
update(double)
,updatev(double)
,getAccumulatedTime()

update
public boolean update(double elapsedTime, double stepElapsedTime, int maximumSteps)
Updates theWorld
.This method will only update the world given the step frequency contained in the
Settings
object. You can use theStepListener
interface to listen for when a step is actually performed.Unlike the
update(double)
method, this method will perform more than one step based on the given elapsed time. For example, if the given elapsed time + the remaining time from the last call of this method is 2 * step frequency, then 2 steps will be performed. Use the maximumSteps parameter to put an upper bound on the number of steps performed.The stepElapsedTime parameter provides a way for the
World
to continue to update at the frequency defined in theSettings
object, but advance the simulation by the given time.Alternatively you can call the
updatev(double)
method to use a variable time step. Parameters:
elapsedTime
 the elapsed time in secondsstepElapsedTime
 the time, in seconds, that the simulation should be advanced for each step; if less than or equal to zeroSettings.getStepFrequency()
will be usedmaximumSteps
 the maximum number of steps to perform Returns:
 boolean true if the
World
performed at least one simulation step  Since:
 3.2.4
 See Also:
update(double)
,updatev(double)
,getAccumulatedTime()

updatev
public void updatev(double elapsedTime)
Updates theWorld
.This method will update the world on every call. Unlike the
update(double)
method, this method uses the given elapsed time and does not attempt to update the world on a set interval.This method immediately returns if the given elapsedTime is less than or equal to zero.
 Parameters:
elapsedTime
 the elapsed time in seconds See Also:
update(double)
,update(double, int)

step
public void step(int steps)
Performs the given number of simulation steps using the step frequency inSettings
.This method immediately returns if the given step count is less than or equal to zero.
 Parameters:
steps
 the number of simulation steps to perform

step
public void step(int steps, double elapsedTime)
Performs the given number of simulation steps using the given elapsed time for each step.This method immediately returns if the given elapsedTime or step count is less than or equal to zero.
 Parameters:
steps
 the number of simulation steps to performelapsedTime
 the elapsed time for each step

step
protected void step()
Performs one time step of theWorld
using the currentStep
.This method advances the world by the elapsed time in the
Step
object and performs collision resolution and constraint solving.This method will perform a collision detection sweep at the end to ensure that callers of the world have the latest collision information. If the
isUpdateRequired()
method returns true, a collision detection sweep will be performed before doing collision resolution. See thesetUpdateRequired(boolean)
method for details on when this flag should be set.Use the various listeners to listen for events during the execution of this method.
If possible use the
StepListener.postSolve(Step, World)
method to update any bodies or joints to increase performance.Most
Listener
s do not allow modification of the world, bodies, joints, etc in there methods. It's recommended that any of modification be performed in aStepListener
or after this method has returned.

detect
protected void detect()
Finds new contacts for all bodies in this world.This method performs the following:
 Checks for out of bound bodies
 Updates the broadphase using the current body positions
 Performs broadphase collision detection
 Performs narrowphase collision detection
 Performs manifold solving
 Adds contacts to the contact manager
 Warm starts the contacts
This method will notify all bounds and collision listeners. If any
CollisionListener
returns false, the collision is ignored.This method also notifies any
ContactListener
s. Since:
 3.0.0

solveTOI
protected void solveTOI(ContinuousDetectionMode mode)
Solves the time of impact for all theBody
s in thisWorld
.This method solves for the time of impact for each
Body
iteratively and pairwise.The cases considered are dependent on the given collision detection mode.
Cases skipped (including the converse of the above):
 Inactive, asleep, or nonmoving bodies
 Bodies connected via a joint with the collision flag set to false
 Bodies already in contact
 Fixtures whose filters return false
 Sensor fixtures
 Parameters:
mode
 the continuous collision detection mode Since:
 1.2.0
 See Also:
ContinuousDetectionMode

solveTOI
protected void solveTOI(Body body1, java.util.List<TimeOfImpactListener> listeners)
Solves the time of impact for the givenBody
.This method will find the first
Body
that the givenBody
collides with unless ignored via theTimeOfImpactListener
.If any
TimeOfImpactListener
doesn't allow the collision then the collision is ignored.After the first
Body
is found the twoBody
s are interpolated to the time of impact.Then the
Body
s are position solved using theTimeOfImpactSolver
to force theBody
s into collision. This causes the discrete collision detector to detect the collision on the next time step. Parameters:
body1
 theBody
listeners
 the list ofTimeOfImpactListener
s Since:
 3.1.0

raycast
public boolean raycast(Vector2 start, Vector2 end, boolean ignoreSensors, boolean all, java.util.List<RaycastResult> results)
Performs a raycast against all theBody
s in theWorld
.The given
RaycastResult
list, results, will be filled with the raycast results if the given ray intersected any bodies.The
RaycastResult
class implements the Comparable interface to allow sorting by distance from the ray's origin.If the all flag is false, the results list will only contain the closest result (if any).
All raycasts pass through the
RaycastListener
s before being tested. If anyRaycastListener
doesn't allow the raycast then the body will not be tested.Bodies that contain the start of the ray will not be included in the results.
Inactive bodies are ignored in this test.
 Parameters:
start
 the start pointend
 the end pointignoreSensors
 true if sensorBodyFixture
s should be ignoredall
 true if all intersectedBody
s should be returned; false if only the closestBody
should be returnedresults
 a list to contain the results of the raycast Returns:
 boolean true if at least one
Body
was intersected by theRay
 Throws:
java.lang.NullPointerException
 if start, end, or results is null Since:
 2.0.0
 See Also:
raycast(Ray, double, boolean, boolean, List)
,RaycastListener.allow(Ray, Body, BodyFixture)

raycast
public boolean raycast(Vector2 start, Vector2 end, boolean ignoreSensors, boolean ignoreInactive, boolean all, java.util.List<RaycastResult> results)
Performs a raycast against all theBody
s in theWorld
.The given
RaycastResult
list, results, will be filled with the raycast results if the given ray intersected any bodies.The
RaycastResult
class implements the Comparable interface to allow sorting by distance from the ray's origin.If the all flag is false, the results list will only contain the closest result (if any).
All raycasts pass through the
RaycastListener
s before being tested. If anyRaycastListener
doesn't allow the raycast then the body will not be tested.Bodies that contain the start of the ray will not be included in the results.
 Parameters:
start
 the start pointend
 the end pointignoreSensors
 true if sensorBodyFixture
s should be ignoredignoreInactive
 true if inactive bodies should be ignoredall
 true if all intersectedBody
s should be returned; false if only the closestBody
should be returnedresults
 a list to contain the results of the raycast Returns:
 boolean true if at least one
Body
was intersected by theRay
 Throws:
java.lang.NullPointerException
 if start, end, or results is null Since:
 3.1.9
 See Also:
raycast(Ray, double, boolean, boolean, boolean, List)
,RaycastListener.allow(Ray, Body, BodyFixture)

raycast
public boolean raycast(Vector2 start, Vector2 end, Filter filter, boolean ignoreSensors, boolean ignoreInactive, boolean all, java.util.List<RaycastResult> results)
Performs a raycast against all theBody
s in theWorld
.The given
RaycastResult
list, results, will be filled with the raycast results if the given ray intersected any bodies.The
RaycastResult
class implements the Comparable interface to allow sorting by distance from the ray's origin.If the all flag is false, the results list will only contain the closest result (if any).
All raycasts pass through the
RaycastListener
s before being tested. If anyRaycastListener
doesn't allow the raycast then the body will not be tested.Bodies that contain the start of the ray will not be included in the results.
 Parameters:
start
 the start pointend
 the end pointfilter
 theFilter
to use against the fixtures; can be nullignoreSensors
 true if sensorBodyFixture
s should be ignoredignoreInactive
 true if inactive bodies should be ignoredall
 true if all intersectedBody
s should be returned; false if only the closestBody
should be returnedresults
 a list to contain the results of the raycast Returns:
 boolean true if at least one
Body
was intersected by theRay
 Throws:
java.lang.NullPointerException
 if start, end, or results is null Since:
 3.1.9
 See Also:
raycast(Ray, double, Filter, boolean, boolean, boolean, List)
,RaycastListener.allow(Ray, Body, BodyFixture)

raycast
public boolean raycast(Ray ray, double maxLength, boolean ignoreSensors, boolean all, java.util.List<RaycastResult> results)
Performs a raycast against all theBody
s in theWorld
.The given
RaycastResult
list, results, will be filled with the raycast results if the given ray intersected any bodies.The
RaycastResult
class implements the Comparable interface to allow sorting by distance from the ray's origin.If the all flag is false, the results list will only contain the closest result (if any).
Pass 0 into the maxLength field to specify an infinite length
Ray
.All raycasts pass through the
RaycastListener
s before being tested. If anyRaycastListener
doesn't allow the raycast then the body will not be tested.Bodies that contain the start of the ray will not be included in the results.
Inactive bodies are ignored in this test.
 Parameters:
ray
 theRay
maxLength
 the maximum length of the ray; 0 for infinite lengthignoreSensors
 true if sensorBodyFixture
s should be ignoredall
 true if all intersectedBody
s should be returned; false if only the closestBody
should be returnedresults
 a list to contain the results of the raycast Returns:
 boolean true if at least one
Body
was intersected by the givenRay
 Throws:
java.lang.NullPointerException
 if ray or results is null Since:
 2.0.0
 See Also:
raycast(Vector2, Vector2, boolean, boolean, List)
,RaycastListener.allow(Ray, Body, BodyFixture)

raycast
public boolean raycast(Ray ray, double maxLength, boolean ignoreSensors, boolean ignoreInactive, boolean all, java.util.List<RaycastResult> results)
Performs a raycast against all theBody
s in theWorld
.The given
RaycastResult
list, results, will be filled with the raycast results if the given ray intersected any bodies.The
RaycastResult
class implements the Comparable interface to allow sorting by distance from the ray's origin.If the all flag is false, the results list will only contain the closest result (if any).
Pass 0 into the maxLength field to specify an infinite length
Ray
.All raycasts pass through the
RaycastListener
s before being tested. If anyRaycastListener
doesn't allow the raycast then the body will not be tested.Bodies that contain the start of the ray will not be included in the results.
 Parameters:
ray
 theRay
maxLength
 the maximum length of the ray; 0 for infinite lengthignoreSensors
 true if sensorBodyFixture
s should be ignoredignoreInactive
 true if inactive bodies should be ignoredall
 true if all intersectedBody
s should be returned; false if only the closestBody
should be returnedresults
 a list to contain the results of the raycast Returns:
 boolean true if at least one
Body
was intersected by the givenRay
 Throws:
java.lang.NullPointerException
 if ray or results is null Since:
 3.1.9
 See Also:
raycast(Vector2, Vector2, boolean, boolean, boolean, List)
,RaycastListener.allow(Ray, Body, BodyFixture)

raycast
public boolean raycast(Ray ray, double maxLength, Filter filter, boolean ignoreSensors, boolean ignoreInactive, boolean all, java.util.List<RaycastResult> results)
Performs a raycast against all theBody
s in theWorld
.The given
RaycastResult
list, results, will be filled with the raycast results if the given ray intersected any bodies.The
RaycastResult
class implements the Comparable interface to allow sorting by distance from the ray's origin.If the all flag is false, the results list will only contain the closest result (if any).
Pass 0 into the maxLength field to specify an infinite length
Ray
.All raycasts pass through the
RaycastListener
s before being tested. If anyRaycastListener
doesn't allow the raycast then the body will not be tested.Bodies that contain the start of the ray will not be included in the results.
 Parameters:
ray
 theRay
maxLength
 the maximum length of the ray; 0 for infinite lengthfilter
 theFilter
to use against the fixtures; can be nullignoreSensors
 true if sensorBodyFixture
s should be ignoredignoreInactive
 true if inactive bodies should be ignoredall
 true if all intersectedBody
s should be returned; false if only the closestBody
should be returnedresults
 a list to contain the results of the raycast Returns:
 boolean true if at least one
Body
was intersected by the givenRay
 Throws:
java.lang.NullPointerException
 if ray or results is null Since:
 3.1.9
 See Also:
raycast(Vector2, Vector2, Filter, boolean, boolean, boolean, List)
,RaycastListener.allow(Ray, Body, BodyFixture)

raycast
public boolean raycast(Vector2 start, Vector2 end, Body body, boolean ignoreSensors, RaycastResult result)
Performs a raycast against the givenBody
and returns true if the ray intersects the body.The given
RaycastResult
object, result, will be filled with the raycast result if the given ray intersected the given body.All raycasts pass through the
RaycastListener
s before being tested. If anyRaycastListener
doesn't allow the raycast then the body will not be tested.Returns false if the start position of the ray lies inside the given body.
 Parameters:
start
 the start pointend
 the end pointbody
 theBody
to testignoreSensors
 whether or not to ignore sensorBodyFixture
sresult
 the raycast result Returns:
 boolean true if the
Ray
intersects theBody
 Throws:
java.lang.NullPointerException
 if start, end, body, or result is null Since:
 2.0.0
 See Also:
raycast(Ray, Body, double, boolean, RaycastResult)
,RaycastListener.allow(Ray, Body, BodyFixture)

raycast
public boolean raycast(Vector2 start, Vector2 end, Body body, Filter filter, boolean ignoreSensors, RaycastResult result)
Performs a raycast against the givenBody
and returns true if the ray intersects the body.The given
RaycastResult
object, result, will be filled with the raycast result if the given ray intersected the given body.All raycasts pass through the
RaycastListener
s before being tested. If anyRaycastListener
doesn't allow the raycast then the body will not be tested.Returns false if the start position of the ray lies inside the given body.
 Parameters:
start
 the start pointend
 the end pointbody
 theBody
to testfilter
 theFilter
to use against the fixtures; can be nullignoreSensors
 whether or not to ignore sensorBodyFixture
sresult
 the raycast result Returns:
 boolean true if the
Ray
intersects theBody
 Throws:
java.lang.NullPointerException
 if start, end, body, or result is null Since:
 3.1.9
 See Also:
raycast(Ray, Body, double, Filter, boolean, RaycastResult)
,RaycastListener.allow(Ray, Body, BodyFixture)

raycast
public boolean raycast(Ray ray, Body body, double maxLength, boolean ignoreSensors, RaycastResult result)
Performs a raycast against the givenBody
and returns true if the ray intersects the body.The given
RaycastResult
object, result, will be filled with the raycast result if the given ray intersected the given body.Pass 0 into the maxLength field to specify an infinite length
Ray
.All raycasts pass through the
RaycastListener
s before being tested. If anyRaycastListener
doesn't allow the raycast then the body will not be tested.Returns false if the start position of the ray lies inside the given body.
 Parameters:
ray
 theRay
to castbody
 theBody
to testmaxLength
 the maximum length of the ray; 0 for infinite lengthignoreSensors
 whether or not to ignore sensorBodyFixture
sresult
 the raycast result Returns:
 boolean true if the
Ray
intersects theBody
 Throws:
java.lang.NullPointerException
 if ray, body, or result is null Since:
 2.0.0
 See Also:
raycast(Vector2, Vector2, Body, boolean, RaycastResult)
,RaycastListener.allow(Ray, Body, BodyFixture)

raycast
public boolean raycast(Ray ray, Body body, double maxLength, Filter filter, boolean ignoreSensors, RaycastResult result)
Performs a raycast against the givenBody
and returns true if the ray intersects the body.The given
RaycastResult
object, result, will be filled with the raycast result if the given ray intersected the given body.Pass 0 into the maxLength field to specify an infinite length
Ray
.All raycasts pass through the
RaycastListener
s before being tested. If anyRaycastListener
doesn't allow the raycast then the body will not be tested.Returns false if the start position of the ray lies inside the given body.
 Parameters:
ray
 theRay
to castbody
 theBody
to testmaxLength
 the maximum length of the ray; 0 for infinite lengthfilter
 theFilter
to use against the fixtures; can be nullignoreSensors
 whether or not to ignore sensorBodyFixture
sresult
 the raycast result Returns:
 boolean true if the
Ray
intersects theBody
 Throws:
java.lang.NullPointerException
 if ray, body, or result is null Since:
 3.1.9
 See Also:
raycast(Vector2, Vector2, Body, Filter, boolean, RaycastResult)
,RaycastListener.allow(Ray, Body, BodyFixture)

convexCast
public boolean convexCast(Convex convex, Transform transform, Vector2 deltaPosition, boolean ignoreSensors, boolean all, java.util.List<ConvexCastResult> results)
Performs a linear convex cast on the world, placing any detected collisions into the given results list.This method does a static test of bodies (in other words, does not take into account the bodies linear or angular velocity, but rather assumes they are stationary).
The
deltaPosition
parameter is the linear cast vector determining the direction and magnitude of the cast.The
ConvexCastResult
class implements the Comparable interface to allow sorting by the time of impact.If the all flag is false, the results list will only contain the closest result (if any).
All convex casts pass through the
ConvexCastListener
s before being tested. If anyConvexCastListener
doesn't allow the convex cast, then the body will not be tested.For multifixtured bodies, only the fixture that has the minimum time of impact will be added to the results list.
Bodies in collision with the given convex at the beginning of the cast are not included in the results.
Inactive bodies are ignored in this test.
 Parameters:
convex
 the convex to casttransform
 the initial position and orientation of the convexdeltaPosition
 Δposition; the change in position (the cast length and direction basically)ignoreSensors
 true if sensor fixtures should be ignored in the testsall
 true if all hits should be returned; false if only the first should be returnedresults
 the list to add the results to Returns:
 boolean true if a collision was found
 Since:
 3.1.5
 See Also:
convexCast(Convex, Transform, Vector2, double, boolean, boolean, boolean, List)

convexCast
public boolean convexCast(Convex convex, Transform transform, Vector2 deltaPosition, boolean ignoreSensors, boolean ignoreInactive, boolean all, java.util.List<ConvexCastResult> results)
Performs a linear convex cast on the world, placing any detected collisions into the given results list.This method does a static test of bodies (in other words, does not take into account the bodies linear or angular velocity, but rather assumes they are stationary).
The
deltaPosition
parameter is the linear cast vector determining the direction and magnitude of the cast.The
ConvexCastResult
class implements the Comparable interface to allow sorting by the time of impact.If the all flag is false, the results list will only contain the closest result (if any).
All convex casts pass through the
ConvexCastListener
s before being tested. If anyConvexCastListener
doesn't allow the convex cast, then the body will not be tested.For multifixtured bodies, only the fixture that has the minimum time of impact will be added to the results list.
Bodies in collision with the given convex at the beginning of the cast are not included in the results.
 Parameters:
convex
 the convex to casttransform
 the initial position and orientation of the convexdeltaPosition
 Δposition; the change in position (the cast length and direction basically)ignoreSensors
 true if sensor fixtures should be ignored in the testsignoreInactive
 true if inactive bodies should be ignored in the testsall
 true if all hits should be returned; false if only the first should be returnedresults
 the list to add the results to Returns:
 boolean true if a collision was found
 Since:
 3.1.9
 See Also:
convexCast(Convex, Transform, Vector2, double, boolean, boolean, boolean, List)

convexCast
public boolean convexCast(Convex convex, Transform transform, Vector2 deltaPosition, double deltaAngle, boolean ignoreSensors, boolean all, java.util.List<ConvexCastResult> results)
Performs a linear convex cast on the world, placing any detected collisions into the given results list.This method does a static test of bodies (in other words, does not take into account the bodies linear or angular velocity, but rather assumes they are stationary).
The
deltaPosition
parameter is the linear cast vector determining the direction and magnitude of the cast. ThedeltaAngle
parameter is the change in angle over the linear cast and is interpolated linearly during detection.The
ConvexCastResult
class implements the Comparable interface to allow sorting by the time of impact.If the all flag is false, the results list will only contain the closest result (if any).
All convex casts pass through the
ConvexCastListener
s before being tested. If anyConvexCastListener
doesn't allow the convex cast, then the body will not be tested.For multifixtured bodies, only the fixture that has the minimum time of impact will be added to the results list.
Bodies in collision with the given convex at the beginning of the cast are not included in the results.
Inactive bodies are ignored in this test.
 Parameters:
convex
 the convex to casttransform
 the initial position and orientation of the convexdeltaPosition
 Δposition; the change in position (the cast length and direction basically)deltaAngle
 Δangle; the change in the angle; this is the change in the angle over the linear periodignoreSensors
 true if sensor fixtures should be ignored in the testsall
 true if all hits should be returned; false if only the first should be returnedresults
 the list to add the results to Returns:
 boolean true if a collision was found
 Since:
 3.1.5
 See Also:
convexCast(Convex, Transform, Vector2, double, boolean, boolean, boolean, List)

convexCast
public boolean convexCast(Convex convex, Transform transform, Vector2 deltaPosition, double deltaAngle, boolean ignoreSensors, boolean ignoreInactive, boolean all, java.util.List<ConvexCastResult> results)
Performs a linear convex cast on the world, placing any detected collisions into the given results list.This method does a static test of bodies (in other words, does not take into account the bodies linear or angular velocity, but rather assumes they are stationary).
The
deltaPosition
parameter is the linear cast vector determining the direction and magnitude of the cast. ThedeltaAngle
parameter is the change in angle over the linear cast and is interpolated linearly during detection.The
ConvexCastResult
class implements the Comparable interface to allow sorting by the time of impact.If the all flag is false, the results list will only contain the closest result (if any).
All convex casts pass through the
ConvexCastListener
s before being tested. If anyConvexCastListener
doesn't allow the convex cast, then the body will not be tested.For multifixtured bodies, only the fixture that has the minimum time of impact will be added to the results list.
Bodies in collision with the given convex at the beginning of the cast are not included in the results.
 Parameters:
convex
 the convex to casttransform
 the initial position and orientation of the convexdeltaPosition
 Δposition; the change in position (the cast length and direction basically)deltaAngle
 Δangle; the change in the angle; this is the change in the angle over the linear periodignoreSensors
 true if sensor fixtures should be ignored in the testsignoreInactive
 true if inactive bodies should be ignored in the testsall
 true if all hits should be returned; false if only the first should be returnedresults
 the list to add the results to Returns:
 boolean true if a collision was found
 Since:
 3.1.9

convexCast
public boolean convexCast(Convex convex, Transform transform, Vector2 deltaPosition, double deltaAngle, Filter filter, boolean ignoreSensors, boolean ignoreInactive, boolean all, java.util.List<ConvexCastResult> results)
Performs a linear convex cast on the world, placing any detected collisions into the given results list.This method does a static test of bodies (in other words, does not take into account the bodies linear or angular velocity, but rather assumes they are stationary).
The
deltaPosition
parameter is the linear cast vector determining the direction and magnitude of the cast. ThedeltaAngle
parameter is the change in angle over the linear cast and is interpolated linearly during detection.The
ConvexCastResult
class implements the Comparable interface to allow sorting by the time of impact.If the all flag is false, the results list will only contain the closest result (if any).
All convex casts pass through the
ConvexCastListener
s before being tested. If anyConvexCastListener
doesn't allow the convex cast, then the body will not be tested.For multifixtured bodies, only the fixture that has the minimum time of impact will be added to the results list.
Bodies in collision with the given convex at the beginning of the cast are not included in the results.
 Parameters:
convex
 the convex to casttransform
 the initial position and orientation of the convexdeltaPosition
 Δposition; the change in position (the cast length and direction basically)deltaAngle
 Δangle; the change in the angle; this is the change in the angle over the linear periodfilter
 theFilter
to use against the fixtures; can be nullignoreSensors
 true if sensor fixtures should be ignored in the testsignoreInactive
 true if inactive bodies should be ignored in the testsall
 true if all hits should be returned; false if only the first should be returnedresults
 the list to add the results to Returns:
 boolean true if a collision was found
 Since:
 3.1.9

convexCast
public boolean convexCast(Convex convex, Transform transform, Vector2 deltaPosition, Body body, boolean ignoreSensors, ConvexCastResult result)
Performs a linear convex cast on the given body, placing a detected collision into the given result object.This method does a static test of the body (in other words, does not take into account the body's linear or angular velocity, but rather assumes it is stationary).
The
deltaPosition
parameter is the linear cast vector determining the direction and magnitude of the cast.All convex casts pass through the
ConvexCastListener
s before being tested. If anyConvexCastListener
doesn't allow the convex cast, then the body will not be tested.For multifixtured bodies, the fixture that has the minimum time of impact will be the result.
Returns false if the given body and convex are in collision at the beginning of the cast.
 Parameters:
convex
 the convex to casttransform
 the initial position and orientation of the convexdeltaPosition
 Δposition; the change in position (the cast length and direction basically)body
 the body to cast againstignoreSensors
 true if sensor fixtures should be ignored in the testsresult
 the convex cast result Returns:
 boolean true if a collision was found
 Since:
 3.1.5

convexCast
public boolean convexCast(Convex convex, Transform transform, Vector2 deltaPosition, double deltaAngle, Body body, boolean ignoreSensors, ConvexCastResult result)
Performs a linear convex cast on the given body, placing a detected collision into the given result object.This method does a static test of the body (in other words, does not take into account the body's linear or angular velocity, but rather assumes it is stationary).
The
deltaPosition
parameter is the linear cast vector determining the direction and magnitude of the cast. ThedeltaAngle
parameter is the change in angle over the linear cast and is interpolated linearly during detection.All convex casts pass through the
ConvexCastListener
s before being tested. If anyConvexCastListener
doesn't allow the convex cast, then the body will not be tested.For multifixtured bodies, the fixture that has the minimum time of impact will be the result.
Returns false if the given body and convex are in collision at the beginning of the cast.
 Parameters:
convex
 the convex to casttransform
 the initial position and orientation of the convexdeltaPosition
 Δposition; the change in position (the cast length and direction basically)deltaAngle
 Δangle; the change in the angle; this is the change in the angle over the linear periodbody
 the body to cast againstignoreSensors
 true if sensor fixtures should be ignored in the testsresult
 the convex cast result Returns:
 boolean true if a collision was found
 Since:
 3.1.5

convexCast
public boolean convexCast(Convex convex, Transform transform, Vector2 deltaPosition, double deltaAngle, Body body, Filter filter, boolean ignoreSensors, ConvexCastResult result)
Performs a linear convex cast on the given body, placing a detected collision into the given result object.This method does a static test of the body (in other words, does not take into account the body's linear or angular velocity, but rather assumes it is stationary).
The
deltaPosition
parameter is the linear cast vector determining the direction and magnitude of the cast. ThedeltaAngle
parameter is the change in angle over the linear cast and is interpolated linearly during detection.All convex casts pass through the
ConvexCastListener
s before being tested. If anyConvexCastListener
doesn't allow the convex cast, then the body will not be tested.For multifixtured bodies, the fixture that has the minimum time of impact will be the result.
Returns false if the given body and convex are in collision at the beginning of the cast.
 Parameters:
convex
 the convex to casttransform
 the initial position and orientation of the convexdeltaPosition
 Δposition; the change in position (the cast length and direction basically)deltaAngle
 Δangle; the change in the angle; this is the change in the angle over the linear periodbody
 the body to cast againstfilter
 theFilter
to use against the fixtures; can be nullignoreSensors
 true if sensor fixtures should be ignored in the testsresult
 the convex cast result Returns:
 boolean true if a collision was found
 Since:
 3.1.9

detect
public boolean detect(AABB aabb, java.util.List<DetectResult> results)
Returns true if the given AABB overlaps aBody
in thisWorld
.If any part of a body is overlaping the AABB, the body is added to the list.
This performs a static collision test of the world using the
BroadphaseDetector
.This may return bodies who only have sensor fixtures overlapping.
Inactive bodies are ignored in this test.
 Parameters:
aabb
 the world spaceAABB
results
 the list of overlapping bodies and fixtures Returns:
 boolean true if the AABB overlaps any body
 Since:
 3.1.9

detect
public boolean detect(AABB aabb, boolean ignoreInactive, java.util.List<DetectResult> results)
Returns true if the given AABB overlaps aBody
Fixture
in thisWorld
.If any part of a body is overlaping the AABB, the body and that respective fixture is added to the returned list.
This performs a static collision test of the world using the
BroadphaseDetector
.This may return bodies who only have sensor fixtures overlapping.
 Parameters:
aabb
 the world spaceAABB
ignoreInactive
 true if inactive bodies should be ignoredresults
 the list of overlapping bodies and fixtures Returns:
 boolean true if the AABB overlaps any body
 Since:
 3.1.9

detect
public boolean detect(AABB aabb, boolean ignoreSensors, boolean ignoreInactive, java.util.List<DetectResult> results)
Returns true if the given AABB overlaps aBody
in thisWorld
.If this method returns true, the results list will contain the bodies and fixtures that the convex overlaps.
 Parameters:
aabb
 the world spaceAABB
ignoreSensors
 true if sensor fixtures should be ignoredignoreInactive
 true if inactive bodies should be ignoredresults
 the list of overlapping bodies and fixtures Returns:
 boolean true if the AABB overlaps any fixture
 Since:
 3.1.9

detect
public boolean detect(AABB aabb, Filter filter, boolean ignoreSensors, boolean ignoreInactive, java.util.List<DetectResult> results)
Returns true if the given AABB overlaps aBody
in thisWorld
.If this method returns true, the results list will contain the bodies and fixtures that the convex overlaps.
 Parameters:
aabb
 the world spaceAABB
filter
 theFilter
to use against the fixtures; can be nullignoreSensors
 true if sensor fixtures should be ignoredignoreInactive
 true if inactive bodies should be ignoredresults
 the list of overlapping bodies and fixtures Returns:
 boolean true if the AABB overlaps any fixture
 Since:
 3.1.9

detect
public boolean detect(Convex convex, java.util.List<DetectResult> results)
Returns true if the givenConvex
overlaps a body in the world.If this method returns true, the results list will contain the bodies and fixtures that the convex overlaps.
Use the
Body.isInContact(Body)
method instead if you want to test if two bodies are colliding.The returned results may include sensor fixutres.
Inactive bodies are ignored in this test.
The results from this test will not include
Penetration
objects. Parameters:
convex
 the convex shape in world coordinatesresults
 the list of overlapping bodies and fixtures Returns:
 boolean true if an overlap was found
 Since:
 3.1.9
 See Also:
detect(Convex, boolean, List)

detect
public boolean detect(Convex convex, boolean ignoreSensors, java.util.List<DetectResult> results)
Returns true if the givenConvex
overlaps a body in the world.If this method returns true, the results list will contain the bodies and fixtures that the convex overlaps.
Use the
Body.isInContact(Body)
method instead if you want to test if two bodies are colliding.Inactive bodies are ignored in this test.
The results from this test will not include
Penetration
objects. Parameters:
convex
 the convex shape in world coordinatesignoreSensors
 true if sensor fixtures should be ignoredresults
 the list of overlapping bodies and fixtures Returns:
 boolean true if an overlap was found
 Since:
 3.1.9
 See Also:
detect(Convex, boolean, boolean, List)

detect
public boolean detect(Convex convex, boolean ignoreSensors, boolean ignoreInactive, java.util.List<DetectResult> results)
Returns true if the givenConvex
overlaps a body in the world.If this method returns true, the results list will contain the bodies and fixtures that the convex overlaps.
Use the
Body.isInContact(Body)
method instead if you want to test if two bodies are colliding.The results from this test will not include
Penetration
objects. Parameters:
convex
 the convex shape in world coordinatesignoreSensors
 true if sensor fixtures should be ignoredignoreInactive
 true if inactive bodies should be ignoredresults
 the list of overlapping bodies and fixtures Returns:
 boolean true if an overlap was found
 Since:
 3.1.9
 See Also:
detect(Convex, Transform, Filter, boolean, boolean, List)

detect
public boolean detect(Convex convex, Filter filter, boolean ignoreSensors, boolean ignoreInactive, java.util.List<DetectResult> results)
Returns true if the givenConvex
overlaps a body in the world.If this method returns true, the results list will contain the bodies and fixtures that the convex overlaps.
Use the
Body.isInContact(Body)
method instead if you want to test if two bodies are colliding.The results from this test will not include
Penetration
objects. Parameters:
convex
 the convex shape in world coordinatesfilter
 theFilter
to use against the fixtures; can be nullignoreSensors
 true if sensor fixtures should be ignoredignoreInactive
 true if inactive bodies should be ignoredresults
 the list of overlapping bodies and fixtures Returns:
 boolean true if an overlap was found
 Since:
 3.1.9
 See Also:
detect(Convex, Transform, Filter, boolean, boolean, boolean, List)

detect
public boolean detect(Convex convex, Filter filter, boolean ignoreSensors, boolean ignoreInactive, boolean includeCollisionData, java.util.List<DetectResult> results)
Returns true if the givenConvex
overlaps a body in the world.If this method returns true, the results list will contain the bodies and fixtures that the convex overlaps.
Use the
Body.isInContact(Body)
method instead if you want to test if two bodies are colliding.Use the
includeCollisionData
parameter to have thePenetration
object filled in theDetectResult
s. Including this information will have a performance impact. Parameters:
convex
 the convex shape in world coordinatesfilter
 theFilter
to use against the fixtures; can be nullignoreSensors
 true if sensor fixtures should be ignoredignoreInactive
 true if inactive bodies should be ignoredincludeCollisionData
 true if the overlapPenetration
should be returnedresults
 the list of overlapping bodies and fixtures Returns:
 boolean true if an overlap was found
 Since:
 3.1.9

detect
public boolean detect(Convex convex, Transform transform, java.util.List<DetectResult> results)
Returns true if the givenConvex
overlaps a body in the world.If this method returns true, the results list will contain the bodies and fixtures that the convex overlaps.
Use the
Body.isInContact(Body)
method instead if you want to test if two bodies are colliding.The returned results may include sensor fixutres.
Inactive bodies are ignored in this test.
The results from this test will not include
Penetration
objects. Parameters:
convex
 the convex shape in local coordinatestransform
 the convex shape's world transformresults
 the list of overlapping bodies and fixtures Returns:
 boolean true if an overlap was found
 Since:
 3.1.9
 See Also:
detect(Convex, Transform, boolean, List)

detect
public boolean detect(Convex convex, Transform transform, boolean ignoreSensors, java.util.List<DetectResult> results)
Returns true if the givenConvex
overlaps a body in the world.If this method returns true, the results list will contain the bodies and fixtures that the convex overlaps.
Use the
Body.isInContact(Body)
method instead if you want to test if two bodies are colliding.Inactive bodies are ignored in this test.
The results from this test will not include
Penetration
objects. Parameters:
convex
 the convex shape in local coordinatestransform
 the convex shape's world transformignoreSensors
 true if sensor fixtures should be ignoredresults
 the list of overlapping bodies and fixtures Returns:
 boolean true if an overlap was found
 Since:
 3.1.9
 See Also:
detect(Convex, Transform, boolean, boolean, List)

detect
public boolean detect(Convex convex, Transform transform, boolean ignoreSensors, boolean ignoreInactive, java.util.List<DetectResult> results)
Returns true if the givenConvex
overlaps a body in the world.If this method returns true, the results list will contain the bodies and fixtures that the convex overlaps.
Use the
Body.isInContact(Body)
method instead if you want to test if two bodies are colliding.The results from this test will not include
Penetration
objects. Parameters:
convex
 the convex shape in local coordinatestransform
 the convex shape's world transformignoreSensors
 true if sensor fixtures should be ignoredignoreInactive
 true if inactive bodies should be ignoredresults
 the list of overlapping bodies and fixtures Returns:
 boolean true if an overlap was found
 Since:
 3.1.9
 See Also:
detect(Convex, Transform, Filter, boolean, boolean, List)

detect
public boolean detect(Convex convex, Transform transform, Filter filter, boolean ignoreSensors, boolean ignoreInactive, java.util.List<DetectResult> results)
Returns true if the givenConvex
overlaps a body in the world.If this method returns true, the results list will contain the bodies and fixtures that the convex overlaps.
Use the
Body.isInContact(Body)
method instead if you want to test if two bodies are colliding.The results from this test will not include
Penetration
objects. Parameters:
convex
 the convex shape in local coordinatestransform
 the convex shape's world transformfilter
 theFilter
to use against the fixtures; can be nullignoreSensors
 true if sensor fixtures should be ignoredignoreInactive
 true if inactive bodies should be ignoredresults
 the list of overlapping bodies and fixtures Returns:
 boolean true if an overlap was found
 Since:
 3.1.9
 See Also:
detect(Convex, Transform, Filter, boolean, boolean, boolean, List)

detect
public boolean detect(Convex convex, Transform transform, Filter filter, boolean ignoreSensors, boolean ignoreInactive, boolean includeCollisionData, java.util.List<DetectResult> results)
Returns true if the givenConvex
overlaps a body in the world.If this method returns true, the results list will contain the bodies and fixtures that the convex overlaps.
Use the
Body.isInContact(Body)
method instead if you want to test if two bodies are colliding.Use the
includeCollisionData
parameter to have thePenetration
object filled in theDetectResult
s. Including this information will have a performance impact. Parameters:
convex
 the convex shape in local coordinatestransform
 the convex shape's world transformfilter
 theFilter
to use against the fixtures; can be nullignoreSensors
 true if sensor fixtures should be ignoredignoreInactive
 true if inactive bodies should be ignoredincludeCollisionData
 true if the overlapPenetration
should be returnedresults
 the list of overlapping bodies and fixtures Returns:
 boolean true if an overlap was found
 Since:
 3.1.9

detect
public boolean detect(AABB aabb, Body body, boolean ignoreSensors, java.util.List<DetectResult> results)
Returns true if the givenAABB
overlaps the given body in the world.If this method returns true, the results list will contain the bodies and fixtures that the AABB overlaps.
Use the
Body.isInContact(Body)
method instead if you want to test if two bodies are colliding.

detect
public boolean detect(AABB aabb, Body body, Filter filter, boolean ignoreSensors, java.util.List<DetectResult> results)
Returns true if the givenAABB
overlaps the given body in the world.If this method returns true, the results list will contain the bodies and fixtures that the AABB overlaps.
Use the
Body.isInContact(Body)
method instead if you want to test if two bodies are colliding. Parameters:
aabb
 theAABB
in world coordinatesbody
 theBody
to test againstfilter
 theFilter
to use against the fixtures; can be nullignoreSensors
 true if sensor fixtures should be ignoredresults
 the list of overlapping bodies and fixtures Returns:
 boolean true if an overlap was found
 Since:
 3.1.9

detect
public boolean detect(Convex convex, Body body, boolean ignoreSensors, java.util.List<DetectResult> results)
Returns true if the givenConvex
overlaps the given body in the world.If this method returns true, the results list will contain the bodies and fixtures that the convex overlaps.
Use the
Body.isInContact(Body)
method instead if you want to test if two bodies are colliding.The results from this test will not include
Penetration
objects.

detect
public boolean detect(Convex convex, Body body, Filter filter, boolean ignoreSensors, java.util.List<DetectResult> results)
Returns true if the givenConvex
overlaps the given body in the world.If this method returns true, the results list will contain the bodies and fixtures that the convex overlaps.
Use the
Body.isInContact(Body)
method instead if you want to test if two bodies are colliding.The results from this test will not include
Penetration
objects. Parameters:
convex
 theConvex
in world coordinatesbody
 theBody
to test againstfilter
 theFilter
to use against the fixtures; can be nullignoreSensors
 true if sensor fixtures should be ignoredresults
 the list of overlapping bodies and fixtures Returns:
 boolean true if an overlap was found
 Since:
 3.1.9

detect
public boolean detect(Convex convex, Body body, Filter filter, boolean ignoreSensors, boolean includeCollisionData, java.util.List<DetectResult> results)
Returns true if the givenConvex
overlaps the given body in the world.If this method returns true, the results list will contain the bodies and fixtures that the convex overlaps.
Use the
Body.isInContact(Body)
method instead if you want to test if two bodies are colliding.Use the
includeCollisionData
parameter to have thePenetration
object filled in theDetectResult
s. Including this information negatively impacts performance. Parameters:
convex
 theConvex
in world coordinatesbody
 theBody
to test againstfilter
 theFilter
to use against the fixtures; can be nullincludeCollisionData
 true if the overlapPenetration
should be returnedignoreSensors
 true if sensor fixtures should be ignoredresults
 the list of overlapping bodies and fixtures Returns:
 boolean true if an overlap was found
 Since:
 3.1.9

detect
public boolean detect(Convex convex, Transform transform, Body body, boolean ignoreSensors, java.util.List<DetectResult> results)
Returns true if the givenConvex
overlaps the given body in the world.If this method returns true, the results list will contain the bodies and fixtures that the convex overlaps.
Use the
Body.isInContact(Body)
method instead if you want to test if two bodies are colliding.The results from this test will not include
Penetration
objects. Parameters:
convex
 theConvex
in local coordinatestransform
 the convex shape's worldTransform
body
 theBody
to test againstignoreSensors
 true if sensor fixtures should be ignoredresults
 the list of overlapping bodies and fixtures Returns:
 boolean true if an overlap was found
 Since:
 3.1.9

detect
public boolean detect(Convex convex, Transform transform, Body body, Filter filter, boolean ignoreSensors, java.util.List<DetectResult> results)
Returns true if the givenConvex
overlaps the given body in the world.If this method returns true, the results list will contain the bodies and fixtures that the convex overlaps.
Use the
Body.isInContact(Body)
method instead if you want to test if two bodies are colliding.The results from this test will not include
Penetration
objects. Parameters:
convex
 theConvex
in local coordinatestransform
 the convex shape's worldTransform
body
 theBody
to test againstfilter
 theFilter
to use against the fixtures; can be nullignoreSensors
 true if sensor fixtures should be ignoredresults
 the list of overlapping bodies and fixtures Returns:
 boolean true if an overlap was found
 Since:
 3.1.9

detect
public boolean detect(Convex convex, Transform transform, Body body, Filter filter, boolean ignoreSensors, boolean includeCollisionData, java.util.List<DetectResult> results)
Returns true if the givenConvex
overlaps the given body in the world.If this method returns true, the results list will contain the bodies and fixtures that the convex overlaps.
Use the
Body.isInContact(Body)
method instead if you want to test if two bodies are colliding.Use the
includeCollisionData
parameter to have thePenetration
object filled in theDetectResult
s. Including this information negatively impacts performance. Parameters:
convex
 theConvex
in local coordinatestransform
 the convex shape's worldTransform
body
 theBody
to test againstfilter
 theFilter
to use against the fixtures; can be nullincludeCollisionData
 true if the overlapPenetration
should be returnedignoreSensors
 true if sensor fixtures should be ignoredresults
 the list of overlapping bodies and fixtures Returns:
 boolean true if an overlap was found
 Since:
 3.1.9

shift
public void shift(Vector2 shift)
Shifts the coordinates of the entire world by the given amount.NewPosition = OldPosition + shift
This method is useful in situations where the world is very large causing very large numbers to be used in the computations. Shifting the coordinate system allows the computations to be localized and retain accuracy.This method modifies the coordinates of every body and joint in the world.
Adding joints or bodies after this method is called should consider that everything has been shifted.
This method does NOT require a call to
setUpdateRequired(boolean)
.

addBody
public void addBody(Body body)
 Parameters:
body
 theBody
to add Throws:
java.lang.NullPointerException
 if body is nulljava.lang.IllegalArgumentException
 if body has already been added to this world or if its a member of another world instance Since:
 3.1.1

addJoint
public void addJoint(Joint joint)
 Parameters:
joint
 theJoint
to add Throws:
java.lang.NullPointerException
 if joint is nulljava.lang.IllegalArgumentException
 if joint has already been added to this world or if its a member of another world instance Since:
 3.1.1

containsBody
public boolean containsBody(Body body)
Returns true if this world contains the given body. Parameters:
body
 theBody
to test for Returns:
 boolean true if the body is contained in this world
 Since:
 3.1.1

containsJoint
public boolean containsJoint(Joint joint)
Returns true if this world contains the given joint. Parameters:
joint
 theJoint
to test for Returns:
 boolean true if the joint is contained in this world
 Since:
 3.1.1

removeBody
public boolean removeBody(int index)
Removes theBody
at the given index from thisWorld
.Use the
removeBody(int, boolean)
method to enable implicit destruction notification. Parameters:
index
 the index of the body to remove. Returns:
 boolean true if the body was removed
 Since:
 3.2.0

removeBody
public boolean removeBody(int index, boolean notify)
Removes theBody
at the given index from thisWorld
.When a body is removed, joints and contacts may be implicitly destroyed. Pass true to the notify parameter to be notified of the destruction of these objects via the
DestructionListener
s.This method does not trigger
ContactListener.end(ContactPoint)
events for the contacts that are being removed. Parameters:
index
 the index of the body to remove.notify
 true if implicit destruction should be notified Returns:
 boolean true if the body was removed
 Since:
 3.2.0

removeBody
public boolean removeBody(Body body)
Removes the givenBody
from thisWorld
.Use the
removeBody(Body, boolean)
method to enable implicit destruction notification. Parameters:
body
 theBody
to remove. Returns:
 boolean true if the body was removed

removeBody
public boolean removeBody(Body body, boolean notify)
Removes the givenBody
from thisWorld
.When a body is removed, joints and contacts may be implicitly destroyed. Pass true to the notify parameter to be notified of the destruction of these objects via the
DestructionListener
s.This method does not trigger
ContactListener.end(ContactPoint)
events for the contacts that are being removed. Parameters:
body
 theBody
to removenotify
 true if implicit destruction should be notified Returns:
 boolean true if the body was removed
 Since:
 3.1.1

removeJoint
public boolean removeJoint(int index)

removeJoint
public boolean removeJoint(Joint joint)

removeAllBodiesAndJoints
public void removeAllBodiesAndJoints()
Removes all the joints and bodies from this world.This method does not notify of destroyed objects.
 Since:
 3.1.1
 See Also:
removeAllBodiesAndJoints(boolean)

removeAllBodiesAndJoints
public void removeAllBodiesAndJoints(boolean notify)
Removes all the joints and bodies from this world. Parameters:
notify
 true if destruction of joints and contacts should be notified of by theDestructionListener
 Since:
 3.1.1

removeAllBodies
public void removeAllBodies()
This is a convenience method for theremoveAllBodiesAndJoints()
method since all joints will be removed when all bodies are removed anyway.This method does not notify of the destroyed contacts, joints, etc.
 Since:
 3.0.1
 See Also:
removeAllBodies(boolean)

removeAllBodies
public void removeAllBodies(boolean notify)
This is a convenience method for theremoveAllBodiesAndJoints(boolean)
method since all joints will be removed when all bodies are removed anyway. Parameters:
notify
 true if destruction of joints and contacts should be notified of by theDestructionListener
 Since:
 3.0.1

removeAllJoints
public void removeAllJoints()
 Since:
 3.0.1
 See Also:
removeAllJoints(boolean)

removeAllJoints
public void removeAllJoints(boolean notify)
 Parameters:
notify
 true if destruction of joints should be notified of by theDestructionListener
 Since:
 3.0.1

isUpdateRequired
public boolean isUpdateRequired()
Returns true if upon the next time step the contacts must be updated.This is typically set via user code when something about the simulation changes that can affect collision detection.
 Returns:
 boolean
 See Also:
setUpdateRequired(boolean)

setUpdateRequired
public void setUpdateRequired(boolean flag)
Sets the update required flag.Set this flag to true if any of the following conditions have been met:
 If a Body has been added or removed from the World
 If a Body has been translated or rotated
 If a Body's state has been manually changed via the Body.setActive(boolean) method
 If a BodyFixture has been added or removed from a Body
 If a BodyFixture's sensor flag has been manually changed via the BodyFixture.setSensor(boolean) method
 If a BodyFixture's filter has been manually changed via the BodyFixture.setFilter(boolean) method
 If a BodyFixture's restitution or friction coefficient has changed
 If a BodyFixture's Shape has been translated or rotated
 If a BodyFixture's Shape has been changed (vertices, radius, etc.)
 If a Body's type has changed to or from Static (this is caused by the using setMassType(Mass.INFINITE/Mass.NORMAL) method)
 If a Joint has been added or removed from the World in which the joined bodies should not be allowed to collide
 If the World's CoefficientMixer has been changed
 Parameters:
flag
 the flag

getId
@Deprecated public java.util.UUID getId()
Deprecated.ID schemes should be implemented by the user where needed; since 3.4.0Returns the world id. Returns:
 UUID
 Since:
 3.2.0

getSettings
public Settings getSettings()
Returns the settings for this world. Returns:
Settings
 Since:
 3.0.3

setSettings
public void setSettings(Settings settings)
Sets the dynamics settings for this world. Parameters:
settings
 the desired settings Throws:
java.lang.NullPointerException
 if the given settings is null Since:
 3.0.3

setGravity
public void setGravity(Vector2 gravity)
Sets the acceleration due to gravity. Parameters:
gravity
 the gravity in meters/second^{2} Throws:
java.lang.NullPointerException
 if gravity is null

getGravity
public Vector2 getGravity()
Returns the acceleration due to gravity. Returns:
Vector2
the gravity in meters/second^{2}

setBounds
public void setBounds(Bounds bounds)
Sets the bounds of thisWorld
. Parameters:
bounds
 the bounds; can be null

getBounds
public Bounds getBounds()
Returns the bounds of this world.This will return null if no bounds were initially set or if it was set to null via the
setBounds(Bounds)
method. Returns:
Bounds
the bounds or null

getListeners
public <T extends Listener> java.util.List<T> getListeners(java.lang.Class<T> clazz)
Returns the listeners that are of the given type (or sub types) of the given type.Returns an empty list if no listeners for the given type are found.
Returns null if clazz is null.
Example usage:
world.getListeners(ContactListener.class);
 Type Parameters:
T
 the listener type Parameters:
clazz
 the type of listener to get Returns:
 List<T>
 Since:
 3.1.0

getListeners
public <T extends Listener> void getListeners(java.lang.Class<T> clazz, java.util.List<T> listeners)
Returns the listeners of the given type (or sub types) in the given list.This method does not clear the given listeners list before adding the listeners.
If clazz or listeners is null, this method immediately returns.
Example usage:
List<ContactListener> list = ...; world.getListeners(ContactListener.class, list);
 Type Parameters:
T
 the listener type Parameters:
clazz
 the type of listener to getlisteners
 the list to add the listeners to Since:
 3.1.1

addListener
public void addListener(Listener listener)
Adds the given listener to the list of listeners. Parameters:
listener
 the listener Throws:
java.lang.NullPointerException
 if the given listener is nulljava.lang.IllegalArgumentException
 if the given listener has already been added to this world Since:
 3.1.0

containsListener
public boolean containsListener(Listener listener)
Returns true if the given listener is already attached to this world. Parameters:
listener
 the listener Returns:
 boolean
 Since:
 3.1.1

removeListener
public boolean removeListener(Listener listener)
Removes the given listener from this world. Parameters:
listener
 the listener to remove Returns:
 boolean true if the listener was removed
 Since:
 3.1.0

removeAllListeners
public int removeAllListeners()
Removes all the listeners. Returns:
 int the number of listeners removed
 Since:
 3.1.1

removeAllListeners
public <T extends Listener> int removeAllListeners(java.lang.Class<T> clazz)
Removes all the listeners of the specified type (or sub types).Returns zero if the given type is null or there are zero listeners attached.
Example usage:
world.removeAllListeners(ContactListener.class);
 Type Parameters:
T
 the listener type Parameters:
clazz
 the listener type Returns:
 int the number of listeners removed
 Since:
 3.1.1

getListenerCount
public int getListenerCount()
Returns the total number of listeners attached to this world. Returns:
 int
 Since:
 3.1.1

getListenerCount
public <T extends Listener> int getListenerCount(java.lang.Class<T> clazz)
Returns the total number of listeners of the given type (or sub types) attached to this world.Returns zero if the given class type is null.
Example usage:
world.getListenerCount(BoundsListener.class);
 Type Parameters:
T
 the listener type Parameters:
clazz
 the listener type Returns:
 int
 Since:
 3.1.1

setBroadphaseDetector
public void setBroadphaseDetector(BroadphaseDetector<Body,BodyFixture> broadphaseDetector)
Sets the broadphase collision detection algorithm. Parameters:
broadphaseDetector
 the broadphase collision detection algorithm Throws:
java.lang.NullPointerException
 if broadphaseDetector is null

getBroadphaseDetector
public BroadphaseDetector<Body,BodyFixture> getBroadphaseDetector()
Returns the broadphase collision detection algorithm. Returns:
BroadphaseDetector
the broadphase collision detection algorithm

setDetectBroadphaseFilter
public void setDetectBroadphaseFilter(BroadphaseFilter<Body,BodyFixture> filter)
Sets theBroadphaseFilter
used when detecting collisions for each time step.This should always be an instance of a class that extends the
DetectBroadphaseFilter
so that the standard filters are retained. Parameters:
filter
 the filter Since:
 3.2.2

getDetectBroadphaseFilter
public BroadphaseFilter<Body,BodyFixture> getDetectBroadphaseFilter()
Returns theBroadphaseFilter
used when detecting collisions for each time step. Returns:
BroadphaseFilter
 Since:
 3.2.2

setNarrowphaseDetector
public void setNarrowphaseDetector(NarrowphaseDetector narrowphaseDetector)
Sets the narrowphase collision detection algorithm. Parameters:
narrowphaseDetector
 the narrowphase collision detection algorithm Throws:
java.lang.NullPointerException
 if narrowphaseDetector is null

getNarrowphaseDetector
public NarrowphaseDetector getNarrowphaseDetector()
Returns the narrowphase collision detection algorithm. Returns:
NarrowphaseDetector
the narrowphase collision detection algorithm

setManifoldSolver
public void setManifoldSolver(ManifoldSolver manifoldSolver)
Sets the manifold solver. Parameters:
manifoldSolver
 the manifold solver Throws:
java.lang.NullPointerException
 if manifoldSolver is null

getManifoldSolver
public ManifoldSolver getManifoldSolver()
Returns the manifold solver. Returns:
ManifoldSolver
the manifold solver

setTimeOfImpactDetector
public void setTimeOfImpactDetector(TimeOfImpactDetector timeOfImpactDetector)
Sets the time of impact detector. Parameters:
timeOfImpactDetector
 the time of impact detector Throws:
java.lang.NullPointerException
 if timeOfImpactDetector is null Since:
 1.2.0

getTimeOfImpactDetector
public TimeOfImpactDetector getTimeOfImpactDetector()
Returns the time of impact detector. Returns:
TimeOfImpactDetector
the time of impact detector Since:
 1.2.0

setRaycastDetector
public void setRaycastDetector(RaycastDetector raycastDetector)
Sets the raycast detector. Parameters:
raycastDetector
 the raycast detector Throws:
java.lang.NullPointerException
 if raycastDetector is null Since:
 2.0.0

getRaycastDetector
public RaycastDetector getRaycastDetector()
Returns the raycast detector. Returns:
RaycastDetector
the raycast detector Since:
 2.0.0

getCoefficientMixer
public CoefficientMixer getCoefficientMixer()
Returns theCoefficientMixer
. Returns:
CoefficientMixer
 See Also:
setCoefficientMixer(CoefficientMixer)

setCoefficientMixer
public void setCoefficientMixer(CoefficientMixer coefficientMixer)
Sets theCoefficientMixer
.A
CoefficientMixer
is an implementation of mixing functions for various coefficients used in contact solving. Common coefficients are restitution and friction. Since eachBodyFixture
can have it's own value for these coefficients, theCoefficientMixer
is used to mathematically combine them into one coefficient to be used in contact resolution.CoefficientMixer.DEFAULT_MIXER
is the default. Parameters:
coefficientMixer
 the coefficient mixer Throws:
java.lang.NullPointerException
 if coefficientMixer is null See Also:
CoefficientMixer

setContactManager
public void setContactManager(ContactManager contactManager)
Sets theContactManager
.A
ContactManager
manages the contacts detected in thedetect()
method and performs notification ofContactListener
s.ContactManager
s can also contain specialized logic for improving performance and simulation quality.Changing the contact manager requires an update to be performed on the next update of this world and any cached information will be lost.
The default is the
DefaultContactManager
. Parameters:
contactManager
 the contact manager Throws:
java.lang.NullPointerException
 if contactManager is null Since:
 3.2.0
 See Also:
ContactManager

getContactManager
public ContactManager getContactManager()
Returns theContactManager
. Returns:
ContactManager
 Since:
 1.0.2
 See Also:
setContactManager(ContactManager)

setContactConstraintSolver
public void setContactConstraintSolver(ContactConstraintSolver constraintSolver)
Sets theContactConstraintSolver
for this world. Parameters:
constraintSolver
 the contact constraint solver Throws:
java.lang.NullPointerException
 if contactManager is null Since:
 3.2.0
 See Also:
ContactConstraintSolver

getContactConstraintSolver
public ContactConstraintSolver getContactConstraintSolver()
Returns theContactConstraintSolver
. Returns:
ContactConstraintSolver
 Since:
 3.2.0
 See Also:
setContactConstraintSolver(ContactConstraintSolver)

getUserData
public java.lang.Object getUserData()
Description copied from interface:DataContainer
Gets the custom user data. Specified by:
getUserData
in interfaceDataContainer
 Returns:
 Object will return null if not set

setUserData
public void setUserData(java.lang.Object userData)
Description copied from interface:DataContainer
Sets the custom user data to the given data. Specified by:
setUserData
in interfaceDataContainer
 Parameters:
userData
 the user data

getBodyCount
public int getBodyCount()
 Returns:
 int the number of bodies

getBody
public Body getBody(int index)
Returns theBody
at the given index. Parameters:
index
 the index Returns:
Body

getBodies
public java.util.List<Body> getBodies()
Returns an unmodifiable list containing all the bodies in this world.The returned list is backed by the internal list, therefore adding or removing bodies while iterating through the returned list is not permitted. Use the
getBodyIterator()
method instead. Returns:
 List<
Body
>  Since:
 3.1.5
 See Also:
getBodyIterator()

getBodyIterator
public java.util.Iterator<Body> getBodyIterator()
Returns an iterator for iterating over the bodies in this world.The returned iterator supports the
remove
method. Returns:
 Iterator<
Body
>  Since:
 3.2.0

getJointCount
public int getJointCount()
 Returns:
 int the number of joints

getJoint
public Joint getJoint(int index)
Returns theJoint
at the given index. Parameters:
index
 the index Returns:
Joint

getJoints
public java.util.List<Joint> getJoints()
Returns an unmodifiable list containing all the joints in this world.The returned list is backed by the internal list, therefore adding or removing joints while iterating through the returned list is not permitted. Use the
getJointIterator()
method instead. Returns:
 List<
Joint
>  Since:
 3.1.5
 See Also:
getJointIterator()

getJointIterator
public java.util.Iterator<Joint> getJointIterator()
Returns an iterator for iterating over the joints in this world.The returned iterator supports the
remove
method. Returns:
 Iterator<
Joint
>  Since:
 3.2.0

getStep
public Step getStep()
Returns theStep
object used to advance the simulation.The returned object contains the step information (elapsed time) for the last and the previous time step.
 Returns:
Step
the current step object

isEmpty
public boolean isEmpty()
Returns true if this world doesn't contain any bodies or joints. Returns:
 boolean
 Since:
 3.0.1

getAccumulatedTime
public double getAccumulatedTime()
Returns the current accumulated time.This is the time that has elapsed since the last step of the engine.
This time is used and/or accumulated on each call of the
update(double)
andupdate(double, int)
methods.This time is reduced by the step frequency for each step of the engine.
 Returns:
 double
 Since:
 3.1.10

setAccumulatedTime
public void setAccumulatedTime(double elapsedTime)
Sets the current accumulated time.A typical use case would be to throw away any remaining time that the
update(double)
orupdate(double, int)
methods didn't use:boolean updated = world.update(elapsedTime); // the check if the world actually updated is crutial in this example if (updated) { // throw away any remaining time we didnt use world.setAccumulatedTime(0); }
Or, in the case of reusing the same World object, you could use this method to clear any accumulated time.If elapsedTime is less than zero, this method immediately returns.
 Parameters:
elapsedTime
 the desired elapsed time Since:
 3.1.10
 See Also:
getAccumulatedTime()

