Navigation
API > API/Runtime > API/Runtime/Chaos
Description
Find the distance and nearest points on two convex geometries A and B, if they do not overlap.
This is intended to be used with TGJKShape, TGJKCoreShape, TGJKShapeTransformed and TGJKCoreShapeTransformed and generally you will have a TGJKShape or TGJKCoreShape as A, and a Transformed version for B. The transform in B should transform a vector in B space to a vector in A space as all calculations are performed in the local- space of object A.
You can also use this function when you have 2 shapes already in the same space to avoid transforms in the support function(s). In this case you would use the non-transform versions of TGJKShape and would need to transform the results from the shared space to the space you desire.
For algorithm see "A Fast and Robust GJK Implementation for Collision Detection of Convex Objects", Gino Van Deb Bergen, 1999.
This algorithm aborts if objects are overlapping and it does not initialize the out parameters.
| Name | Chaos::GJKDistance |
| Type | function |
| Header File | /Engine/Source/Runtime/Experimental/Chaos/Public/Chaos/GJK.h |
| Include Path | #include "Chaos/GJK.h" |
namespace Chaos
{
template<typename T, typename GJKShapeTypeA, typename GJKShapeTypeB>
EGJKDistanceResult Chaos::GJKDistance
(
const GJKShapeTypeA & A,
const GJKShapeTypeB & B,
const TVec3< T > & InitialV,
T & OutDistance,
TVec3< T > & OutNearestA,
TVec3< T > & OutNearestB,
TVec3< T > & OutNormalA,
const T Epsilon,
const int32 MaxIts
)
}
EGJKDistanceResult - see comments on the enum
Parameters
| Name | Remarks |
|---|---|
| A | The first object (usually TGJKShape or TGJKCoreShape) |
| B | The second object (usually TGJKShapeTransformed or TGJKCoreShapeTransformed) |
| InitialV | Starting support direction that must be in or on the Minkowski Sum. See GJKDistanceInitialVFromDirection(). |
| OutDistance | If result is not DeepContact, the minimum distance between A and B, otherwise not modified. |
| OutNearestA | If result is not DeepContact, the near point on A in local-space, otherwise not modified. |
| OutNearestB | If result is not DeepContact, the near point on B in local-space, otherwise not modified. |
| Epsilon | The algorithm terminates when the iterative distance reduction gets below this threshold. |
| MaxIts | A limit on the number of iterations. Results may be approximate if this is too low. |