RavEngine
Loading...
Searching...
No Matches
PxCustomGeometry.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_CUSTOMGEOMETRY_H
30#define PX_CUSTOMGEOMETRY_H
35#include "geometry/PxGeometry.h"
36#include "geometry/PxGeometryHit.h"
37#include "geometry/PxGeometryQueryContext.h"
38#include "foundation/PxFoundationConfig.h"
39
40#if !PX_DOXYGEN
41namespace physx
42{
43#endif
44 class PxContactBuffer;
45 class PxRenderOutput;
46 class PxMassProperties;
47
52 {
53 public:
57 PX_PHYSX_COMMON_API static PxU32 getUniqueID();
58
62 struct Type
63 {
68
72 PX_INLINE Type(const Type& t) : mID(t.mID) {}
73
77 PX_INLINE Type& operator = (const Type& t) { mID = t.mID; return *this; }
78
82 PX_INLINE bool operator == (const Type& t) const { return mID == t.mID; }
83
87 PX_INLINE bool operator != (const Type& t) const { return mID != t.mID; }
88
92 PX_INLINE static Type INVALID() { PxU32 z(0); return reinterpret_cast<const Type&>(z); }
93
94 private:
95 PxU32 mID;
96 };
97
102 {
110 virtual Type getCustomType() const = 0;
111
119 virtual PxBounds3 getLocalBounds(const PxGeometry& geometry) const = 0;
120
135 virtual bool generateContacts(const PxGeometry& geom0, const PxGeometry& geom1, const PxTransform& pose0, const PxTransform& pose1,
136 const PxReal contactDistance, const PxReal meshContactMargin, const PxReal toleranceLength,
137 PxContactBuffer& contactBuffer) const = 0;
138
155 virtual PxU32 raycast(const PxVec3& origin, const PxVec3& unitDir, const PxGeometry& geom, const PxTransform& pose,
156 PxReal maxDist, PxHitFlags hitFlags, PxU32 maxHits, PxGeomRaycastHit* rayHits, PxU32 stride, PxRaycastThreadContext* threadContext) const = 0;
157
169 virtual bool overlap(const PxGeometry& geom0, const PxTransform& pose0, const PxGeometry& geom1, const PxTransform& pose1, PxOverlapThreadContext* threadContext) const = 0;
170
187 virtual bool sweep(const PxVec3& unitDir, const PxReal maxDist,
188 const PxGeometry& geom0, const PxTransform& pose0, const PxGeometry& geom1, const PxTransform& pose1,
189 PxGeomSweepHit& sweepHit, PxHitFlags hitFlags, const PxReal inflation, PxSweepThreadContext* threadContext) const = 0;
190
199 virtual void visualize(const PxGeometry& geometry, PxRenderOutput& out, const PxTransform& absPose, const PxBounds3& cullbox) const = 0;
200
207 virtual void computeMassProperties(const PxGeometry& geometry, PxMassProperties& massProperties) const = 0;
208
215 virtual bool usePersistentContactManifold(const PxGeometry& geometry, PxReal& breakingThreshold) const = 0;
216
217 /* Destructor */
218 virtual ~Callbacks() {}
219 };
220
227 PxGeometry(PxGeometryType::eCUSTOM),
228 callbacks(NULL)
229 {}
230
235 PxGeometry(PxGeometryType::eCUSTOM),
236 callbacks(&_callbacks)
237 {}
238
245 PxGeometry(that),
246 callbacks(that.callbacks)
247 {}
248
253 {
254 mType = that.mType;
255 callbacks = that.callbacks;
256 }
257
265 PX_INLINE bool isValid() const;
266
274
275 public:
277 };
278
280 {
281 return mType == PxGeometryType::eCUSTOM && callbacks != NULL;
282 }
283
284#if !PX_DOXYGEN
285} // namespace physx
286#endif
287
291#define DECLARE_CUSTOM_GEOMETRY_TYPE \
292 static ::physx::PxCustomGeometry::Type TYPE(); \
293 virtual ::physx::PxCustomGeometry::Type getCustomType() const;
294
298#define IMPLEMENT_CUSTOM_GEOMETRY_TYPE(CLASS) \
299::physx::PxCustomGeometry::Type CLASS::TYPE() \
300{ \
301 static ::physx::PxCustomGeometry::Type customType; \
302 return customType; \
303} \
304::physx::PxCustomGeometry::Type CLASS::getCustomType() const \
305{ \
306 return TYPE(); \
307}
308
310#endif
Class representing 3D range or axis aligned bounding box.
Definition PxBounds3.h:58
Definition PxContactBuffer.h:42
Custom geometry class. This class allows user to create custom geometries by providing a set of virtu...
Definition PxCustomGeometry.h:52
PX_INLINE PxCustomGeometry(Callbacks &_callbacks)
Constructor.
Definition PxCustomGeometry.h:234
Callbacks * callbacks
A reference to the callbacks object.
Definition PxCustomGeometry.h:276
static PX_PHYSX_COMMON_API PxU32 getUniqueID()
For internal use.
Definition GuGeometryQuery.cpp:486
PX_INLINE bool isValid() const
Returns true if the geometry is valid.
Definition PxCustomGeometry.h:279
PX_INLINE PxCustomGeometry()
Default constructor.
Definition PxCustomGeometry.h:226
PX_INLINE void operator=(const PxCustomGeometry &that)
Assignment operator.
Definition PxCustomGeometry.h:252
PX_INLINE Type getCustomType() const
Returns the custom type of the custom geometry.
Definition PxCustomGeometry.h:270
PX_INLINE PxCustomGeometry(const PxCustomGeometry &that)
Copy constructor.
Definition PxCustomGeometry.h:244
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 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
Custom geometry callbacks structure. User should inherit this and implement all pure virtual function...
Definition PxCustomGeometry.h:102
virtual Type getCustomType() const =0
Return custom type. The type purpose is for user to differentiate custom geometries....
virtual bool usePersistentContactManifold(const PxGeometry &geometry, PxReal &breakingThreshold) const =0
Compatible with PhysX's PCM feature. Allows to optimize contact generation.
virtual void visualize(const PxGeometry &geometry, PxRenderOutput &out, const PxTransform &absPose, const PxBounds3 &cullbox) const =0
Visualize custom geometry for debugging. Optional.
virtual bool generateContacts(const PxGeometry &geom0, const PxGeometry &geom1, const PxTransform &pose0, const PxTransform &pose1, const PxReal contactDistance, const PxReal meshContactMargin, const PxReal toleranceLength, PxContactBuffer &contactBuffer) const =0
Contacts generation. Generate collision contacts between two geometries in given poses.
virtual void computeMassProperties(const PxGeometry &geometry, PxMassProperties &massProperties) const =0
Compute custom geometry mass properties. For geometries usable with dynamic rigidbodies.
virtual bool sweep(const PxVec3 &unitDir, const PxReal maxDist, const PxGeometry &geom0, const PxTransform &pose0, const PxGeometry &geom1, const PxTransform &pose1, PxGeomSweepHit &sweepHit, PxHitFlags hitFlags, const PxReal inflation, PxSweepThreadContext *threadContext) const =0
Sweep. Sweep one geometry against the other.
virtual PxU32 raycast(const PxVec3 &origin, const PxVec3 &unitDir, const PxGeometry &geom, const PxTransform &pose, PxReal maxDist, PxHitFlags hitFlags, PxU32 maxHits, PxGeomRaycastHit *rayHits, PxU32 stride, PxRaycastThreadContext *threadContext) const =0
Raycast. Cast a ray against the geometry in given pose.
virtual PxBounds3 getLocalBounds(const PxGeometry &geometry) const =0
Return local bounds.
virtual bool overlap(const PxGeometry &geom0, const PxTransform &pose0, const PxGeometry &geom1, const PxTransform &pose1, PxOverlapThreadContext *threadContext) const =0
Overlap. Test if geometries overlap.
The type of a custom geometry. Allows to identify a particular kind of it.
Definition PxCustomGeometry.h:63
PX_INLINE Type & operator=(const Type &t)
Assigment operator.
Definition PxCustomGeometry.h:77
PX_INLINE bool operator!=(const Type &t) const
Inequality operator.
Definition PxCustomGeometry.h:87
static PX_INLINE Type INVALID()
Invalid type.
Definition PxCustomGeometry.h:92
PX_INLINE Type()
Default constructor.
Definition PxCustomGeometry.h:67
PX_INLINE Type(const Type &t)
Default constructor.
Definition PxCustomGeometry.h:72
PX_INLINE bool operator==(const Type &t) const
Equality operator.
Definition PxCustomGeometry.h:82
Stores results of raycast queries.
Definition PxGeometryHit.h:151
Stores results of sweep queries.
Definition PxGeometryHit.h:175
A geometry type.
Definition PxGeometry.h:50
A per-thread context passed to low-level query functions.
Definition PxGeometryQueryContext.h:52