RavEngine
Loading...
Searching...
No Matches
PxShape.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_SHAPE_H
30#define PX_SHAPE_H
35#include "PxPhysXConfig.h"
36#include "common/PxBase.h"
37#include "geometry/PxGeometry.h"
38#include "geometry/PxGeometryHelpers.h"
39
40#if !PX_DOXYGEN
41namespace physx
42{
43#endif
44
45class PxBoxGeometry;
46class PxSphereGeometry;
47class PxCapsuleGeometry;
48class PxPlaneGeometry;
49class PxConvexMeshGeometry;
50class PxTriangleMeshGeometry;
51class PxTetrahedronMeshGeometry;
52class PxHeightFieldGeometry;
53class PxParticleSystemGeometry;
54class PxHairSystemGeometry;
55class PxRigidActor;
56struct PxFilterData;
57class PxBaseMaterial;
58class PxMaterial;
59class PxFEMSoftBodyMaterial;
60class PxFEMClothMaterial;
61
68{
69 enum Enum
70 {
84
89
111
117 eVISUALIZATION = (1<<3)
118 };
119};
120
127PX_FLAGS_OPERATORS(PxShapeFlag::Enum,PxU8)
128
129
145class PxShape : public PxRefCounted
146{
147public:
158 virtual void release() = 0;
159
171 virtual void setGeometry(const PxGeometry& geometry) = 0;
172
182 virtual const PxGeometry& getGeometry() const = 0;
183
193 {
194 return getGeometry().getType();
195 }
196
210 {
211 return getGeometryT(PxGeometryType::eBOX, geometry);
212 }
213
227 {
228 return getGeometryT(PxGeometryType::eSPHERE, geometry);
229 }
230
244 {
245 return getGeometryT(PxGeometryType::eCAPSULE, geometry);
246 }
247
261 {
262 return getGeometryT(PxGeometryType::ePLANE, geometry);
263 }
264
278 {
279 return getGeometryT(PxGeometryType::eCONVEXMESH, geometry);
280 }
281
295 {
296 return getGeometryT(PxGeometryType::eTRIANGLEMESH, geometry);
297 }
298
312 {
313 return getGeometryT(PxGeometryType::eTETRAHEDRONMESH, geometry);
314 }
315
329 {
330 return getGeometryT(PxGeometryType::ePARTICLESYSTEM, geometry);
331 }
332
346 {
347 return getGeometryT(PxGeometryType::eHEIGHTFIELD, geometry);
348 }
349
363 {
364 return getGeometryT(PxGeometryType::eCUSTOM, geometry);
365 }
366
374 virtual PxRigidActor* getActor() const = 0;
375
376/************************************************************************************************/
377
381
400 virtual void setLocalPose(const PxTransform& pose) = 0;
401
411 virtual PxTransform getLocalPose() const = 0;
412
414/************************************************************************************************/
415
419
430 virtual void setSimulationFilterData(const PxFilterData& data) = 0;
431
438
446 virtual void setQueryFilterData(const PxFilterData& data) = 0;
447
453 virtual PxFilterData getQueryFilterData() const = 0;
454
456/************************************************************************************************/
457
468 virtual void setMaterials(PxMaterial*const* materials, PxU16 materialCount) = 0;
469
480 virtual void setSoftBodyMaterials(PxFEMSoftBodyMaterial*const* materials, PxU16 materialCount) = 0;
481
493 virtual void setClothMaterials(PxFEMClothMaterial*const* materials, PxU16 materialCount) = 0;
494
504 virtual PxU16 getNbMaterials() const = 0;
505
520 virtual PxU32 getMaterials(PxMaterial** userBuffer, PxU32 bufferSize, PxU32 startIndex=0) const = 0;
521
536 virtual PxU32 getSoftBodyMaterials(PxFEMSoftBodyMaterial** userBuffer, PxU32 bufferSize, PxU32 startIndex = 0) const = 0;
537
553 virtual PxU32 getClothMaterials(PxFEMClothMaterial** userBuffer, PxU32 bufferSize, PxU32 startIndex = 0) const = 0;
554
573 virtual PxBaseMaterial* getMaterialFromInternalFaceIndex(PxU32 faceIndex) const = 0;
574
591 virtual void setContactOffset(PxReal contactOffset) = 0;
592
600 virtual PxReal getContactOffset() const = 0;
601
617 virtual void setRestOffset(PxReal restOffset) = 0;
618
626 virtual PxReal getRestOffset() const = 0;
627
641 virtual void setDensityForFluid(PxReal densityForFluid) = 0;
642
650 virtual PxReal getDensityForFluid() const = 0;
651
664 virtual void setTorsionalPatchRadius(PxReal radius) = 0;
665
676 virtual PxReal getTorsionalPatchRadius() const = 0;
677
690 virtual void setMinTorsionalPatchRadius(PxReal radius) = 0;
691
702 virtual PxReal getMinTorsionalPatchRadius() const = 0;
703
704/************************************************************************************************/
705
718 virtual void setFlag(PxShapeFlag::Enum flag, bool value) = 0;
719
725 virtual void setFlags(PxShapeFlags inFlags) = 0;
726
734 virtual PxShapeFlags getFlags() const = 0;
735
741 virtual bool isExclusive() const = 0;
742
755 virtual void setName(const char* name) = 0;
756
763 virtual const char* getName() const = 0;
764
765
766 virtual const char* getConcreteTypeName() const { return "PxShape"; }
767
768/************************************************************************************************/
769
770 void* userData;
771
772protected:
773 PX_INLINE PxShape(PxBaseFlags baseFlags) : PxRefCounted(baseFlags) {}
774 PX_INLINE PxShape(PxType concreteType, PxBaseFlags baseFlags) : PxRefCounted(concreteType, baseFlags), userData(NULL) {}
775 virtual ~PxShape() {}
776 virtual bool isKindOf(const char* name) const { return !::strcmp("PxShape", name) || PxRefCounted::isKindOf(name); }
777
778 template<class T>
779 PX_FORCE_INLINE bool getGeometryT(PxGeometryType::Enum type, T& geom) const
780 {
781 if(getGeometryType() != type)
782 return false;
783
784 geom = static_cast<const T&>(getGeometry());
785 return true;
786 }
787};
788
789#if !PX_DOXYGEN
790} // namespace physx
791#endif
792
794#endif
Base material class.
Definition PxBaseMaterial.h:49
Class representing the geometry of a box.
Definition PxBoxGeometry.h:49
Class representing the geometry of a capsule.
Definition PxCapsuleGeometry.h:54
Convex mesh geometry class.
Definition PxConvexMeshGeometry.h:79
Custom geometry class. This class allows user to create custom geometries by providing a set of virtu...
Definition PxCustomGeometry.h:52
Material class to represent a set of FEM material properties.
Definition PxFEMClothMaterial.h:48
Material class to represent a set of softbody FEM material properties.
Definition PxFEMSoftBodyMaterial.h:49
Container for bitfield flag variables associated with a specific enum type.
Definition PxFlags.h:73
A geometry object.
Definition PxGeometry.h:79
Height field geometry class.
Definition PxHeightFieldGeometry.h:55
Material class to represent a set of surface properties.
Definition PxMaterial.h:149
Particle system geometry class.
Definition PxParticleSystemGeometry.h:51
Class describing a plane geometry.
Definition PxPlaneGeometry.h:56
Base class for ref-counted objects.
Definition PxBase.h:200
virtual bool isKindOf(const char *name) const
Returns whether a given type name matches with the type of this instance.
Definition PxBase.h:231
PxRigidActor represents a base class shared between dynamic and static rigid bodies in the physics SD...
Definition PxRigidActor.h:53
Abstract class for collision shapes.
Definition PxShape.h:146
virtual PxFilterData getSimulationFilterData() const =0
Retrieves the shape's collision filter data.
virtual PxReal getRestOffset() const =0
Retrieves the rest offset.
PX_DEPRECATED PX_FORCE_INLINE bool getCapsuleGeometry(PxCapsuleGeometry &geometry) const
Fetch the geometry of the shape.
Definition PxShape.h:243
virtual void setGeometry(const PxGeometry &geometry)=0
Adjust the geometry of the shape.
virtual const PxGeometry & getGeometry() const =0
Retrieve a reference to the shape's geometry.
virtual void setDensityForFluid(PxReal densityForFluid)=0
Sets the density used to interact with fluids.
virtual PxReal getMinTorsionalPatchRadius() const =0
Gets minimum torsional patch radius.
PX_DEPRECATED PX_FORCE_INLINE PxGeometryType::Enum getGeometryType() const
Get the geometry type of the shape.
Definition PxShape.h:192
virtual bool isExclusive() const =0
Returns true if the shape is exclusive to an actor.
virtual const char * getName() const =0
retrieves the name string set with setName().
virtual PxU32 getMaterials(PxMaterial **userBuffer, PxU32 bufferSize, PxU32 startIndex=0) const =0
Retrieve all the material pointers associated with the shape.
PX_DEPRECATED PX_FORCE_INLINE bool getHeightFieldGeometry(PxHeightFieldGeometry &geometry) const
Fetch the geometry of the shape.
Definition PxShape.h:345
virtual void setFlag(PxShapeFlag::Enum flag, bool value)=0
Sets shape flags.
virtual void setClothMaterials(PxFEMClothMaterial *const *materials, PxU16 materialCount)=0
Assigns FEM cloth material(s) to the shape. Will remove existing materials from the shape.
virtual PxBaseMaterial * getMaterialFromInternalFaceIndex(PxU32 faceIndex) const =0
Retrieve material from given triangle index.
virtual bool isKindOf(const char *name) const
Returns whether a given type name matches with the type of this instance.
Definition PxShape.h:776
virtual PxU32 getClothMaterials(PxFEMClothMaterial **userBuffer, PxU32 bufferSize, PxU32 startIndex=0) const =0
Retrieve all the FEM cloth material pointers associated with the shape.
virtual PxFilterData getQueryFilterData() const =0
Retrieves the shape's Query filter data.
virtual void setMaterials(PxMaterial *const *materials, PxU16 materialCount)=0
Assigns material(s) to the shape. Will remove existing materials from the shape.
PX_DEPRECATED PX_FORCE_INLINE bool getCustomGeometry(PxCustomGeometry &geometry) const
Fetch the geometry of the shape.
Definition PxShape.h:362
virtual void setFlags(PxShapeFlags inFlags)=0
Sets shape flags.
virtual void setSoftBodyMaterials(PxFEMSoftBodyMaterial *const *materials, PxU16 materialCount)=0
Assigns FEM soft body material(s) to the shape. Will remove existing materials from the shape.
virtual void setName(const char *name)=0
Sets a name string for the object that can be retrieved with getName().
PX_DEPRECATED PX_FORCE_INLINE bool getTetrahedronMeshGeometry(PxTetrahedronMeshGeometry &geometry) const
Fetch the geometry of the shape.
Definition PxShape.h:311
virtual void setSimulationFilterData(const PxFilterData &data)=0
Sets the user definable collision filter data.
PX_DEPRECATED PX_FORCE_INLINE bool getSphereGeometry(PxSphereGeometry &geometry) const
Fetch the geometry of the shape.
Definition PxShape.h:226
virtual void setMinTorsionalPatchRadius(PxReal radius)=0
Sets minimum torsional patch radius.
virtual void setContactOffset(PxReal contactOffset)=0
Sets the contact offset.
virtual PxReal getDensityForFluid() const =0
Retrieves the density used to interact with fluids.
PX_DEPRECATED PX_FORCE_INLINE bool getParticleSystemGeometry(PxParticleSystemGeometry &geometry) const
Fetch the geometry of the shape.
Definition PxShape.h:328
void * userData
user can assign this to whatever, usually to create a 1:1 relationship with a user object.
Definition PxShape.h:770
virtual PxShapeFlags getFlags() const =0
Retrieves shape flags.
virtual PxReal getTorsionalPatchRadius() const =0
Gets torsional patch radius.
virtual PxTransform getLocalPose() const =0
Retrieves the pose of the shape in actor space, i.e. relative to the actor they are owned by.
PX_DEPRECATED PX_FORCE_INLINE bool getPlaneGeometry(PxPlaneGeometry &geometry) const
Fetch the geometry of the shape.
Definition PxShape.h:260
virtual void setLocalPose(const PxTransform &pose)=0
Sets the pose of the shape in actor space, i.e. relative to the actors to which they are attached.
PX_DEPRECATED PX_FORCE_INLINE bool getConvexMeshGeometry(PxConvexMeshGeometry &geometry) const
Fetch the geometry of the shape.
Definition PxShape.h:277
PX_DEPRECATED PX_FORCE_INLINE bool getBoxGeometry(PxBoxGeometry &geometry) const
Fetch the geometry of the shape.
Definition PxShape.h:209
virtual void setQueryFilterData(const PxFilterData &data)=0
Sets the user definable query filter data.
virtual PxReal getContactOffset() const =0
Retrieves the contact offset.
virtual PxU16 getNbMaterials() const =0
Returns the number of materials assigned to the shape.
virtual PxU32 getSoftBodyMaterials(PxFEMSoftBodyMaterial **userBuffer, PxU32 bufferSize, PxU32 startIndex=0) const =0
Retrieve all the FEM soft body material pointers associated with the shape.
virtual void setTorsionalPatchRadius(PxReal radius)=0
Sets torsional patch radius.
virtual PxRigidActor * getActor() const =0
Retrieves the actor which this shape is associated with.
virtual const char * getConcreteTypeName() const
Returns string name of dynamic type.
Definition PxShape.h:766
virtual void setRestOffset(PxReal restOffset)=0
Sets the rest offset.
virtual void release()=0
Decrements the reference count of a shape and releases it if the new reference count is zero.
PX_DEPRECATED PX_FORCE_INLINE bool getTriangleMeshGeometry(PxTriangleMeshGeometry &geometry) const
Fetch the geometry of the shape.
Definition PxShape.h:294
A class representing the geometry of a sphere.
Definition PxSphereGeometry.h:48
Tetrahedron mesh geometry class.
Definition PxTetrahedronMeshGeometry.h:50
class representing a rigid euclidean transform as a quaternion and a vector
Definition PxTransform.h:49
Triangle mesh geometry class.
Definition PxTriangleMeshGeometry.h:81
#define PX_FORCE_INLINE
Definition PxPreprocessor.h:335
#define PX_INLINE
Definition PxPreprocessor.h:320
#define PX_DEPRECATED
Definition PxPreprocessor.h:418
Sorts an array of objects in ascending order, assuming that the predicate implements the < operator:
Definition PxBoxController.h:39
PxFlags< PxShapeFlag::Enum, PxU8 > PxShapeFlags
collection of set bits defined in PxShapeFlag.
Definition PxShape.h:126
PxFilterData is user-definable data which gets passed into the collision filtering shader and/or call...
Definition PxFiltering.h:365
Enum
Definition PxGeometry.h:52
Flags which affect the behavior of PxShapes.
Definition PxShape.h:68
Enum
Definition PxShape.h:70
@ eSIMULATION_SHAPE
The shape will partake in collision in the physical simulation.
Definition PxShape.h:83
@ eVISUALIZATION
Enable debug renderer for this shape.
Definition PxShape.h:117
@ eSCENE_QUERY_SHAPE
The shape will partake in scene queries (ray casts, overlap tests, sweeps, ...).
Definition PxShape.h:88
@ eTRIGGER_SHAPE
The shape is a trigger which can send reports whenever other shapes enter/leave its volume.
Definition PxShape.h:110