RavEngine
Loading...
Searching...
No Matches
GuSweepTests.h
1// Redistribution and use in source and binary forms, with or without
2// modification, are permitted provided that the following conditions
3// are met:
4// * Redistributions of source code must retain the above copyright
5// notice, this list of conditions and the following disclaimer.
6// * Redistributions in binary form must reproduce the above copyright
7// notice, this list of conditions and the following disclaimer in the
8// documentation and/or other materials provided with the distribution.
9// * Neither the name of NVIDIA CORPORATION nor the names of its
10// contributors may be used to endorse or promote products derived
11// from this software without specific prior written permission.
12//
13// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
14// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24//
25// Copyright (c) 2008-2022 NVIDIA Corporation. All rights reserved.
26// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
27// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
28
29#ifndef GU_SWEEP_TESTS_H
30#define GU_SWEEP_TESTS_H
31
32#include "geometry/PxGeometry.h"
33#include "geometry/PxGeometryHit.h"
34#include "geometry/PxGeometryQueryContext.h"
35
36namespace physx
37{
38 class PxConvexMeshGeometry;
39 class PxCapsuleGeometry;
40 class PxTriangle;
41 class PxBoxGeometry;
42
43 #define UNUSED_SWEEP_THREAD_CONTEXT NULL
44
45 // PT: TODO: unify this with raycast calls (names and order of params)
46
47 // PT: we use defines to be able to quickly change the signature of all sweep functions.
48 // (this also ensures they all use consistent names for passed parameters).
49 // \param[in] geom geometry object to sweep against
50 // \param[in] pose pose of geometry object
51 // \param[in] unitDir sweep's unit dir
52 // \param[in] distance sweep's length/max distance
53 // \param[out] sweepHit hit result
54 // \param[in] hitFlags query behavior flags
55 // \param[in] inflation optional inflation value for swept shape
56 // \param[in] threadContext optional per-thread context
57
58 // PT: sweep parameters for capsule
59 #define GU_CAPSULE_SWEEP_FUNC_PARAMS const PxGeometry& geom, const PxTransform& pose, \
60 const PxCapsuleGeometry& capsuleGeom_, const PxTransform& capsulePose_, const Gu::Capsule& lss, \
61 const PxVec3& unitDir, PxReal distance, \
62 PxGeomSweepHit& sweepHit, const PxHitFlags hitFlags, PxReal inflation, PxSweepThreadContext* threadContext
63
64 // PT: sweep parameters for box
65 #define GU_BOX_SWEEP_FUNC_PARAMS const PxGeometry& geom, const PxTransform& pose, \
66 const PxBoxGeometry& boxGeom_, const PxTransform& boxPose_, const Gu::Box& box, \
67 const PxVec3& unitDir, PxReal distance, \
68 PxGeomSweepHit& sweepHit, const PxHitFlags hitFlags, PxReal inflation, PxSweepThreadContext* threadContext
69
70 // PT: sweep parameters for convex
71 #define GU_CONVEX_SWEEP_FUNC_PARAMS const PxGeometry& geom, const PxTransform& pose, \
72 const PxConvexMeshGeometry& convexGeom, const PxTransform& convexPose, \
73 const PxVec3& unitDir, PxReal distance, \
74 PxGeomSweepHit& sweepHit, const PxHitFlags hitFlags, PxReal inflation, PxSweepThreadContext* threadContext
75 namespace Gu
76 {
77 class Capsule;
78 class Box;
79
80 // PT: function pointer for Geom-indexed capsule sweep functions
81 // See GU_CAPSULE_SWEEP_FUNC_PARAMS for function parameters details.
82 // \return true if a hit was found, false otherwise
83 typedef bool (*SweepCapsuleFunc) (GU_CAPSULE_SWEEP_FUNC_PARAMS);
84
85 // PT: function pointer for Geom-indexed box sweep functions
86 // See GU_BOX_SWEEP_FUNC_PARAMS for function parameters details.
87 // \return true if a hit was found, false otherwise
88 typedef bool (*SweepBoxFunc) (GU_BOX_SWEEP_FUNC_PARAMS);
89
90 // PT: function pointer for Geom-indexed box sweep functions
91 // See GU_CONVEX_SWEEP_FUNC_PARAMS for function parameters details.
92 // \return true if a hit was found, false otherwise
93 typedef bool (*SweepConvexFunc) (GU_CONVEX_SWEEP_FUNC_PARAMS);
94
95 // PT: typedef for bundles of all sweep functions, i.e. the function tables themselves (indexed by geom-type).
96 typedef SweepCapsuleFunc GeomSweepCapsuleTable [PxGeometryType::eGEOMETRY_COUNT];
97 typedef SweepBoxFunc GeomSweepBoxTable [PxGeometryType::eGEOMETRY_COUNT];
98 typedef SweepConvexFunc GeomSweepConvexTable [PxGeometryType::eGEOMETRY_COUNT];
99
101 {
102 GeomSweepCapsuleTable capsuleMap;
103 GeomSweepCapsuleTable preciseCapsuleMap;
104 GeomSweepBoxTable boxMap;
105 GeomSweepBoxTable preciseBoxMap;
106 GeomSweepConvexTable convexMap;
107 };
108 // PT: grabs all sweep function tables at once (for access by external non-Gu modules)
109 PX_PHYSX_COMMON_API const GeomSweepFuncs& getSweepFuncTable();
110
111 // PT: signature for sweep-vs-triangles functions.
112 // We use defines to be able to quickly change the signature of all sweep functions.
113 // (this also ensures they all use consistent names for passed parameters).
114 // \param[in] nbTris number of triangles in input array
115 // \param[in] triangles array of triangles to sweep the shape against
116 // \param[in] doubleSided true if input triangles are double-sided
117 // \param[in] x geom to sweep against input triangles
118 // \param[in] pose pose of geom x
119 // \param[in] unitDir sweep's unit dir
120 // \param[in] distance sweep's length/max distance
121 // \param[out] hit hit result
122 // \param[in] cachedIndex optional initial triangle index (must be <nbTris)
123 // \param[in] inflation optional inflation value for swept shape
124 // \param[in] hitFlags query behavior flags
125 #define GU_SWEEP_TRIANGLES_FUNC_PARAMS(x) PxU32 nbTris, const PxTriangle* triangles, bool doubleSided, \
126 const x& geom, const PxTransform& pose, \
127 const PxVec3& unitDir, const PxReal distance, \
128 PxGeomSweepHit& hit, const PxU32* cachedIndex, \
129 const PxReal inflation, PxHitFlags hitFlags
130
131 bool sweepCapsuleTriangles (GU_SWEEP_TRIANGLES_FUNC_PARAMS(PxCapsuleGeometry));
132 bool sweepBoxTriangles (GU_SWEEP_TRIANGLES_FUNC_PARAMS(PxBoxGeometry));
133 bool sweepBoxTriangles_Precise (GU_SWEEP_TRIANGLES_FUNC_PARAMS(PxBoxGeometry));
134
135 } // namespace Gu
136}
137
138#endif
Class representing the geometry of a box.
Definition PxBoxGeometry.h:49
Class representing the geometry of a capsule.
Definition PxCapsuleGeometry.h:54
Sorts an array of objects in ascending order, assuming that the predicate implements the < operator:
Definition PxBoxController.h:39
Definition GuSweepTests.h:101
@ eGEOMETRY_COUNT
internal use only!
Definition PxGeometry.h:65