Collision Detection Overview
There are three basic types of collision checks supported in Unreal, Raycast, Sweep and Overlap (defined in ESQType
). All three query types follow the basic flow of getting an Accelerator and a Spatial Visitor which iterates over the geometry in the Accelerator.
TSceneCastCommon
and SceneTrace
which in turn call LowLevelRaycast
or LowLevelSweep
GeomOverlapMultiImp
then LowLevelOverlap
This geometry is stored in an AABB tree, which will get all leaf nodes in the query area and pass it to TSQVisitor::Visit
visit. This Visitor will iterate over all FImplicitObject
and query them
FImplicitObject
, basic objects like FCapsule
and FBoxFloat3
, and complex objects TImplicitObjectTransformed
and TImplicitObjectIntersection
which contain other Objects and alter them in some way.There is a different behavior for each query type
FImplicitObject::Raycast
Chaos::SweepQuery
which runs a Raycast if the shape is effectively a point, or a GJK query if the shape is Convex. Otherwise it will recursively query complex shapes until it reaches a base shape that satisfies one of the above conditionsGJKRaycast2ImplSimd
combines a few different algorithms, using GJK to detect overlap, then iterate over it with smaller / larger area to find contact points. It will fall back to EPA when GJK fails. For reference: GJK Overview Video and Text Explanation, EPA Explained, Finding Contact PointsChaos::OverlapQuery
which works similar to Sweep, using GJK to detect overlap on convex shapes, and breaking down complex shapes until they are convex.