29#ifndef GU_MIDPHASE_INTERFACE_H
30#define GU_MIDPHASE_INTERFACE_H
32#include "GuOverlapTests.h"
33#include "GuRaycastTests.h"
34#include "GuTriangleMesh.h"
35#include "GuTetrahedronMesh.h"
36#include "foundation/PxVecMath.h"
37#include "PxQueryReport.h"
38#include "geometry/PxMeshQuery.h"
47 class PxTriangleMeshGeometry;
50 class FastVertex2ShapeScaling;
55 struct ConvexHullData;
59 template<
typename HitType>
62 CallbackMode::Enum mode;
66 PX_FORCE_INLINE bool inAnyMode()
const {
return mode == CallbackMode::eANY; }
67 PX_FORCE_INLINE bool inClosestMode()
const {
return mode == CallbackMode::eCLOSEST; }
68 PX_FORCE_INLINE bool inMultipleMode()
const {
return mode == CallbackMode::eMULTIPLE; }
71 const HitType& hit,
const PxVec3& v0,
const PxVec3& v1,
const PxVec3& v2, PxReal& shrunkMaxT,
const PxU32* vIndices) = 0;
76 template<
typename HitType>
79 CallbackMode::Enum mode;
83 PX_FORCE_INLINE bool inAnyMode()
const {
return mode == CallbackMode::eANY; }
84 PX_FORCE_INLINE bool inClosestMode()
const {
return mode == CallbackMode::eCLOSEST; }
85 PX_FORCE_INLINE bool inMultipleMode()
const {
return mode == CallbackMode::eMULTIPLE; }
88 const HitType& hit,
const PxVec3& v0,
const PxVec3& v1,
const PxVec3& v2,
const PxVec3& v3, PxReal& shrunkMaxT,
const PxU32* vIndices) = 0;
107 : mResults(results), mMaxResults(maxResults), mStartIndex(startIndex)
121 if(mNbResults>=mMaxResults)
127 if(mNbSkipped>=mStartIndex)
128 mResults[mNbResults++] = index;
138 const PxVec3& rayOrigin,
const PxVec3& rayDir, PxReal maxDist,
146 PxGeomSweepHit& sweepHit, PxHitFlags hitFlags,
const PxReal inflation);
148 const Gu::Box& box,
const PxVec3& unitDir,
const PxReal distance,
149 PxGeomSweepHit& sweepHit, PxHitFlags hitFlags,
const PxReal inflation);
155 const PxVec3& rayOrigin,
const PxVec3& rayDir, PxReal maxDist,
164 PxGeomSweepHit& sweepHit, PxHitFlags hitFlags,
const PxReal inflation);
166 const Gu::Box& box,
const PxVec3& unitDir,
const PxReal distance,
167 PxGeomSweepHit& sweepHit, PxHitFlags hitFlags,
const PxReal inflation);
173 const PxVec3& rayOrigin,
const PxVec3& rayDir, PxReal maxDist,
183 PxGeomSweepHit& sweepHit, PxHitFlags hitFlags,
const PxReal inflation);
185 const Gu::Box& box,
const PxVec3& unitDir,
const PxReal distance,
186 PxGeomSweepHit& sweepHit, PxHitFlags hitFlags,
const PxReal inflation);
190 static const MidphaseRaycastFunction gMidphaseRaycastTable[PxMeshMidPhase::eLAST] =
192 raycast_triangleMesh_RTREE,
193 raycast_triangleMesh_BV4,
196 static const MidphaseSphereOverlapFunction gMidphaseSphereOverlapTable[PxMeshMidPhase::eLAST] =
198 intersectSphereVsMesh_RTREE,
199 intersectSphereVsMesh_BV4,
202 static const MidphaseBoxOverlapFunction gMidphaseBoxOverlapTable[PxMeshMidPhase::eLAST] =
204 intersectBoxVsMesh_RTREE,
205 intersectBoxVsMesh_BV4,
208 static const MidphaseCapsuleOverlapFunction gMidphaseCapsuleOverlapTable[PxMeshMidPhase::eLAST] =
210 intersectCapsuleVsMesh_RTREE,
211 intersectCapsuleVsMesh_BV4,
214 static const MidphaseBoxCBOverlapFunction gMidphaseBoxCBOverlapTable[PxMeshMidPhase::eLAST] =
220 static const MidphaseBoxSweepFunction gMidphaseBoxSweepTable[PxMeshMidPhase::eLAST] =
222 sweepBox_MeshGeom_RTREE,
223 sweepBox_MeshGeom_BV4,
226 static const MidphaseCapsuleSweepFunction gMidphaseCapsuleSweepTable[PxMeshMidPhase::eLAST] =
228 sweepCapsule_MeshGeom_RTREE,
229 sweepCapsule_MeshGeom_BV4,
232 static const MidphaseConvexSweepFunction gMidphaseConvexSweepTable[PxMeshMidPhase::eLAST] =
234 sweepConvex_MeshGeom_RTREE,
235 sweepConvex_MeshGeom_BV4,
238 static const MidphasePointMeshFunction gMidphasePointMeshTable[PxMeshMidPhase::eLAST] =
240 pointMeshDistance_RTREE,
241 pointMeshDistance_BV4,
257 PX_FORCE_INLINE PxU32 raycastTriangleMesh(
const TriangleMesh* mesh,
const PxTriangleMeshGeometry& meshGeom,
const PxTransform& meshTransform,
258 const PxVec3& rayOrigin,
const PxVec3& rayDir, PxReal maxDist,
259 PxHitFlags hitFlags, PxU32 maxHits, PxGeomRaycastHit*
PX_RESTRICT hits, PxU32 stride)
261 const PxU32 index = PxU32(mesh->getConcreteType() - PxConcreteType::eTRIANGLE_MESH_BVH33);
262 return gMidphaseRaycastTable[index](mesh, meshGeom, meshTransform, rayOrigin, rayDir, maxDist, hitFlags, maxHits, hits, stride);
271 PX_FORCE_INLINE bool intersectSphereVsMesh(
const Sphere& sphere,
const TriangleMesh& mesh,
const PxTransform& meshTransform,
const PxMeshScale& meshScale, LimitedResults* results)
273 const PxU32 index = PxU32(mesh.getConcreteType() - PxConcreteType::eTRIANGLE_MESH_BVH33);
274 return gMidphaseSphereOverlapTable[index](sphere, mesh, meshTransform, meshScale, results);
284 PX_FORCE_INLINE bool intersectBoxVsMesh(
const Box& box,
const TriangleMesh& mesh,
const PxTransform& meshTransform,
const PxMeshScale& meshScale, LimitedResults* results)
286 const PxU32 index = PxU32(mesh.getConcreteType() - PxConcreteType::eTRIANGLE_MESH_BVH33);
287 return gMidphaseBoxOverlapTable[index](box, mesh, meshTransform, meshScale, results);
296 PX_FORCE_INLINE bool intersectCapsuleVsMesh(
const Capsule& capsule,
const TriangleMesh& mesh,
const PxTransform& meshTransform,
const PxMeshScale& meshScale, LimitedResults* results)
298 const PxU32 index = PxU32(mesh.getConcreteType() - PxConcreteType::eTRIANGLE_MESH_BVH33);
299 return gMidphaseCapsuleOverlapTable[index](capsule, mesh, meshTransform, meshScale, results);
307 PX_FORCE_INLINE void intersectOBB(
const TriangleMesh* mesh,
const Box& obb, MeshHitCallback<PxGeomRaycastHit>& callback,
bool bothTriangleSidesCollide,
bool checkObbIsAligned =
true)
309 const PxU32 index = PxU32(mesh->getConcreteType() - PxConcreteType::eTRIANGLE_MESH_BVH33);
310 gMidphaseBoxCBOverlapTable[index](mesh, obb, callback, bothTriangleSidesCollide, checkObbIsAligned);
316 PX_FORCE_INLINE void intersectOBB(
const TetrahedronMesh* mesh,
const Box& obb, TetMeshHitCallback<PxGeomRaycastHit>& callback)
318 intersectOBB_BV4(mesh, obb, callback);
331 PX_FORCE_INLINE bool sweepCapsuleVsMesh(
const TriangleMesh* mesh,
const PxTriangleMeshGeometry& meshGeom,
const PxTransform& meshTransform,
332 const Gu::Capsule& capsule,
const PxVec3& unitDir,
const PxReal distance,
333 PxGeomSweepHit& sweepHit, PxHitFlags hitFlags,
const PxReal inflation)
335 const PxU32 index = PxU32(mesh->getConcreteType() - PxConcreteType::eTRIANGLE_MESH_BVH33);
336 return gMidphaseCapsuleSweepTable[index](mesh, meshGeom, meshTransform, capsule, unitDir, distance, sweepHit, hitFlags, inflation);
349 PX_FORCE_INLINE bool sweepBoxVsMesh(
const TriangleMesh* mesh,
const PxTriangleMeshGeometry& meshGeom,
const PxTransform& meshTransform,
350 const Gu::Box& box,
const PxVec3& unitDir,
const PxReal distance,
351 PxGeomSweepHit& sweepHit, PxHitFlags hitFlags,
const PxReal inflation)
353 const PxU32 index = PxU32(mesh->getConcreteType() - PxConcreteType::eTRIANGLE_MESH_BVH33);
354 return gMidphaseBoxSweepTable[index](mesh, meshGeom, meshTransform, box, unitDir, distance, sweepHit, hitFlags, inflation);
363 PX_FORCE_INLINE void sweepConvexVsMesh(
const TriangleMesh* mesh,
const Gu::Box& hullBox,
const PxVec3& localDir,
const PxReal distance, SweepConvexMeshHitCallback& callback,
bool anyHit)
365 const PxU32 index = PxU32(mesh->getConcreteType() - PxConcreteType::eTRIANGLE_MESH_BVH33);
366 gMidphaseConvexSweepTable[index](mesh, hullBox, localDir, distance, callback, anyHit);
369 PX_FORCE_INLINE void pointMeshDistance(
const TriangleMesh* mesh,
const PxTriangleMeshGeometry& meshGeom,
const PxTransform& pose,
const PxVec3& point,
float maxDist
370 , PxU32& closestIndex,
float& dist, PxVec3& closestPt)
372 const PxU32 index = PxU32(mesh->getConcreteType() - PxConcreteType::eTRIANGLE_MESH_BVH33);
373 gMidphasePointMeshTable[index](mesh, meshGeom, pose, point, maxDist, closestIndex, dist, closestPt);
Represents an oriented bounding box.
Definition GuBox.h:72
Represents a capsule.
Definition GuCapsule.h:47
Definition GuTetrahedronMesh.h:120
Definition GuTriangleMesh.h:78
A class expressing a nonuniform scaling transformation.
Definition PxMeshScale.h:69
Base class for callback reporting an unknown number of items to users.
Definition PxReportCallback.h:60
Triangle mesh geometry class.
Definition PxTriangleMeshGeometry.h:81
3 Element vector class.
Definition PxVec3.h:50
#define PX_RESTRICT
Definition PxPreprocessor.h:355
#define PX_FORCE_INLINE
Definition PxPreprocessor.h:335
Sorts an array of objects in ascending order, assuming that the predicate implements the < operator:
Definition PxBoxController.h:39
bool PxAgain
Describes query behavior after returning a partial query result via a callback.
Definition PxQueryReport.h:78
Definition GuMidphaseInterface.h:57
Definition GuMidphaseInterface.h:98
Definition GuMidphaseInterface.h:61
Definition GuSweepMesh.h:117
Definition GuMidphaseInterface.h:78
Stores results of raycast queries.
Definition PxGeometryHit.h:151
Stores results of sweep queries.
Definition PxGeometryHit.h:175