RavEngine
Loading...
Searching...
No Matches
PxCustomGeometryExt.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_CUSTOM_GEOMETRY_EXT_H
30#define PX_CUSTOM_GEOMETRY_EXT_H
35#include <geometry/PxCustomGeometry.h>
36#include <geometry/PxGjkQuery.h>
37
38#if !PX_DOXYGEN
39namespace physx
40{
41#endif
42
43class PxGeometry;
44class PxMassProperties;
45class PxGeometryHolder;
46struct PxContactPoint;
47
52{
53public:
54
56 struct BaseConvexCallbacks : PxCustomGeometry::Callbacks, PxGjkQuery::Support
57 {
58 float margin;
59
60 BaseConvexCallbacks(float _margin) : margin(_margin) {}
61
62 // override PxCustomGeometry::Callbacks
63 virtual PxBounds3 getLocalBounds(const PxGeometry& geometry) const;
64 virtual bool generateContacts(const PxGeometry& geom0, const PxGeometry& geom1, const PxTransform& pose0, const PxTransform& pose1,
65 const PxReal contactDistance, const PxReal meshContactMargin, const PxReal toleranceLength,
66 PxContactBuffer& contactBuffer) const;
67 virtual PxU32 raycast(const PxVec3& origin, const PxVec3& unitDir, const PxGeometry& geom, const PxTransform& pose,
68 PxReal maxDist, PxHitFlags hitFlags, PxU32 maxHits, PxGeomRaycastHit* rayHits, PxU32 stride, PxRaycastThreadContext*) const;
69 virtual bool overlap(const PxGeometry& geom0, const PxTransform& pose0, const PxGeometry& geom1, const PxTransform& pose1, PxOverlapThreadContext*) const;
70 virtual bool sweep(const PxVec3& unitDir, const PxReal maxDist,
71 const PxGeometry& geom0, const PxTransform& pose0, const PxGeometry& geom1, const PxTransform& pose1,
72 PxGeomSweepHit& sweepHit, PxHitFlags hitFlags, const PxReal inflation, PxSweepThreadContext*) const;
73 virtual bool usePersistentContactManifold(const PxGeometry& geometry, PxReal& breakingThreshold) const;
74
75 // override PxGjkQuery::Support
76 virtual PxReal getMargin() const { return margin; }
77
78 protected:
79
80 // Substitute geometry
81 virtual bool useSubstituteGeometry(PxGeometryHolder& geom, PxTransform& preTransform, const PxContactPoint& p, const PxTransform& pose0, const PxVec3& pos1) const = 0;
82 };
84
88 struct CylinderCallbacks : BaseConvexCallbacks
89 {
91 float height;
93 float radius;
95 int axis;
96
105 CylinderCallbacks(float height, float radius, int axis = 0, float margin = 0);
106
108 // override PxCustomGeometry::Callbacks
110 virtual void visualize(const PxGeometry&, PxRenderOutput&, const PxTransform&, const PxBounds3&) const;
111 virtual void computeMassProperties(const PxGeometry& geometry, PxMassProperties& massProperties) const;
112
113 // override PxGjkQuery::Support
114 virtual PxVec3 supportLocal(const PxVec3& dir) const;
115
116 protected:
117
118 // Substitute geometry
119 virtual bool useSubstituteGeometry(PxGeometryHolder& geom, PxTransform& preTransform, const PxContactPoint& p, const PxTransform& pose0, const PxVec3& pos1) const;
120
121 // Radius at height
122 float getRadiusAtHeight(float height) const;
124 };
125
129 struct ConeCallbacks : BaseConvexCallbacks
130 {
132 float height;
134 float radius;
136 int axis;
137
146 ConeCallbacks(float height, float radius, int axis = 0, float margin = 0);
147
149 // override PxCustomGeometry::Callbacks
151 virtual void visualize(const PxGeometry&, PxRenderOutput&, const PxTransform&, const PxBounds3&) const;
152 virtual void computeMassProperties(const PxGeometry& geometry, PxMassProperties& massProperties) const;
153
154 // override PxGjkQuery::Support
155 virtual PxVec3 supportLocal(const PxVec3& dir) const;
156
157 protected:
158
159 // Substitute geometry
160 virtual bool useSubstituteGeometry(PxGeometryHolder& geom, PxTransform& preTransform, const PxContactPoint& p, const PxTransform& pose0, const PxVec3& pos1) const;
161
162 // Radius at height
163 float getRadiusAtHeight(float height) const;
165 };
166};
167
168#if !PX_DOXYGEN
169}
170#endif
171
173#endif
Class representing 3D range or axis aligned bounding box.
Definition PxBounds3.h:58
Definition PxContactBuffer.h:42
Pre-made custom geometry callbacks implementations.
Definition PxCustomGeometryExt.h:52
Geometry holder class.
Definition PxGeometryHelpers.h:66
A geometry object.
Definition PxGeometry.h:79
Utility class to compute and manipulate mass and inertia tensor properties.
Definition PxMassProperties.h:65
Definition PxRenderOutput.h:50
class representing a rigid euclidean transform as a quaternion and a vector
Definition PxTransform.h:49
3 Element vector class.
Definition PxVec3.h:50
#define DECLARE_CUSTOM_GEOMETRY_TYPE
Used in pair with IMPLEMENT_CUSTOM_GEOMETRY_TYPE to overwrite Callbacks::getCustomType() callback.
Definition PxCustomGeometry.h:291
Sorts an array of objects in ascending order, assuming that the predicate implements the < operator:
Definition PxBoxController.h:39
Definition PxContactPoint.h:40
Cone geometry callbacks.
Definition PxCustomGeometryExt.h:130
float height
Cone height.
Definition PxCustomGeometryExt.h:132
int axis
Cone axis.
Definition PxCustomGeometryExt.h:136
float radius
Cone radius.
Definition PxCustomGeometryExt.h:134
Cylinder geometry callbacks.
Definition PxCustomGeometryExt.h:89
float height
Cylinder height.
Definition PxCustomGeometryExt.h:91
int axis
Cylinder axis.
Definition PxCustomGeometryExt.h:95
float radius
Cylinder radius.
Definition PxCustomGeometryExt.h:93
Custom geometry callbacks structure. User should inherit this and implement all pure virtual function...
Definition PxCustomGeometry.h:102
Stores results of raycast queries.
Definition PxGeometryHit.h:151
Stores results of sweep queries.
Definition PxGeometryHit.h:175
Abstract interface for a user defined shape GJK mapping support. A user defined shape consists of a c...
Definition PxGjkQuery.h:55
A per-thread context passed to low-level query functions.
Definition PxGeometryQueryContext.h:52