RavEngine
Loading...
Searching...
No Matches
PxGjkQueryExt.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 PX_GJK_QUERY_EXT_H
30#define PX_GJK_QUERY_EXT_H
31
32#include "geometry/PxGjkQuery.h"
33#include "geometry/PxGeometry.h"
34
35#if !PX_DOXYGEN
36namespace physx
37{
38#endif
39
40class PxSphereGeometry;
41class PxCapsuleGeometry;
42class PxBoxGeometry;
43class PxConvexMeshGeometry;
44class PxContactBuffer;
45class PxConvexMesh;
46
51{
52public:
57 {
58 PxReal radius;
59
67 SphereSupport(PxReal radius);
72
73 virtual PxReal getMargin() const;
74 virtual PxVec3 supportLocal(const PxVec3& dir) const;
75 };
76
81 {
82 PxReal radius, halfHeight;
83
91 CapsuleSupport(PxReal radius, PxReal halfHeight);
96
97 virtual PxReal getMargin() const;
98 virtual PxVec3 supportLocal(const PxVec3& dir) const;
99 };
100
105 {
106 PxVec3 halfExtents;
107 PxReal margin;
108
112 BoxSupport();
116 BoxSupport(const PxVec3& halfExtents, PxReal margin = 0);
120 BoxSupport(const PxBoxGeometry& box, PxReal margin = 0);
121
122 virtual PxReal getMargin() const;
123 virtual PxVec3 supportLocal(const PxVec3& dir) const;
124 };
125
130 {
131 const PxConvexMesh* convexMesh;
132 PxVec3 scale;
133 PxQuat scaleRotation;
134 PxReal margin;
135
143 ConvexMeshSupport(const PxConvexMesh& convexMesh, const PxVec3& scale = PxVec3(1), const PxQuat& scaleRotation = PxQuat(PxIdentity), PxReal margin = 0);
147 ConvexMeshSupport(const PxConvexMeshGeometry& convexMesh, PxReal margin = 0);
148
149 virtual PxReal getMargin() const;
150 virtual PxVec3 supportLocal(const PxVec3& dir) const;
151 };
152
157 {
165 ConvexGeomSupport(const PxGeometry& geom, PxReal margin = 0);
170
174 bool isValid() const;
175
176 virtual PxReal getMargin() const;
177 virtual PxVec3 supportLocal(const PxVec3& dir) const;
178
179 private:
181 union {
182 void* alignment;
183 PxU8 sphere[sizeof(SphereSupport)];
184 PxU8 capsule[sizeof(CapsuleSupport)];
185 PxU8 box[sizeof(BoxSupport)];
186 PxU8 convexMesh[sizeof(ConvexMeshSupport)];
187 } mSupport;
188 };
189
203 static bool generateContacts(const PxGjkQuery::Support& a, const PxGjkQuery::Support& b, const PxTransform& poseA, const PxTransform& poseB,
204 PxReal contactDistance, PxReal toleranceLength, PxContactBuffer& contactBuffer);
205
206};
207
208#if !PX_DOXYGEN
209}
210#endif
211
212#endif
Class representing the geometry of a box.
Definition PxBoxGeometry.h:49
Class representing the geometry of a capsule.
Definition PxCapsuleGeometry.h:54
Definition PxContactBuffer.h:42
Convex mesh geometry class.
Definition PxConvexMeshGeometry.h:79
A convex mesh.
Definition PxConvexMesh.h:83
A geometry object.
Definition PxGeometry.h:79
Pre-made support mapping for built-in convex geometry types.
Definition PxGjkQueryExt.h:51
static bool generateContacts(const PxGjkQuery::Support &a, const PxGjkQuery::Support &b, const PxTransform &poseA, const PxTransform &poseB, PxReal contactDistance, PxReal toleranceLength, PxContactBuffer &contactBuffer)
Generates a contact point between two shapes using GJK-EPA algorithm.
Definition ExtGjkQueryExt.cpp:235
This is a quaternion class. For more information on quaternion mathematics consult a mathematics sour...
Definition PxQuat.h:50
A class representing the geometry of a sphere.
Definition PxSphereGeometry.h:48
class representing a rigid euclidean transform as a quaternion and a vector
Definition PxTransform.h:49
3 Element vector class.
Definition PxVec3.h:50
Sorts an array of objects in ascending order, assuming that the predicate implements the < operator:
Definition PxBoxController.h:39
Enum
Definition PxGeometry.h:52
Pre-made support mapping for a box.
Definition PxGjkQueryExt.h:105
virtual PxReal getMargin() const
Return the user defined shape margin. Margin should be greater than or equal to 0.
Definition ExtGjkQueryExt.cpp:102
BoxSupport()
Default constructor.
Definition ExtGjkQueryExt.cpp:90
virtual PxVec3 supportLocal(const PxVec3 &dir) const
Return the farthest point on the user defined shape's core in given direction.
Definition ExtGjkQueryExt.cpp:107
Pre-made support mapping for a capsule.
Definition PxGjkQueryExt.h:81
virtual PxVec3 supportLocal(const PxVec3 &dir) const
Return the farthest point on the user defined shape's core in given direction.
Definition ExtGjkQueryExt.cpp:83
CapsuleSupport()
Default constructor.
Definition ExtGjkQueryExt.cpp:66
virtual PxReal getMargin() const
Return the user defined shape margin. Margin should be greater than or equal to 0.
Definition ExtGjkQueryExt.cpp:78
Pre-made support mapping for any PhysX's convex geometry (sphere, capsule, box, convex mesh)
Definition PxGjkQueryExt.h:157
virtual PxVec3 supportLocal(const PxVec3 &dir) const
Return the farthest point on the user defined shape's core in given direction.
Definition ExtGjkQueryExt.cpp:228
virtual PxReal getMargin() const
Return the user defined shape margin. Margin should be greater than or equal to 0.
Definition ExtGjkQueryExt.cpp:223
ConvexGeomSupport()
Default constructor.
Definition ExtGjkQueryExt.cpp:172
bool isValid() const
Returns false if ConvexGeomSupport was constructed from non-convex geometry.
Definition ExtGjkQueryExt.cpp:218
~ConvexGeomSupport()
Destructor.
Definition ExtGjkQueryExt.cpp:212
Pre-made support mapping for a convex mesh.
Definition PxGjkQueryExt.h:130
ConvexMeshSupport()
Default constructor.
Definition ExtGjkQueryExt.cpp:115
virtual PxVec3 supportLocal(const PxVec3 &dir) const
Return the farthest point on the user defined shape's core in given direction.
Definition ExtGjkQueryExt.cpp:144
virtual PxReal getMargin() const
Return the user defined shape margin. Margin should be greater than or equal to 0.
Definition ExtGjkQueryExt.cpp:139
Pre-made support mapping for a sphere.
Definition PxGjkQueryExt.h:57
SphereSupport()
Default constructor.
Definition ExtGjkQueryExt.cpp:42
virtual PxVec3 supportLocal(const PxVec3 &dir) const
Return the farthest point on the user defined shape's core in given direction.
Definition ExtGjkQueryExt.cpp:59
virtual PxReal getMargin() const
Return the user defined shape margin. Margin should be greater than or equal to 0.
Definition ExtGjkQueryExt.cpp:54
Abstract interface for a user defined shape GJK mapping support. A user defined shape consists of a c...
Definition PxGjkQuery.h:55