35#include "foundation/PxTransform.h"
36#include "common/PxPhysXCommonConfig.h"
37#include "geometry/PxBoxGeometry.h"
38#include "foundation/PxVecTransform.h"
39#include "GuVecConvex.h"
40#include "GuConvexSupportTable.h"
44PX_PHYSX_COMMON_API
extern const aos::BoolV boxVertexTable[8];
49#define BOX_MARGIN_RATIO 0.15f
50#define BOX_MIN_MARGIN_RATIO 0.05f
51#define BOX_SWEEP_MARGIN_RATIO 0.05f
53#define BOX_MARGIN_CCD_RATIO 0.01f
54#define BOX_MIN_MARGIN_CCD_RATIO 0.005f
60 PX_FORCE_INLINE void CalculateBoxMargin(
const aos::Vec3VArg extent, PxReal& margin, PxReal& minMargin, PxReal& sweepMargin,
61 const PxReal marginR = BOX_MARGIN_RATIO,
const PxReal minMarginR = BOX_MIN_MARGIN_RATIO)
66 const FloatV min = V3ExtractMin(extent);
67 FStore(min, &minExtent);
69 margin = minExtent * marginR;
70 minMargin = minExtent * minMarginR;
71 sweepMargin = minExtent * BOX_SWEEP_MARGIN_RATIO;
74 PX_FORCE_INLINE aos::FloatV CalculateBoxTolerance(
const aos::Vec3VArg extent)
78 const FloatV r0 = FLoad(0.01f);
79 const FloatV min = V3ExtractMin(extent);
84 PX_FORCE_INLINE aos::FloatV CalculatePCMBoxMargin(
const aos::Vec3VArg extent,
const PxReal toleranceLength,
const PxReal toleranceMarginRatio = BOX_MARGIN_RATIO)
88 const FloatV min = V3ExtractMin(extent);
89 const FloatV toleranceMargin = FLoad(toleranceLength * toleranceMarginRatio);
90 return FMin(FMul(min, FLoad(BOX_MARGIN_RATIO)), toleranceMargin);
93 PX_FORCE_INLINE aos::FloatV CalculateMTDBoxMargin(
const aos::Vec3VArg extent)
97 const FloatV min = V3ExtractMin(extent);
98 return FMul(min, FLoad(BOX_MARGIN_RATIO));
115 CalculateBoxMargin(extent, margin, minMargin, sweepMargin);
125 CalculateBoxMargin(extent, margin, minMargin, sweepMargin, BOX_MARGIN_CCD_RATIO, BOX_MIN_MARGIN_CCD_RATIO);
137 minMargin =
PxMin(toleranceLength * BOX_MIN_MARGIN_RATIO, minMargin);
143 center = other.center;
144 extents = other.extents;
145 margin = other.margin;
146 minMargin = other.minMargin;
147 sweepMargin = other.sweepMargin;
155 for(PxU32 i=0; i<numInds; ++i)
156 verts[i] = V3LoadU_SafeReadW(originalVerts[inds[i]]);
162 const BoolV con = boxVertexTable[index];
163 return V3Sel(con, extents, V3Neg(extents));
169 index = PxI32(BGetBitMask(con) & 0x7);
175 return V3Sel(V3IsGrtr(dir, V3Zero()), extents, V3Neg(extents));
179 PX_SUPPORT_INLINE
void supportLocal(
const aos::Vec3VArg dir, aos::FloatV& min, aos::FloatV& max)
const
182 const Vec3V point = V3Sel(V3IsGrtr(dir, V3Zero()), extents, V3Neg(extents));
183 max = V3Dot(dir, point);
187 PX_SUPPORT_INLINE aos::Vec3V supportRelative(
const aos::Vec3VArg dir,
const aos::PxMatTransformV& aTob,
const aos::PxMatTransformV& aTobT)
const
192 const Vec3V _dir = aTobT.rotate(dir);
193 const Vec3V p = supportLocal(_dir);
195 return aTob.transform(p);
198 PX_SUPPORT_INLINE aos::Vec3V supportLocal(
const aos::Vec3VArg dir, PxI32& index)
const
201 const BoolV comp = V3IsGrtr(dir, V3Zero());
202 getIndex(comp, index);
203 return V3Sel(comp, extents, V3Neg(extents));
206 PX_SUPPORT_INLINE aos::Vec3V supportRelative(
const aos::Vec3VArg dir,
const aos::PxMatTransformV& aTob,
207 const aos::PxMatTransformV& aTobT, PxI32& index)
const
212 const Vec3V _dir = aTobT.rotate(dir);
213 const Vec3V p = supportLocal(_dir, index);
215 return aTob.transform(p);
Definition GuVecBox.h:102
PX_INLINE ~BoxV()
Destructor.
Definition GuVecBox.h:131
PX_FORCE_INLINE const BoxV & operator=(const BoxV &other)
Assignment operator.
Definition GuVecBox.h:141
PX_INLINE BoxV()
Constructor.
Definition GuVecBox.h:108
Definition GuVecConvex.h:58
Class representing the geometry of a box.
Definition PxBoxGeometry.h:49
PxVec3 halfExtents
Half of the width, height, and depth of the box.
Definition PxBoxGeometry.h:97
A geometry object.
Definition PxGeometry.h:79
3 Element vector class.
Definition PxVec3.h:50
#define PX_FORCE_INLINE
Definition PxPreprocessor.h:335
#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
PX_CUDA_CALLABLE PX_FORCE_INLINE T PxMin(T a, T b)
The return value is the lesser of the two specified values.
Definition PxMath.h:88
Definition GuVecConvex.h:43
Definition PxVecMathAoSScalar.h:90
Definition PxVecMathAoSScalar.h:77