29#ifndef GU_DISTANCE_POINT_TETRAHEDRON_H
30#define GU_DISTANCE_POINT_TETRAHEDRON_H
32#include "foundation/PxVec3.h"
33#include "foundation/PxVec4.h"
34#include "common/PxPhysXCommonConfig.h"
35#include "GuDistancePointTriangle.h"
36#include "foundation/PxMathUtils.h"
42 PX_PHYSX_COMMON_API PxVec4 PointOutsideOfPlane4(
const PxVec3& p,
const PxVec3& _a,
const PxVec3& _b,
43 const PxVec3& _c,
const PxVec3& _d);
45 PX_PHYSX_COMMON_API PxVec3 closestPtPointTetrahedron(
const PxVec3& p,
const PxVec3& a,
const PxVec3& b,
const PxVec3& c,
const PxVec3& d,
const PxVec4& result);
47 PX_INLINE PX_CUDA_CALLABLE PxVec3 closestPtPointTetrahedron(
const PxVec3& p,
const PxVec3& a,
const PxVec3& b,
const PxVec3& c,
const PxVec3& d)
49 const PxVec3 ab = b - a;
50 const PxVec3 ac = c - a;
51 const PxVec3 ad = d - a;
52 const PxVec3 bc = c - b;
53 const PxVec3 bd = d - b;
56 PxVec3 bestClosestPt = closestPtPointTriangle2(p, a, b, c, ab, ac);
57 PxVec3 diff = bestClosestPt - p;
58 PxReal bestSqDist = diff.dot(diff);
61 PxVec3 closestPt = closestPtPointTriangle2(p, a, c, d, ac, ad);
63 PxReal sqDist = diff.dot(diff);
64 if (sqDist < bestSqDist)
66 bestClosestPt = closestPt;
71 closestPt = closestPtPointTriangle2(p, a, d, b, ad, ab);
73 sqDist = diff.dot(diff);
74 if (sqDist < bestSqDist)
76 bestClosestPt = closestPt;
81 closestPt = closestPtPointTriangle2(p, b, d, c, bd, bc);
83 sqDist = diff.dot(diff);
84 if (sqDist < bestSqDist)
86 bestClosestPt = closestPt;
93 PX_INLINE PX_CUDA_CALLABLE PxVec3 closestPtPointTetrahedronWithInsideCheck(
const PxVec3& p,
const PxVec3& a,
const PxVec3& b,
const PxVec3& c,
const PxVec3& d,
const PxReal eps = 0)
95 PxVec4 tmpBarycentric;
96 computeBarycentric(a, b, c, d, p, tmpBarycentric);
97 if ((tmpBarycentric.x >= -eps && tmpBarycentric.x <= 1.f + eps) && (tmpBarycentric.y >= -eps && tmpBarycentric.y <= 1.f + eps) &&
98 (tmpBarycentric.z >= -eps && tmpBarycentric.z <= 1.f + eps) && (tmpBarycentric.w >= -eps && tmpBarycentric.w <= 1.f + eps))
100 return closestPtPointTetrahedron(p, a, b, c, d);
#define PX_INLINE
Definition PxPreprocessor.h:320
Sorts an array of objects in ascending order, assuming that the predicate implements the < operator:
Definition PxBoxController.h:39