PxShape.h
Go to the documentation of this file.
1 //
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions
4 // are met:
5 // * Redistributions of source code must retain the above copyright
6 // notice, this list of conditions and the following disclaimer.
7 // * Redistributions in binary form must reproduce the above copyright
8 // notice, this list of conditions and the following disclaimer in the
9 // documentation and/or other materials provided with the distribution.
10 // * Neither the name of NVIDIA CORPORATION nor the names of its
11 // contributors may be used to endorse or promote products derived
12 // from this software without specific prior written permission.
13 //
14 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
15 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
18 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
21 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
22 // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 //
26 // Copyright (c) 2008-2018 NVIDIA Corporation. All rights reserved.
27 // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
28 // Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
29 
30 #ifndef PX_PHYSICS_NX_SHAPE
31 #define PX_PHYSICS_NX_SHAPE
32 
36 #include "PxPhysXConfig.h"
37 #include "common/PxBase.h"
38 #include "geometry/PxGeometry.h"
40 
41 #if !PX_DOXYGEN
42 namespace physx
43 {
44 #endif
45 
46 class PxBoxGeometry;
47 class PxSphereGeometry;
48 class PxCapsuleGeometry;
49 class PxPlaneGeometry;
53 class PxRigidActor;
54 struct PxFilterData;
55 struct PxRaycastHit;
56 struct PxSweepHit;
57 
64 {
65  enum Enum
66  {
79  eSIMULATION_SHAPE = (1<<0),
80 
84  eSCENE_QUERY_SHAPE = (1<<1),
85 
106  eTRIGGER_SHAPE = (1<<2),
107 
113  eVISUALIZATION = (1<<3)
114  };
115 };
116 
123 PX_FLAGS_OPERATORS(PxShapeFlag::Enum,PxU8)
124 
125 
126 
142 class PxShape : public PxBase
143 {
144 public:
145 
156  virtual void release() = 0;
157 
166  virtual PxU32 getReferenceCount() const = 0;
167 
173  virtual void acquireReference() = 0;
174 
182  virtual PxGeometryType::Enum getGeometryType() const = 0;
183 
195  virtual void setGeometry(const PxGeometry& geometry) = 0;
196 
197 
206  virtual PxGeometryHolder getGeometry() const = 0;
207 
208 
220  virtual bool getBoxGeometry(PxBoxGeometry& geometry) const = 0;
221 
233  virtual bool getSphereGeometry(PxSphereGeometry& geometry) const = 0;
234 
246  virtual bool getCapsuleGeometry(PxCapsuleGeometry& geometry) const = 0;
247 
259  virtual bool getPlaneGeometry(PxPlaneGeometry& geometry) const = 0;
260 
272  virtual bool getConvexMeshGeometry(PxConvexMeshGeometry& geometry) const = 0;
273 
285  virtual bool getTriangleMeshGeometry(PxTriangleMeshGeometry& geometry) const = 0;
286 
287 
299  virtual bool getHeightFieldGeometry(PxHeightFieldGeometry& geometry) const = 0;
300 
308  virtual PxRigidActor* getActor() const = 0;
309 
310 
311 /************************************************************************************************/
312 
316 
335  virtual void setLocalPose(const PxTransform& pose) = 0;
336 
346  virtual PxTransform getLocalPose() const = 0;
347 
349 /************************************************************************************************/
350 
354 
365  virtual void setSimulationFilterData(const PxFilterData& data) = 0;
366 
372  virtual PxFilterData getSimulationFilterData() const = 0;
373 
381  virtual void setQueryFilterData(const PxFilterData& data) = 0;
382 
388  virtual PxFilterData getQueryFilterData() const = 0;
389 
391 /************************************************************************************************/
392 
403  virtual void setMaterials(PxMaterial*const* materials, PxU16 materialCount) = 0;
404 
414  virtual PxU16 getNbMaterials() const = 0;
415 
430  virtual PxU32 getMaterials(PxMaterial** userBuffer, PxU32 bufferSize, PxU32 startIndex=0) const = 0;
431 
450  virtual PxMaterial* getMaterialFromInternalFaceIndex(PxU32 faceIndex) const = 0;
451 
468  virtual void setContactOffset(PxReal contactOffset) = 0;
469 
477  virtual PxReal getContactOffset() const = 0;
478 
494  virtual void setRestOffset(PxReal restOffset) = 0;
495 
503  virtual PxReal getRestOffset() const = 0;
504 
505 
517  virtual void setTorsionalPatchRadius(PxReal radius) = 0;
518 
529  virtual PxReal getTorsionalPatchRadius() const = 0;
530 
542  virtual void setMinTorsionalPatchRadius(PxReal radius) = 0;
543 
554  virtual PxReal getMinTorsionalPatchRadius() const = 0;
555 
556 
557 /************************************************************************************************/
558 
571  virtual void setFlag(PxShapeFlag::Enum flag, bool value) = 0;
572 
578  virtual void setFlags(PxShapeFlags inFlags) = 0;
579 
587  virtual PxShapeFlags getFlags() const = 0;
588 
594  virtual bool isExclusive() const = 0;
595 
608  virtual void setName(const char* name) = 0;
609 
610 
617  virtual const char* getName() const = 0;
618 
619 
620  virtual const char* getConcreteTypeName() const { return "PxShape"; }
621 
622 /************************************************************************************************/
623 
624  void* userData;
625 
626 protected:
627  PX_INLINE PxShape(PxBaseFlags baseFlags) : PxBase(baseFlags) {}
628  PX_INLINE PxShape(PxType concreteType, PxBaseFlags baseFlags) : PxBase(concreteType, baseFlags), userData(NULL) {}
629  virtual ~PxShape() {}
630  virtual bool isKindOf(const char* name) const { return !::strcmp("PxShape", name) || PxBase::isKindOf(name); }
631 
632 };
633 
634 #if !PX_DOXYGEN
635 } // namespace physx
636 #endif
637 
639 #endif
Definition: GuContactBuffer.h:37
virtual bool isKindOf(const char *name) const
Returns whether a given type name matches with the type of this instance.
Definition: PxShape.h:630
PxFilterData is user-definable data which gets passed into the collision filtering shader and/or call...
Definition: PxFiltering.h:366
Class representing the geometry of a capsule.
Definition: PxCapsuleGeometry.h:54
Abstract class for collision shapes.
Definition: PxShape.h:142
float PxReal
Definition: PxSimpleTypes.h:78
A class representing the geometry of a sphere.
Definition: PxSphereGeometry.h:49
virtual bool isKindOf(const char *superClass) const
Returns whether a given type name matches with the type of this instance.
Definition: PxBase.h:178
A geometry object.
Definition: PxGeometry.h:75
virtual const char * getConcreteTypeName() const
Returns string name of dynamic type.
Definition: PxShape.h:620
PxU16 PxType
Definition: PxBase.h:49
PxRigidActor represents a base class shared between dynamic and static rigid bodies in the physics SD...
Definition: PxRigidActor.h:58
Height field geometry class.
Definition: PxHeightFieldGeometry.h:56
virtual ~PxShape()
Definition: PxShape.h:629
PxFlags< PxShapeFlag::Enum, PxU8 > PxShapeFlags
collection of set bits defined in PxShapeFlag.
Definition: PxShape.h:122
PxU8 geometry[sizeof(PxGeometry)]
Definition: PxGeometryHelpers.h:215
Flags which affect the behavior of PxShapes.
Definition: PxShape.h:63
uint8_t PxU8
Definition: PxSimpleTypes.h:75
class representing a rigid euclidean transform as a quaternion and a vector
Definition: PxTransform.h:48
Enum
Definition: PxGeometry.h:53
Enum
Definition: PxShape.h:65
Geometry holder class.
Definition: PxGeometryHelpers.h:64
Class describing a plane geometry.
Definition: PxPlaneGeometry.h:58
PX_INLINE PxShape(PxType concreteType, PxBaseFlags baseFlags)
Definition: PxShape.h:628
Material class to represent a set of surface properties.
Definition: PxMaterial.h:130
Container for bitfield flag variables associated with a specific enum type.
Definition: PxFlags.h:73
Stores results of sweep queries.
Definition: PxQueryReport.h:199
void * userData
user can assign this to whatever, usually to create a 1:1 relationship with a user object...
Definition: PxShape.h:624
Stores results of raycast queries.
Definition: PxQueryReport.h:173
uint16_t PxU16
Definition: PxSimpleTypes.h:73
uint32_t PxU32
Definition: Px.h:48
PX_INLINE PxShape(PxBaseFlags baseFlags)
Definition: PxShape.h:627
Base class for objects that can be members of a PxCollection.
Definition: PxBase.h:73
Triangle mesh geometry class.
Definition: PxTriangleMeshGeometry.h:82
Convex mesh geometry class.
Definition: PxConvexMeshGeometry.h:80
#define PX_INLINE
Definition: PxPreprocessor.h:349
Class representing the geometry of a box.
Definition: PxBoxGeometry.h:50