Narrowphase collision detection is used to determine if two Convex
Shape
s penetrate, and if so, compute the vector of minimum magnitude
able to push the Convex
Shape
s out
of penetration.
The NarrowphaseDetector
s can only perform on
Convex
Shape
s. This allows for fast
and simple algorithms. Nonconvex shapes can be decomposed using a Decomposer
into Convex
pieces which can then be tested individually.
Even though the NarrowphaseDetector
s are fast, performance
can be improved substantially if a BroadphaseDetector
is
used to eliminate obvious nonpenetrating pairs.
NarrowphaseDetector
s return
Penetration
objects representing the vector of minimum
magnitude able to push the Convex
Shape
s out
of penetration. This information is typically passed onto a ManifoldSolver
to find the collision points.
There are two NarrowphaseDetector
implementations provided:
Sat
and Gjk
.
NOTE: The Sat
algorithm doesn't
support the Ellipse
and HalfEllipse
shapes.
This package also contains a FallbackNarrowphaseDetector
class. This class is
used to build a hierarchy of NarrowphaseDetector
s that can select detection
algorithms based on arbitrary conditions. For example, in the case of Ellipse
and
HalfEllipse
, Gjk
could be the fallback detector while
Sat
is the primary. Fallback is determined by the assigned
FallbackCondition
s.
NOTE: The CircleDetector
and SegmentDetector
classes already being used in the Sat
and Gjk
classes so no FallbackNarrowphaseDetector
is necessary for these.
The Gjk
algorithm also implements the DistanceDetector
and RaycastDetector
interfaces. These interfaces allow performing distance checks and raycasts
against Convex
Shape
s.
The DistanceDetector
s can return a Separation
object which contains the separation normal, distance and closest points.
The RaycastDetector
s can return a Raycast
object which contains the point the Ray
intersects the shape, the normal and the
distance. For raycasting, it's also advisable to perform a raycast against a BroadphaseDetector
first to rule out the obvious failures.
Interface  Description 

DistanceDetector  
FallbackCondition 
Represents a condition that returns true to indicate a fallback
NarrowphaseDetector
should be used instead of the primary. 
MinkowskiPenetrationSolver 
Interface representing a sub algorithm for finding the penetration vector
and depth using properties of the
MinkowskiSum and the Gjk
termination information. 
NarrowphaseDetector  
NarrowphasePostProcessor 
Interface used to modify the narrowphase collision information before being sent to listeners.

RaycastDetector 
Class  Description 

AbstractFallbackCondition 
Abstract implementation of the
FallbackCondition interface. 
CircleDetector 
Class devoted to
Circle detection queries. 
Epa  
FallbackNarrowphaseDetector 
Represents a delegating
NarrowphaseDetector that uses a primary NarrowphaseDetector and
fallback NarrowphaseDetector . 
Gjk 
Implementation of the GilbertJohnsonKeerthi (GJK) algorithm for collision detection.

LinkPostProcessor 
A
NarrowphasePostProcessor specifically for the Link class to solve the
internal edge problem when using a chain of segments. 
MinkowskiSum  
MinkowskiSumPoint 
Represents a point in the
MinkowskiSum . 
PairwiseTypedFallbackCondition 
Represents a
TypedFallbackCondition that filters on a particular pair of types. 
Penetration  
Raycast  
Sat 
Implementation of the Separating Axis Theorem (SAT) for collision detection.

SegmentDetector 
Class devoted to improving performance of
Segment detection queries. 
Separation  
SingleTypedFallbackCondition 
Represents a
TypedFallbackCondition that filters on a single type. 
TypedFallbackCondition 
Represents a
FallbackCondition that uses the Convex 's class type to determine
which pairs will be detected by the fallback NarrowphaseDetector . 