Package org.dyn4j.collision
Convex
Shape
s.
Collision detection can be an expensive process. To avoid unnecessary processing a two phase approach to collision detection is used. First a inaccurate, yet conservative, algorithm is used to detect possible collision pairs. This process is called the broad-phase. Next, after obtaining all the possible collision pairs, each pair is tested using an accurate algorithm. This is called the narrow-phase. After the narrow-phase is complete, another phase, Manifold generation, generates the contact points.
Broad-phase
The BroadphaseDetector
s will determine whether
two Convex
Shape
s can possibly
penetrate, returning only valid CollisionPair
s, which
should then be sent to a NarrowphaseDetector
.
Narrow-phase
The NarrowphaseDetector
s will determine whether two
Convex
Shape
s penetrate and
return a Penetration
.
The Penetration
object represents the minimum distance
along some vector required to push the Shape
s out of the penetration.
The narrow-phase also contains classes for supporting multiple detectors at once via the
FallbackNarrowphaseDetector
class. Using the
FallbackCondition
s the detector will determine whether to
use the primary NarrowphaseDetector
or the fallback.
Manifold Generation
Once a Penetration
object is obtained, it should be passed
to a ManifoldSolver
. A
ManifoldSolver
will use the
Penetration
object and the given
Convex
Shape
s to create a collision
Manifold
.
A collision Manifold
represents the collision point(s) between
the two Convex
Shape
s.
Continuous Collision Detection (CCD) and Raycasting
The process outlined above is called discrete collision detection. Outside of this process, there's continuous collision detection and raycasting.
Continuous collision detection (CCD) is the process
of detecting missed collisions that the discrete process couldn't detect. The discrete process fails
to detect some collisions due to it being run on a set interval - if a sufficiently small object is going
fast enough, for example. CCD detectors implement the TimeOfImpactDetector
interface and return a TimeOfImpact
object when a collision is
detected.
This package also supports raycasting for both the broad and narrow phases. These detectors implement
the RaycastDetector
interface and return
Raycast
objects when a ray hits a Fixture
.
The following is a list of implementations of the above interfaces:
- Since:
- 1.0.0
- Version:
- 4.0.0
- Author:
- William Bittle
-
Interface Summary Interface Description Bounds Represents theBounds
of a simulation.CollisionBody<T extends Fixture> Represents an object that can collide with other objects.CollisionItem<T extends CollisionBody<E>,E extends Fixture> Represents a grouping of aCollisionBody
andFixture
.CollisionPair<T> Represents a collision between twoCollisionBody
'sFixture
s.Filter Interface representing a filter for collision detection.FixtureModificationHandler<T extends Fixture> Represents a hook into aCollisionBody
to be notified ofFixture
modification events. -
Class Summary Class Description AbstractBounds Abstract implementation of theBounds
interface.AbstractCollisionBody<T extends Fixture> A base implementation of theCollisionBody
interface.AbstractCollisionItem<T extends CollisionBody<E>,E extends Fixture> Abstract implementation of theCollisionItem
interface.AbstractCollisionPair<T> Abstract implementation of theCollisionPair
interface.AxisAlignedBounds Represents a bounding region that is an Axis-Aligned bounding box.BasicCollisionItem<T extends CollisionBody<E>,E extends Fixture> Represents a basic, immutable implementation of theCollisionItem
interface.BasicCollisionPair<T> Represents a basic, immutable implementation of theCollisionPair
interface.CategoryFilter AFilter
for categorized fixtures.Collisions Class used to estimate collision counts and other one-off collision methods and values.Fixture Represents a geometric piece of aCollisionBody
.TypeFilter