41 static constexpr int cMaxPointsToIncludeOriginInHull = 32;
42 static_assert(cMaxPointsToIncludeOriginInHull < cMaxPoints);
60 template <
typename A,
typename B>
98 template <
typename AE,
typename BE>
139 template <
typename AI,
typename BI>
200#ifdef JPH_EPA_CONVEX_BUILDER_DRAW
201 hull.DrawLabel(
"Build initial hull");
203#ifdef JPH_EPA_PENETRATION_DEPTH_DEBUG
206 hull.Initialize(0, 1, 2);
223#ifdef JPH_EPA_CONVEX_BUILDER_DRAW
224 hull.DrawLabel(
"Complete hull");
231 hull.DrawLabel(
"Ensure origin in hull");
243 hull.PopClosestTriangleFromQueue();
246 if (!
hull.HasNextTriangle())
249 hull.FreeTriangle(
t);
254 if (
t->mClosestLenSq >= 0.0f)
257#ifdef JPH_EPA_CONVEX_BUILDER_DRAW
258 hull.DrawLabel(
"Next iteration");
260#ifdef JPH_EPA_PENETRATION_DEPTH_DEBUG
261 Trace(
"EncapsulateOrigin: verts = (%d, %d, %d), closest_dist_sq = %g, centroid = (%g, %g, %g), normal = (%g, %g, %g)",
262 t->mEdge[0].mStartIdx,
t->mEdge[1].mStartIdx,
t->mEdge[2].mStartIdx,
264 t->mCentroid.GetX(),
t->mCentroid.GetY(),
t->mCentroid.GetZ(),
265 t->mNormal.GetX(),
t->mNormal.GetY(),
t->mNormal.GetZ());
269 hull.PopClosestTriangleFromQueue();
275#ifdef JPH_EPA_CONVEX_BUILDER_DRAW
289 hull.FreeTriangle(
t);
292 if (!
hull.HasNextTriangle() ||
support_points.mY.size() >= cMaxPointsToIncludeOriginInHull)
296#ifdef JPH_EPA_CONVEX_BUILDER_DRAW
297 hull.DrawLabel(
"Main algorithm");
318 hull.FreeTriangle(
t);
322#ifdef JPH_EPA_CONVEX_BUILDER_DRAW
323 hull.DrawLabel(
"Next iteration");
325#ifdef JPH_EPA_PENETRATION_DEPTH_DEBUG
326 Trace(
"FindClosest: verts = (%d, %d, %d), closest_len_sq = %g, centroid = (%g, %g, %g), normal = (%g, %g, %g)",
327 t->mEdge[0].mStartIdx,
t->mEdge[1].mStartIdx,
t->mEdge[2].mStartIdx,
329 t->mCentroid.GetX(),
t->mCentroid.GetY(),
t->mCentroid.GetZ(),
330 t->mNormal.GetX(),
t->mNormal.GetY(),
t->mNormal.GetZ());
358#ifdef JPH_EPA_PENETRATION_DEPTH_DEBUG
359 Trace(
"FindClosest: w = (%g, %g, %g), dot = %g, dist_sq = %g",
363#ifdef JPH_EPA_CONVEX_BUILDER_DRAW
373#ifdef JPH_EPA_PENETRATION_DEPTH_DEBUG
385#ifdef JPH_EPA_PENETRATION_DEPTH_DEBUG
386 Trace(
"Not facing triangle");
395#ifdef JPH_EPA_PENETRATION_DEPTH_DEBUG
396 Trace(
"Could not add point");
404 if (
nt->IsFacingOrigin())
411#ifdef JPH_EPA_PENETRATION_DEPTH_DEBUG
430#ifdef JPH_EPA_CONVEX_BUILDER_DRAW
431 hull.DrawLabel(
"Closest found");
442 if (
outV.IsNearZero())
458 if (
last->mLambdaRelativeTo0)
477 template <
typename AE,
typename AI,
typename BE,
typename BI>
478 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)
514 template <
typename A,
typename B>
515 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)
518 if (!mGJK.
CastShape(
inStart,
inDirection,
inCollisionTolerance,
inA,
inB,
inConvexRadiusA,
inConvexRadiusB,
ioLambda,
outPointA,
outPointB,
outContactNormal))
unsigned int uint
Definition Core.h:439
#define JPH_NAMESPACE_END
Definition Core.h:367
#define JPH_NAMESPACE_BEGIN
Definition Core.h:361
TraceFunction Trace
Definition IssueReporting.cpp:18
#define JPH_ASSERT(...)
Definition IssueReporting.h:33
constexpr T Square(T inV)
Square a value.
Definition Math.h:52
constexpr float DegreesToRadians(float inV)
Convert a value from degrees to radians.
Definition Math.h:13
AllocateFunction Allocate
Definition Memory.cpp:59
#define JPH_PROFILE_FUNCTION()
Scope profiling for function.
Definition Profiler.h:254
static const Color sPurple
Definition Color.h:58
static const Color sWhite
Definition Color.h:64
static const Color sRed
Definition Color.h:52
static const Color sYellow
Definition Color.h:57
GeometryRef CreateTriangleGeometryForConvex(SupportFunction inGetSupport)
Definition DebugRenderer.cpp:688
static DebugRenderer * sInstance
Singleton instance.
Definition DebugRenderer.h:168
Specialized points list that allows direct access to the size.
Definition EPAConvexHullBuilder.h:172
Class that holds the information of one triangle.
Definition EPAConvexHullBuilder.h:62
A convex hull builder specifically made for the EPA penetration depth calculation....
Definition EPAConvexHullBuilder.h:24
static constexpr int cMaxPoints
Max number of points in hull.
Definition EPAConvexHullBuilder.h:36
Definition EPAPenetrationDepth.h:37
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)
Definition EPAPenetrationDepth.h:515
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)
Definition EPAPenetrationDepth.h:478
EStatus GetPenetrationDepthStepGJK(const AE &inAExcludingConvexRadius, float inConvexRadiusA, const BE &inBExcludingConvexRadius, float inConvexRadiusB, float inTolerance, Vec3 &ioV, Vec3 &outPointA, Vec3 &outPointB)
Definition EPAPenetrationDepth.h:99
EStatus
Return code for GetPenetrationDepthStepGJK.
Definition EPAPenetrationDepth.h:81
@ NotColliding
Returned if the objects don't collide, in this case outPointA/outPointB are invalid.
@ Indeterminate
Returned if the objects penetrate further than the convex radius. In this case you need to call GetPe...
@ Colliding
Returned if the objects penetrate.
bool GetPenetrationDepthStepEPA(const AI &inAIncludingConvexRadius, const BI &inBIncludingConvexRadius, float inTolerance, Vec3 &outV, Vec3 &outPointA, Vec3 &outPointB)
Definition EPAPenetrationDepth.h:140
Definition GJKClosestPoint.h:23
bool CastShape(Mat44Arg inStart, Vec3Arg inDirection, float inTolerance, const A &inA, const B &inB, float &ioLambda)
Definition GJKClosestPoint.h:665
void GetClosestPointsSimplex(Vec3 *outY, Vec3 *outP, Vec3 *outQ, uint &outNumPoints) const
Definition GJKClosestPoint.h:502
float GetClosestPoints(const A &inA, const B &inB, float inTolerance, float inMaxDistSq, Vec3 &ioV, Vec3 &outPointA, Vec3 &outPointB)
Definition GJKClosestPoint.h:334
Holds a 4x4 matrix of floats, but supports also operations on the 3x3 upper left part of the matrix.
Definition Mat44.h:13
static JPH_INLINE Mat44 sRotation(Vec3Arg inAxis, float inAngle)
Rotate around arbitrary axis.
Definition Mat44.inl:139
Simple variable length array backed by a fixed size buffer.
Definition StaticArray.h:12
void push_back(const T &inElement)
Add element to the back of the array.
Definition StaticArray.h:59
uint size_type
Definition StaticArray.h:16
size_type size() const
Returns amount of elements in the array.
Definition StaticArray.h:87
JPH_INLINE float Dot(Vec3Arg inV2) const
Dot product.
Definition Vec3.inl:637
JPH_INLINE Vec3 GetNormalizedPerpendicular() const
Get normalized vector that is perpendicular to this vector.
Definition Vec3.inl:812
JPH_INLINE float GetX() const
Get individual components.
Definition Vec3.h:123
JPH_INLINE float GetY() const
Definition Vec3.h:124
static JPH_INLINE Vec3 sZero()
Vector with all zeros.
Definition Vec3.inl:107
JPH_INLINE float GetZ() const
Definition Vec3.h:125
Structure that adds a convex radius.
Definition ConvexSupport.h:46
Structure that performs a Minkowski difference A - B.
Definition ConvexSupport.h:67