|
template<typename AE , typename BE > |
EStatus | GetPenetrationDepthStepGJK (const AE &inAExcludingConvexRadius, float inConvexRadiusA, const BE &inBExcludingConvexRadius, float inConvexRadiusB, float inTolerance, Vec3 &ioV, Vec3 &outPointA, Vec3 &outPointB) |
|
template<typename AI , typename BI > |
bool | GetPenetrationDepthStepEPA (const AI &inAIncludingConvexRadius, const BI &inBIncludingConvexRadius, float inTolerance, Vec3 &outV, Vec3 &outPointA, Vec3 &outPointB) |
|
template<typename AE , typename AI , typename BE , typename BI > |
bool | GetPenetrationDepth (const AE &inAExcludingConvexRadius, const AI &inAIncludingConvexRadius, float inConvexRadiusA, const BE &inBExcludingConvexRadius, const BI &inBIncludingConvexRadius, float inConvexRadiusB, float inCollisionToleranceSq, float inPenetrationTolerance, Vec3 &ioV, Vec3 &outPointA, Vec3 &outPointB) |
|
template<typename A , typename B > |
bool | CastShape (Mat44Arg inStart, Vec3Arg inDirection, float inCollisionTolerance, float inPenetrationTolerance, const A &inA, const B &inB, float inConvexRadiusA, float inConvexRadiusB, bool inReturnDeepestPoint, float &ioLambda, Vec3 &outPointA, Vec3 &outPointB, Vec3 &outContactNormal) |
|
Implementation of Expanding Polytope Algorithm as described in:
Proximity Queries and Penetration Depth Computation on 3D Game Objects - Gino van den Bergen
The implementation of this algorithm does not completely follow the article, instead of splitting triangles at each edge as in fig. 7 in the article, we build a convex hull (removing any triangles that are facing the new point, thereby avoiding the problem of getting really oblong triangles as mentioned in the article).
The algorithm roughly works like:
- Start with a simplex of the Minkowski sum (difference) of two objects that was calculated by GJK
- This simplex should contain the origin (or else GJK would have reported: no collision)
- In cases where the simplex consists of 1 - 3 points, find some extra support points (of the Minkowski sum) to get to at least 4 points
- Convert this into a convex hull with non-zero volume (which includes the origin)
- A: Calculate the closest point to the origin for all triangles of the hull and take the closest one
- Calculate a new support point (of the Minkowski sum) in this direction and add this point to the convex hull
- This will remove all faces that are facing the new point and will create new triangles to fill up the hole
- Loop to A until no closer point found
- The closest point indicates the position / direction of least penetration
template<typename AE , typename AI , typename BE , typename BI >
bool EPAPenetrationDepth::GetPenetrationDepth |
( |
const AE & |
inAExcludingConvexRadius, |
|
|
const AI & |
inAIncludingConvexRadius, |
|
|
float |
inConvexRadiusA, |
|
|
const BE & |
inBExcludingConvexRadius, |
|
|
const BI & |
inBIncludingConvexRadius, |
|
|
float |
inConvexRadiusB, |
|
|
float |
inCollisionToleranceSq, |
|
|
float |
inPenetrationTolerance, |
|
|
Vec3 & |
ioV, |
|
|
Vec3 & |
outPointA, |
|
|
Vec3 & |
outPointB |
|
) |
| |
|
inline |
This function combines the GJK and EPA steps and is provided as a convenience function. Note: less performant since you're providing all support functions in one go Note 2: You need to initialize ioV, see documentation at GetPenetrationDepthStepGJK!