29#ifndef GU_INTERSECTION_CAPSULE_TRIANGLE_H
30#define GU_INTERSECTION_CAPSULE_TRIANGLE_H
33#include "foundation/PxUtilities.h"
46 void init(
const Capsule& capsule)
48 const PxVec3 dir = capsule.p1 - capsule.p0;
49 const float BDotB = dir.
dot(dir);
52 mOneOverBDotB = BDotB!=0.0f ? 1.0f/BDotB : 0.0f;
60 float min0 = capsule.p0.dot(axis);
61 float max0 = capsule.p1.dot(axis);
64 const float MR = axis.magnitude()*capsule.radius;
71 min1 = max1 = p0.
dot(axis);
72 float dp = p1.
dot(axis);
73 if(dp<min1) min1 = dp;
74 if(dp>max1) max1 = dp;
76 if(dp<min1) min1 = dp;
77 if(dp>max1) max1 = dp;
81 if(max0<min1 || max1<min0)
88 PX_FORCE_INLINE PxVec3 computeEdgeAxis(
const PxVec3& p,
const PxVec3& a,
89 const PxVec3& q,
const PxVec3& b,
90 float BDotB,
float oneOverBDotB)
92 const PxVec3 T = q - p;
93 const float ADotA = a.dot(a);
94 const float ADotB = a.dot(b);
95 const float ADotT = a.dot(T);
96 const float BDotT = b.dot(T);
98 const float denom = ADotA*BDotB - ADotB*ADotB;
100 float t = denom!=0.0f ? (ADotT*BDotB - BDotT*ADotB) / denom : 0.0f;
103 float u = (t*ADotB - BDotT) * oneOverBDotB;
114 t = (ADotB + ADotT) / ADotA;
117 return T + b*u - a*t;
131 bool intersectCapsuleTriangle(
const PxVec3& normal,
const PxVec3& p0,
const PxVec3& p1,
const PxVec3& p2,
const Gu::Capsule& capsule,
const CapsuleTriangleOverlapData& params);
Represents a capsule.
Definition GuCapsule.h:47
3 Element vector class.
Definition PxVec3.h:50
PX_CUDA_CALLABLE PX_FORCE_INLINE float dot(const PxVec3 &v) const
returns the scalar product of this and other.
Definition PxVec3.h:276
#define PX_FORCE_INLINE
Definition PxPreprocessor.h:335
bool intersectCapsuleTriangle(const PxVec3 &normal, const PxVec3 &p0, const PxVec3 &p1, const PxVec3 &p2, const Gu::Capsule &capsule, const CapsuleTriangleOverlapData ¶ms)
Definition GuIntersectionCapsuleTriangle.cpp:35
Sorts an array of objects in ascending order, assuming that the predicate implements the < operator:
Definition PxBoxController.h:39
PX_CUDA_CALLABLE PX_FORCE_INLINE T PxClamp(T v, T lo, T hi)
Clamps v to the range [hi,lo].
Definition PxMath.h:139
Definition GuIntersectionCapsuleTriangle.h:41