Interface CollisionWorld<T extends CollisionBody<E>,E extends Fixture,V extends CollisionData<T,E>>
-
- Type Parameters:
T
- theCollisionBody
typeE
- theFixture
typeV
- theCollisionData
type
- All Superinterfaces:
DataContainer
,Shiftable
- All Known Subinterfaces:
PhysicsWorld<T,V>
- All Known Implementing Classes:
AbstractCollisionWorld
,AbstractPhysicsWorld
,World
public interface CollisionWorld<T extends CollisionBody<E>,E extends Fixture,V extends CollisionData<T,E>> extends Shiftable, DataContainer
Represents a world whereCollisionBody
s are added to participate in collision detection.Along with defining the necessary methods to maintain the
CollisionBody
s in an instance, this interface exposes the broad-narrow-manifold phases of collision detection allowing a user to swap implementations.This interface also defines the basic static queries a user would want to perform against the world including raycating, convex casting, AABB, and convex queries.
NOTE: This interface does not define a collision detection pipeline or process. Instead it defines the necessary components to build one.
- Since:
- 4.0.0
- Version:
- 4.0.0
- Author:
- William Bittle
-
-
Field Summary
Fields Modifier and Type Field Description static int
DEFAULT_INITIAL_BODY_CAPACITY
The defaultCollisionBody
count
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
addBody(T body)
Adds the givenCollisionBody
to thisCollisionWorld
.boolean
addBoundsListener(BoundsListener<T,E> listener)
Adds the givenBoundsListener
to this world.boolean
addCollisionListener(CollisionListener<T,E> listener)
Adds the givenCollisionListener
to this world.boolean
containsBody(T body)
Returns true if this world contains the given body.List<ConvexCastResult<T,E>>
convexCast(Convex convex, Transform transform, Vector2 deltaPosition, double deltaAngle, DetectFilter<T,E> filter)
Returns a list ofConvexCastResult
s containing all the body-fixtures that overlap with the givenConvex
over the given deltaPosition and deltaAngle using the current state of theBroadphaseDetector
.ConvexCastResult<T,E>
convexCastClosest(Convex convex, Transform transform, Vector2 deltaPosition, double deltaAngle, DetectFilter<T,E> filter)
Returns the closestConvexCastResult
that overlaps with the givenConvex
over the given deltaPosition and deltaAngle using the current state of theBroadphaseDetector
.ConvexCastResult<T,E>
convexCastClosest(Convex convex, Transform transform, Vector2 deltaPosition, double deltaAngle, T body, DetectFilter<T,E> filter)
Returns the closestConvexCastResult
that overlaps with the givenConvex
over the given deltaPosition and deltaAngle only testing against the givenCollisionBody
.Iterator<ConvexCastResult<T,E>>
convexCastIterator(Convex convex, Transform transform, Vector2 deltaPosition, double deltaAngle, DetectFilter<T,E> filter)
Returns an iterator ofConvexCastResult
s containing all the body-fixtures that overlap with the givenConvex
over the given deltaPosition and deltaAngle using the current state of theBroadphaseDetector
.List<DetectResult<T,E>>
detect(AABB aabb, DetectFilter<T,E> filter)
Returns a list ofDetectResult
s containing all the body-fixtures that overlap with the givenAABB
using the current state of theBroadphaseDetector
.List<DetectResult<T,E>>
detect(AABB aabb, T body, DetectFilter<T,E> filter)
Returns a list ofDetectResult
s containing all the body-fixtures that overlap with the givenAABB
using the current state of theBroadphaseDetector
, only testing against the givenCollisionBody
.List<ConvexDetectResult<T,E>>
detect(Convex convex, Transform transform, DetectFilter<T,E> filter)
Returns a list ofConvexDetectResult
s containing all the body-fixtures that overlap with the givenConvex
using the current state of theBroadphaseDetector
.List<ConvexDetectResult<T,E>>
detect(Convex convex, Transform transform, T body, DetectFilter<T,E> filter)
Returns a list ofConvexDetectResult
s containing all the body-fixtures that overlapped with the givenConvex
using the current state of theBroadphaseDetector
, only testing against the givenCollisionBody
.Iterator<DetectResult<T,E>>
detectIterator(AABB aabb, DetectFilter<T,E> filter)
Returns an iterator ofDetectResult
s containing all the body-fixtures that overlap with the givenAABB
using the current state of theBroadphaseDetector
.Iterator<DetectResult<T,E>>
detectIterator(AABB aabb, T body, DetectFilter<T,E> filter)
Returns an iterator ofDetectResult
s containing all the body-fixtures that overlap with the givenAABB
using the current state of theBroadphaseDetector
, only testing against the givenCollisionBody
.Iterator<ConvexDetectResult<T,E>>
detectIterator(Convex convex, Transform transform, DetectFilter<T,E> filter)
Returns an iterator ofConvexDetectResult
s containing all the body-fixtures that overlapped with the givenConvex
using the current state of theBroadphaseDetector
.Iterator<ConvexDetectResult<T,E>>
detectIterator(Convex convex, Transform transform, T body, DetectFilter<T,E> filter)
Returns an iterator ofConvexDetectResult
s containing all the body-fixtures that overlapped with the givenConvex
using the current state of theBroadphaseDetector
, only testing against the givenCollisionBody
.List<T>
getBodies()
Returns an unmodifiable list containing all the bodies in this world.T
getBody(int index)
Returns theCollisionBody
at the given index.int
getBodyCount()
Returns the number ofCollisionBody
s in thisCollisionWorld
.Iterator<T>
getBodyIterator()
Returns an iterator for iterating over the bodies in this world.Bounds
getBounds()
Returns the bounds of this world.List<BoundsListener<T,E>>
getBoundsListeners()
Returns an unmodifiable list of all the bounds listeners registered to this world.BroadphaseDetector<T,E>
getBroadphaseDetector()
Returns the broad-phase collision detection algorithm.BroadphaseFilter<T,E>
getBroadphaseFilter()
Returns theBroadphaseFilter
used when detecting collisions for each time step.V
getCollisionData(T body1, E fixture1, T body2, E fixture2)
Returns the collision data for the given body-fixture pairs.Iterator<V>
getCollisionDataIterator()
Returns an iterator that can be used to enumerate all the collisions in this world.List<CollisionListener<T,E>>
getCollisionListeners()
Returns an unmodifiable list of all the collision listeners registered to this world.ManifoldSolver
getManifoldSolver()
Returns the manifold solver.NarrowphaseDetector
getNarrowphaseDetector()
Returns the narrow-phase collision detection algorithm.NarrowphasePostProcessor
getNarrowphasePostProcessor()
Returns the narrow-phase post processing algorithm.RaycastDetector
getRaycastDetector()
Returns the raycast detector.TimeOfImpactDetector
getTimeOfImpactDetector()
Returns the time of impact detector.boolean
isEmpty()
Returns true if this world doesn't contain any bodies or joints.List<RaycastResult<T,E>>
raycast(Ray ray, double maxLength, DetectFilter<T,E> filter)
Returns a list ofRaycastResult
s containing all the body-fixtures that overlap with the givenRay
using the current state of theBroadphaseDetector
.List<RaycastResult<T,E>>
raycast(Ray ray, double maxLength, T body, DetectFilter<T,E> filter)
Returns a list ofRaycastResult
s containing all the body-fixtures that overlap with the givenRay
only testing against the givenCollisionBody
.RaycastResult<T,E>
raycastClosest(Ray ray, double maxLength, DetectFilter<T,E> filter)
Returns the closestRaycastResult
that overlaps with the givenRay
using the current state of theBroadphaseDetector
.RaycastResult<T,E>
raycastClosest(Ray ray, double maxLength, T body, DetectFilter<T,E> filter)
Returns the closestRaycastResult
that overlaps with the givenRay
only testing against the givenCollisionBody
.Iterator<RaycastResult<T,E>>
raycastIterator(Ray ray, double maxLength, DetectFilter<T,E> filter)
Returns an iterator ofRaycastResult
s containing all the body-fixtures that overlap with the givenRay
using the current state of theBroadphaseDetector
.Iterator<RaycastResult<T,E>>
raycastIterator(Ray ray, double maxLength, T body, DetectFilter<T,E> filter)
Returns an iterator ofRaycastResult
s containing all the body-fixtures that overlap with the givenRay
only testing against the givenCollisionBody
.void
removeAllBodies()
Removes all bodies from this world.void
removeAllBoundsListeners()
Removes all bounds listeners from this world.void
removeAllCollisionListeners()
Removes all collision listeners from this world.void
removeAllListeners()
Removes all listeners from this world.boolean
removeBody(int index)
Removes theCollisionBody
at the given index from thisCollisionWorld
.boolean
removeBody(T body)
Removes the givenCollisionBody
from thisCollisionWorld
.boolean
removeBoundsListener(BoundsListener<T,E> listener)
Removes the given bounds listener from this world and returns true if it was removed.boolean
removeCollisionListener(CollisionListener<T,E> listener)
Removes the given collision listener from this world and returns true if it was removed.void
setBounds(Bounds bounds)
Sets the bounds of thisCollisionWorld
.void
setBroadphaseDetector(BroadphaseDetector<T,E> broadphaseDetector)
Sets the broad-phase collision detection algorithm.void
setBroadphaseFilter(BroadphaseFilter<T,E> filter)
Sets theBroadphaseFilter
used when detecting collisions for each time step.void
setManifoldSolver(ManifoldSolver manifoldSolver)
Sets the manifold solver.void
setNarrowphaseDetector(NarrowphaseDetector narrowphaseDetector)
Sets the narrow-phase collision detection algorithm.void
setNarrowphasePostProcessor(NarrowphasePostProcessor narrowphasePostProcessor)
Sets the narrow-phase post processing algorithm.void
setRaycastDetector(RaycastDetector raycastDetector)
Sets the raycast detector.void
setTimeOfImpactDetector(TimeOfImpactDetector timeOfImpactDetector)
Sets the time of impact detector.-
Methods inherited from interface DataContainer
getUserData, setUserData
-
-
-
-
Field Detail
-
DEFAULT_INITIAL_BODY_CAPACITY
static final int DEFAULT_INITIAL_BODY_CAPACITY
The defaultCollisionBody
count- See Also:
- Constant Field Values
-
-
Method Detail
-
addBody
void addBody(T body)
Adds the givenCollisionBody
to thisCollisionWorld
.- Parameters:
body
- theCollisionBody
to add- Throws:
NullPointerException
- if body is nullIllegalArgumentException
- if body has already been added to this world or if its a member of another world instance- Since:
- 3.1.1
-
containsBody
boolean containsBody(T body)
Returns true if this world contains the given body.- Parameters:
body
- theCollisionBody
to test for- Returns:
- boolean true if the body is contained in this world
- Since:
- 3.1.1
-
removeBody
boolean removeBody(int index)
Removes theCollisionBody
at the given index from thisCollisionWorld
.- Parameters:
index
- the index of the body to remove.- Returns:
- boolean true if the body was removed
- Since:
- 3.2.0
-
removeBody
boolean removeBody(T body)
Removes the givenCollisionBody
from thisCollisionWorld
.- Parameters:
body
- theCollisionBody
to remove.- Returns:
- boolean true if the body was removed
-
removeAllBodies
void removeAllBodies()
Removes all bodies from this world.- Since:
- 3.0.1
-
getBodyCount
int getBodyCount()
Returns the number ofCollisionBody
s in thisCollisionWorld
.- Returns:
- int the number of bodies
-
getBody
T getBody(int index)
Returns theCollisionBody
at the given index.- Parameters:
index
- the index- Returns:
CollisionBody
-
getBodies
List<T> 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<
CollisionBody
> - Since:
- 3.1.5
- See Also:
getBodyIterator()
-
getBodyIterator
Iterator<T> getBodyIterator()
Returns an iterator for iterating over the bodies in this world.The returned iterator supports the
remove
method.- Returns:
- Iterator<
CollisionBody
> - Since:
- 3.2.0
-
isEmpty
boolean isEmpty()
Returns true if this world doesn't contain any bodies or joints.- Returns:
- boolean
- Since:
- 3.0.1
-
setBounds
void setBounds(Bounds bounds)
Sets the bounds of thisCollisionWorld
.- Parameters:
bounds
- the bounds; can be null
-
getBounds
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
-
getCollisionListeners
List<CollisionListener<T,E>> getCollisionListeners()
Returns an unmodifiable list of all the collision listeners registered to this world.- Returns:
- List<
CollisionListener
>
-
getBoundsListeners
List<BoundsListener<T,E>> getBoundsListeners()
Returns an unmodifiable list of all the bounds listeners registered to this world.- Returns:
- List<
BoundsListener
>
-
removeAllListeners
void removeAllListeners()
Removes all listeners from this world.
-
removeAllCollisionListeners
void removeAllCollisionListeners()
Removes all collision listeners from this world.
-
removeAllBoundsListeners
void removeAllBoundsListeners()
Removes all bounds listeners from this world.
-
removeCollisionListener
boolean removeCollisionListener(CollisionListener<T,E> listener)
Removes the given collision listener from this world and returns true if it was removed.This method will return false if the listener was not found in this world.
- Parameters:
listener
- the listener- Returns:
- boolean
-
removeBoundsListener
boolean removeBoundsListener(BoundsListener<T,E> listener)
Removes the given bounds listener from this world and returns true if it was removed.This method will return false if the listener was not found in this world.
- Parameters:
listener
- the listener- Returns:
- boolean
-
addCollisionListener
boolean addCollisionListener(CollisionListener<T,E> listener)
Adds the givenCollisionListener
to this world.NOTE: No effort is made to prevent duplicate listeners from being added.
- Parameters:
listener
- the listener to add- Returns:
- boolean
-
addBoundsListener
boolean addBoundsListener(BoundsListener<T,E> listener)
Adds the givenBoundsListener
to this world.NOTE: No effort is made to prevent duplicate listeners from being added.
- Parameters:
listener
- the listener to add- Returns:
- boolean
-
setBroadphaseDetector
void setBroadphaseDetector(BroadphaseDetector<T,E> broadphaseDetector)
Sets the broad-phase collision detection algorithm.- Parameters:
broadphaseDetector
- the broad-phase collision detection algorithm- Throws:
NullPointerException
- if broadphaseDetector is null
-
getBroadphaseDetector
BroadphaseDetector<T,E> getBroadphaseDetector()
Returns the broad-phase collision detection algorithm.- Returns:
BroadphaseDetector
the broad-phase collision detection algorithm
-
setBroadphaseFilter
void setBroadphaseFilter(BroadphaseFilter<T,E> filter)
Sets theBroadphaseFilter
used when detecting collisions for each time step.This should always be an instance of a class that extends the
PhysicsBodyBroadphaseFilter
so that the standard filters are retained.- Parameters:
filter
- the filter- Since:
- 3.2.2
-
getBroadphaseFilter
BroadphaseFilter<T,E> getBroadphaseFilter()
Returns theBroadphaseFilter
used when detecting collisions for each time step.- Returns:
BroadphaseFilter
- Since:
- 3.2.2
-
setNarrowphaseDetector
void setNarrowphaseDetector(NarrowphaseDetector narrowphaseDetector)
Sets the narrow-phase collision detection algorithm.- Parameters:
narrowphaseDetector
- the narrow-phase collision detection algorithm- Throws:
NullPointerException
- if narrowphaseDetector is null
-
getNarrowphaseDetector
NarrowphaseDetector getNarrowphaseDetector()
Returns the narrow-phase collision detection algorithm.- Returns:
NarrowphaseDetector
the narrow-phase collision detection algorithm
-
setNarrowphasePostProcessor
void setNarrowphasePostProcessor(NarrowphasePostProcessor narrowphasePostProcessor)
Sets the narrow-phase post processing algorithm.- Parameters:
narrowphasePostProcessor
- the narrow-phase post processing algorithm- Throws:
NullPointerException
- if narrowphasePostProcessor is null
-
getNarrowphasePostProcessor
NarrowphasePostProcessor getNarrowphasePostProcessor()
Returns the narrow-phase post processing algorithm.- Returns:
NarrowphasePostProcessor
the narrow-phase post processing algorithm
-
setManifoldSolver
void setManifoldSolver(ManifoldSolver manifoldSolver)
Sets the manifold solver.- Parameters:
manifoldSolver
- the manifold solver- Throws:
NullPointerException
- if manifoldSolver is null
-
getManifoldSolver
ManifoldSolver getManifoldSolver()
Returns the manifold solver.- Returns:
ManifoldSolver
the manifold solver
-
setRaycastDetector
void setRaycastDetector(RaycastDetector raycastDetector)
Sets the raycast detector.- Parameters:
raycastDetector
- the raycast detector- Throws:
NullPointerException
- if raycastDetector is null- Since:
- 2.0.0
-
getRaycastDetector
RaycastDetector getRaycastDetector()
Returns the raycast detector.- Returns:
RaycastDetector
the raycast detector- Since:
- 2.0.0
-
setTimeOfImpactDetector
void setTimeOfImpactDetector(TimeOfImpactDetector timeOfImpactDetector)
Sets the time of impact detector.- Parameters:
timeOfImpactDetector
- the time of impact detector- Throws:
NullPointerException
- if timeOfImpactDetector is null- Since:
- 1.2.0
-
getTimeOfImpactDetector
TimeOfImpactDetector getTimeOfImpactDetector()
Returns the time of impact detector.- Returns:
TimeOfImpactDetector
the time of impact detector- Since:
- 1.2.0
-
getCollisionData
V getCollisionData(T body1, E fixture1, T body2, E fixture2)
Returns the collision data for the given body-fixture pairs.This returns the collision data for any pair that was detected in the broadphase. Use the
CollisionData.isBroadphaseCollision()
,CollisionData.isManifoldCollision()
, etc. methods to inspect the type of collision or the details about the collision.Returns null if the body-fixtures are not colliding or if either no longer exist in the world.
- Parameters:
body1
- the first bodyfixture1
- the first body's fixturebody2
- the second bodyfixture2
- the second body's fixture- Returns:
- V
-
getCollisionDataIterator
Iterator<V> getCollisionDataIterator()
Returns an iterator that can be used to enumerate all the collisions in this world.This returns the collision data for any pair that was detected in the broadphase. Use the
CollisionData.isBroadphaseCollision()
,CollisionData.isManifoldCollision()
, etc. methods to inspect the type of collision or the details about the collision.NOTE: This iterator does NOT support removal.
- Returns:
- Iterator<V>
-
detect
List<DetectResult<T,E>> detect(AABB aabb, DetectFilter<T,E> filter)
Returns a list ofDetectResult
s containing all the body-fixtures that overlap with the givenAABB
using the current state of theBroadphaseDetector
.- Parameters:
aabb
- the aabbfilter
- the filter; can be null- Returns:
- List<
DetectResult
>
-
detectIterator
Iterator<DetectResult<T,E>> detectIterator(AABB aabb, DetectFilter<T,E> filter)
Returns an iterator ofDetectResult
s containing all the body-fixtures that overlap with the givenAABB
using the current state of theBroadphaseDetector
.NOTE: The returned
DetectResult
s are reused internally. You should call theDetectResult.copy()
method to create a copy of the result if you need to keep it outside of the iteration.- Parameters:
aabb
- the aabbfilter
- the filter; can be null- Returns:
- Iterator<
DetectResult
>
-
detect
List<DetectResult<T,E>> detect(AABB aabb, T body, DetectFilter<T,E> filter)
Returns a list ofDetectResult
s containing all the body-fixtures that overlap with the givenAABB
using the current state of theBroadphaseDetector
, only testing against the givenCollisionBody
.- Parameters:
aabb
- the aabbbody
- the bodyfilter
- the filter; can be null- Returns:
- List<
DetectResult
>
-
detectIterator
Iterator<DetectResult<T,E>> detectIterator(AABB aabb, T body, DetectFilter<T,E> filter)
Returns an iterator ofDetectResult
s containing all the body-fixtures that overlap with the givenAABB
using the current state of theBroadphaseDetector
, only testing against the givenCollisionBody
.NOTE: The returned
DetectResult
s are reused internally. You should call theDetectResult.copy()
method to create a copy of the result if you need to keep it outside of the iteration.- Parameters:
aabb
- the aabbbody
- the bodyfilter
- the filter; can be null- Returns:
- Iterator<
DetectResult
>
-
detect
List<ConvexDetectResult<T,E>> detect(Convex convex, Transform transform, DetectFilter<T,E> filter)
Returns a list ofConvexDetectResult
s containing all the body-fixtures that overlap with the givenConvex
using the current state of theBroadphaseDetector
.- Parameters:
convex
- the convextransform
- the transformfilter
- the filter; can be null- Returns:
- List<
ConvexDetectResult
>
-
detectIterator
Iterator<ConvexDetectResult<T,E>> detectIterator(Convex convex, Transform transform, DetectFilter<T,E> filter)
Returns an iterator ofConvexDetectResult
s containing all the body-fixtures that overlapped with the givenConvex
using the current state of theBroadphaseDetector
.- Parameters:
convex
- the convextransform
- the transformfilter
- the filter; can be null- Returns:
- Iterator<
ConvexDetectResult
>
-
detect
List<ConvexDetectResult<T,E>> detect(Convex convex, Transform transform, T body, DetectFilter<T,E> filter)
Returns a list ofConvexDetectResult
s containing all the body-fixtures that overlapped with the givenConvex
using the current state of theBroadphaseDetector
, only testing against the givenCollisionBody
.- Parameters:
convex
- the convextransform
- the transformbody
- the bodyfilter
- the filter; can be null- Returns:
- List<
ConvexDetectResult
>
-
detectIterator
Iterator<ConvexDetectResult<T,E>> detectIterator(Convex convex, Transform transform, T body, DetectFilter<T,E> filter)
Returns an iterator ofConvexDetectResult
s containing all the body-fixtures that overlapped with the givenConvex
using the current state of theBroadphaseDetector
, only testing against the givenCollisionBody
.- Parameters:
convex
- the convextransform
- the transformbody
- the bodyfilter
- the filter; can be null- Returns:
- Iterator<
ConvexDetectResult
>
-
raycast
List<RaycastResult<T,E>> raycast(Ray ray, double maxLength, DetectFilter<T,E> filter)
Returns a list ofRaycastResult
s containing all the body-fixtures that overlap with the givenRay
using the current state of theBroadphaseDetector
.If the ray begins inside a fixture, that fixture will not be included in the results.
- Parameters:
ray
- the raymaxLength
- the max length of the ray; any value less than or equal to zero represents infinite lengthfilter
- the filter; can be null- Returns:
- List<
RaycastResult
>
-
raycastIterator
Iterator<RaycastResult<T,E>> raycastIterator(Ray ray, double maxLength, DetectFilter<T,E> filter)
Returns an iterator ofRaycastResult
s containing all the body-fixtures that overlap with the givenRay
using the current state of theBroadphaseDetector
.If the ray begins inside a fixture, that fixture will not be included in the results.
- Parameters:
ray
- the raymaxLength
- the max length of the ray; any value less than or equal to zero represents infinite lengthfilter
- the filter; can be null- Returns:
- Iterator<
RaycastResult
>
-
raycast
List<RaycastResult<T,E>> raycast(Ray ray, double maxLength, T body, DetectFilter<T,E> filter)
Returns a list ofRaycastResult
s containing all the body-fixtures that overlap with the givenRay
only testing against the givenCollisionBody
.This method does not use the current state of the
BroadphaseDetector
and instead tests the given body's fixtures directly.If the ray begins inside a fixture, that fixture will not be included in the results.
- Parameters:
ray
- the raymaxLength
- the max length of the ray; any value less than or equal to zero represents infinite lengthbody
- the bodyfilter
- the filter; can be null- Returns:
- List<
RaycastResult
>
-
raycastIterator
Iterator<RaycastResult<T,E>> raycastIterator(Ray ray, double maxLength, T body, DetectFilter<T,E> filter)
Returns an iterator ofRaycastResult
s containing all the body-fixtures that overlap with the givenRay
only testing against the givenCollisionBody
.This method does not use the current state of the
BroadphaseDetector
and instead tests the given body's fixtures directly.If the ray begins inside a fixture, that fixture will not be included in the results.
- Parameters:
ray
- the raymaxLength
- the max length of the ray; any value less than or equal to zero represents infinite lengthbody
- the bodyfilter
- the filter; can be null- Returns:
- Iterator<
RaycastResult
>
-
raycastClosest
RaycastResult<T,E> raycastClosest(Ray ray, double maxLength, DetectFilter<T,E> filter)
Returns the closestRaycastResult
that overlaps with the givenRay
using the current state of theBroadphaseDetector
.The closest is defined as the closest intersection of the ray and a fixture to the ray's start point.
If the ray begins inside a fixture, that fixture will not be included in the results.
- Parameters:
ray
- the raymaxLength
- the max length of the ray; any value less than or equal to zero represents infinite lengthfilter
- the filter; can be null- Returns:
RaycastResult
-
raycastClosest
RaycastResult<T,E> raycastClosest(Ray ray, double maxLength, T body, DetectFilter<T,E> filter)
Returns the closestRaycastResult
that overlaps with the givenRay
only testing against the givenCollisionBody
.The closest is defined as the closest intersection of the ray and a fixture to the ray's start point.
This method does not use the current state of the
BroadphaseDetector
and instead tests the given body's fixtures directly.If the ray begins inside a fixture, that fixture will not be included in the results.
- Parameters:
ray
- the raymaxLength
- the max length of the ray; any value less than or equal to zero represents infinite lengthbody
- the bodyfilter
- the filter; can be null- Returns:
RaycastResult
-
convexCast
List<ConvexCastResult<T,E>> convexCast(Convex convex, Transform transform, Vector2 deltaPosition, double deltaAngle, DetectFilter<T,E> filter)
Returns a list ofConvexCastResult
s containing all the body-fixtures that overlap with the givenConvex
over the given deltaPosition and deltaAngle using the current state of theBroadphaseDetector
.The deltaPosition and deltaAngle parameters define the cast of the convex. Imagine moving the given convex from it's current transform position to the given position and rotating the given convex from it's current transform rotation to the given rotation. This method detects if there was any collisions between these start and end states.
This method assumes linear motion, meaning that the direction of motion is in the same direction for the start and end states as defined by the deltaPosition parameter.
- Parameters:
convex
- the convextransform
- the transformdeltaPosition
- the change in position of the convexdeltaAngle
- the change in rotation of the convexfilter
- the filter; can be null- Returns:
- List<
ConvexCastResult
>
-
convexCastIterator
Iterator<ConvexCastResult<T,E>> convexCastIterator(Convex convex, Transform transform, Vector2 deltaPosition, double deltaAngle, DetectFilter<T,E> filter)
Returns an iterator ofConvexCastResult
s containing all the body-fixtures that overlap with the givenConvex
over the given deltaPosition and deltaAngle using the current state of theBroadphaseDetector
.The deltaPosition and deltaAngle parameters define the cast of the convex. Imagine moving the given convex from it's current transform position to the given position and rotating the given convex from it's current transform rotation to the given rotation. This method detects if there was any collisions between these start and end states.
This method assumes linear motion, meaning that the direction of motion is in the same direction for the start and end states as defined by the deltaPosition parameter.
- Parameters:
convex
- the convextransform
- the transformdeltaPosition
- the change in position of the convexdeltaAngle
- the change in rotation of the convexfilter
- the filter; can be null- Returns:
- Iterator<
ConvexCastResult
>
-
convexCastClosest
ConvexCastResult<T,E> convexCastClosest(Convex convex, Transform transform, Vector2 deltaPosition, double deltaAngle, DetectFilter<T,E> filter)
Returns the closestConvexCastResult
that overlaps with the givenConvex
over the given deltaPosition and deltaAngle using the current state of theBroadphaseDetector
.The closest is defined as the closest intersection from the initial position/rotation of the given convex.
The deltaPosition and deltaAngle parameters define the cast of the convex. Imagine moving the given convex from it's current transform position to the given position and rotating the given convex from it's current transform rotation to the given rotation. This method detects if there was any collisions between these start and end states.
This method assumes linear motion, meaning that the direction of motion is in the same direction for the start and end states as defined by the deltaPosition parameter.
- Parameters:
convex
- the convextransform
- the transformdeltaPosition
- the change in position of the convexdeltaAngle
- the change in rotation of the convexfilter
- the filter; can be null- Returns:
ConvexCastResult
-
convexCastClosest
ConvexCastResult<T,E> convexCastClosest(Convex convex, Transform transform, Vector2 deltaPosition, double deltaAngle, T body, DetectFilter<T,E> filter)
Returns the closestConvexCastResult
that overlaps with the givenConvex
over the given deltaPosition and deltaAngle only testing against the givenCollisionBody
.The closest is defined as the closest intersection from the initial position/rotation of the given convex.
The deltaPosition and deltaAngle parameters define the cast of the convex. Imagine moving the given convex from it's current transform position to the given position and rotating the given convex from it's current transform rotation to the given rotation. This method detects if there was any collisions between these start and end states.
This method assumes linear motion, meaning that the direction of motion is in the same direction for the start and end states as defined by the deltaPosition parameter.
- Parameters:
convex
- the convextransform
- the transformdeltaPosition
- the change in position of the convexdeltaAngle
- the change in rotation of the convexbody
- the bodyfilter
- the filter; can be null- Returns:
ConvexCastResult
-
-