PxPhysics.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-2021 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_PHYSICS
31 #define PX_PHYSICS_NX_PHYSICS
32 
37 #include "PxPhysXConfig.h"
38 #include "PxDeletionListener.h"
39 #include "foundation/PxTransform.h"
40 #include "PxShape.h"
41 
42 #if !PX_DOXYGEN
43 namespace physx
44 {
45 #endif
46 
47 class PxPvd;
49 
50 class PxRigidActor;
53 
54 class PxGeometry;
55 class PxFoundation;
57 
58 class PxPruningStructure;
59 class PxBVHStructure;
60 
71 class PxPhysics
72 {
73 public:
74 
78 
79  virtual ~PxPhysics() {}
80 
99  virtual void release() = 0;
100 
105  virtual PxFoundation& getFoundation() = 0;
106 
116  virtual PxAggregate* createAggregate(PxU32 maxSize, bool enableSelfCollision) = 0;
117 
122  virtual const PxTolerancesScale& getTolerancesScale() const = 0;
123 
125 
128 
139  virtual PxTriangleMesh* createTriangleMesh(PxInputStream& stream) = 0;
140 
148  virtual PxU32 getNbTriangleMeshes() const = 0;
149 
164  virtual PxU32 getTriangleMeshes(PxTriangleMesh** userBuffer, PxU32 bufferSize, PxU32 startIndex=0) const = 0;
165 
176  virtual PxHeightField* createHeightField(PxInputStream& stream) = 0;
177 
185  virtual PxU32 getNbHeightFields() const = 0;
186 
201  virtual PxU32 getHeightFields(PxHeightField** userBuffer, PxU32 bufferSize, PxU32 startIndex=0) const = 0;
202 
213  virtual PxConvexMesh* createConvexMesh(PxInputStream &stream) = 0;
214 
222  virtual PxU32 getNbConvexMeshes() const = 0;
223 
238  virtual PxU32 getConvexMeshes(PxConvexMesh** userBuffer, PxU32 bufferSize, PxU32 startIndex=0) const = 0;
239 
248  virtual PxBVHStructure* createBVHStructure(PxInputStream &stream) = 0;
249 
257  virtual PxU32 getNbBVHStructures() const = 0;
258 
273  virtual PxU32 getBVHStructures(PxBVHStructure** userBuffer, PxU32 bufferSize, PxU32 startIndex=0) const = 0;
274 
276 
279 
291  virtual PxScene* createScene(const PxSceneDesc& sceneDesc) = 0;
292 
300  virtual PxU32 getNbScenes() const = 0;
301 
316  virtual PxU32 getScenes(PxScene** userBuffer, PxU32 bufferSize, PxU32 startIndex=0) const = 0;
317 
319 
322 
331  virtual PxRigidStatic* createRigidStatic(const PxTransform& pose) = 0;
332 
341  virtual PxRigidDynamic* createRigidDynamic(const PxTransform& pose) = 0;
342 
356  virtual PxPruningStructure* createPruningStructure(PxRigidActor*const* actors, PxU32 nbActors) = 0;
357 
359 
362 
378  const PxMaterial& material,
379  bool isExclusive = false,
381  {
382  PxMaterial* materialPtr = const_cast<PxMaterial*>(&material);
383  return createShape(geometry, &materialPtr, 1, isExclusive, shapeFlags);
384  }
385 
401  virtual PxShape* createShape(const PxGeometry& geometry,
402  PxMaterial*const * materials,
403  PxU16 materialCount,
404  bool isExclusive = false,
406 
414  virtual PxU32 getNbShapes() const = 0;
415 
430  virtual PxU32 getShapes(PxShape** userBuffer, PxU32 bufferSize, PxU32 startIndex=0) const = 0;
431 
433 
436 
453  virtual PxConstraint* createConstraint(PxRigidActor* actor0, PxRigidActor* actor1, PxConstraintConnector& connector, const PxConstraintShaderTable& shaders, PxU32 dataSize) = 0;
454 
462  virtual PxArticulation* createArticulation() = 0;
463 
471  virtual PxArticulationReducedCoordinate* createArticulationReducedCoordinate() = 0;
472 
473 
475 
478 
491 
492 
500  virtual PxU32 getNbMaterials() const = 0;
501 
516  virtual PxU32 getMaterials(PxMaterial** userBuffer, PxU32 bufferSize, PxU32 startIndex=0) const = 0;
517 
519 
522 
538  virtual void registerDeletionListener(PxDeletionListener& observer, const PxDeletionEventFlags& deletionEvents, bool restrictedObjectSet = false) = 0;
539 
549  virtual void unregisterDeletionListener(PxDeletionListener& observer) = 0;
550 
566  virtual void registerDeletionListenerObjects(PxDeletionListener& observer, const PxBase* const* observables, PxU32 observableCount) = 0;
567 
583  virtual void unregisterDeletionListenerObjects(PxDeletionListener& observer, const PxBase* const* observables, PxU32 observableCount) = 0;
584 
593  virtual PxPhysicsInsertionCallback& getPhysicsInsertionCallback() = 0;
594 
596 };
597 
598 #if !PX_DOXYGEN
599 } // namespace physx
600 #endif
601 
609 PX_C_EXPORT PX_PHYSX_CORE_API void PX_CALL_CONV PxRegisterArticulations(physx::PxPhysics& physics);
610 
611 
620 
638 PX_C_EXPORT PX_PHYSX_CORE_API void PX_CALL_CONV PxRegisterHeightFields(physx::PxPhysics& physics);
639 
662  physx::PxFoundation& foundation,
663  const physx::PxTolerancesScale& scale,
664  bool trackOutstandingAllocations = false,
665  physx::PxPvd* pvd = NULL);
666 
692 PX_INLINE physx::PxPhysics* PxCreatePhysics(physx::PxU32 version,
693  physx::PxFoundation& foundation,
694  const physx::PxTolerancesScale& scale,
695  bool trackOutstandingAllocations = false,
696  physx::PxPvd* pvd = NULL )
697 {
698  physx::PxPhysics* physics = PxCreateBasePhysics(version, foundation, scale, trackOutstandingAllocations, pvd);
699  if(!physics)
700  return NULL;
701 
702  PxRegisterArticulations(*physics);
704  PxRegisterHeightFields(*physics);
705 
706  return physics;
707 }
708 
709 
717 #ifdef __clang__
718 #pragma clang diagnostic push
719 #pragma clang diagnostic ignored "-Wreturn-type-c-linkage"
720 #endif
721 
723 
724 #ifdef __clang__
725 #pragma clang diagnostic pop
726 #endif
727 
729 #endif
Definition: GuContactBuffer.h:37
Descriptor class for scenes. See PxScene.
Definition: PxSceneDesc.h:471
A scene is a collection of bodies and constraints which can interact.
Definition: PxScene.h:169
Class serving as a registry for XML (RepX) and binary serializable types.
Definition: PxSerialFramework.h:290
PxRigidDynamic represents a dynamic rigid simulation object in the physics SDK.
Definition: PxRigidDynamic.h:83
PxReal restitution
restitution parameter for determining additional "bounce"
Definition: PxConstraintDesc.h:104
Abstract class for collision shapes.
Definition: PxShape.h:142
#define PX_FORCE_INLINE
Definition: PxPreprocessor.h:351
float PxReal
Definition: PxSimpleTypes.h:78
#define PX_C_EXPORT
Definition: Pxc.h:54
#define PX_CALL_CONV
Definition: PxPreprocessor.h:315
uint32_t PxU32
Definition: PxSimpleTypes.h:71
A triangle mesh, also called a &#39;polygon soup&#39;.
Definition: PxTriangleMesh.h:126
#define PX_PHYSX_CORE_API
Definition: PxPhysXCommonConfig.h:59
Input stream class for I/O.
Definition: PxIO.h:50
A geometry object.
Definition: PxGeometry.h:75
A convex mesh.
Definition: PxConvexMesh.h:84
A precomputed pruning structure to accelerate scene queries against newly added actors.
Definition: PxPruningStructure.h:62
The shape will partake in collision in the physical simulation.
Definition: PxShape.h:79
PxRigidActor represents a base class shared between dynamic and static rigid bodies in the physics SD...
Definition: PxRigidActor.h:58
The shape will partake in scene queries (ray casts, overlap tests, sweeps, ...).
Definition: PxShape.h:84
Foundation SDK singleton class.
Definition: PxFoundation.h:51
PX_C_EXPORT PX_PHYSX_CORE_API void PX_CALL_CONV PxRegisterArticulations(physx::PxPhysics &physics)
Enables the usage of the articulations feature. This function is called automatically inside PxCreate...
A height field class.
Definition: PxHeightField.h:85
PxU8 geometry[sizeof(PxGeometry)]
Definition: PxGeometryHelpers.h:215
a tree structure of bodies connected by joints that is treated as a unit by the dynamics solver ...
Definition: PxArticulationReducedCoordinate.h:147
PxReal staticFriction
static friction coefficient
Definition: PxContact.h:460
PxPvd is the top-level class for the PVD framework, and the main customer interface for PVD configura...
Definition: PxPvd.h:114
class representing a rigid euclidean transform as a quaternion and a vector
Definition: PxTransform.h:48
PX_C_EXPORT PX_PHYSX_CORE_API void PX_CALL_CONV PxRegisterArticulationsReducedCoordinate(physx::PxPhysics &physics)
Enables the usage of the reduced coordinate articulations feature. This function is called automatica...
A plugin class for implementing constraints.
Definition: PxConstraint.h:108
Enable debug renderer for this shape.
Definition: PxShape.h:113
interface to get notification on object deletion
Definition: PxDeletionListener.h:73
Class to define the scale at which simulation runs. Most simulation tolerances are calculated in term...
Definition: PxTolerancesScale.h:56
PX_FORCE_INLINE PxShape * createShape(const PxGeometry &geometry, const PxMaterial &material, bool isExclusive=false, PxShapeFlags shapeFlags=PxShapeFlag::eVISUALIZATION|PxShapeFlag::eSCENE_QUERY_SHAPE|PxShapeFlag::eSIMULATION_SHAPE)
Creates a shape which may be attached to multiple actors.
Definition: PxPhysics.h:377
PX_INLINE physx::PxPhysics * PxCreatePhysics(physx::PxU32 version, physx::PxFoundation &foundation, const physx::PxTolerancesScale &scale, bool trackOutstandingAllocations=false, physx::PxPvd *pvd=NULL)
Creates an instance of the physics SDK.
Definition: PxPhysics.h:692
Material class to represent a set of surface properties.
Definition: PxMaterial.h:143
PX_C_EXPORT PX_PHYSX_CORE_API physx::PxPhysics &PX_CALL_CONV PxGetPhysics()
Retrieves the Physics SDK after it has been created.
PX_C_EXPORT PX_PHYSX_CORE_API physx::PxPhysics *PX_CALL_CONV PxCreateBasePhysics(physx::PxU32 version, physx::PxFoundation &foundation, const physx::PxTolerancesScale &scale, bool trackOutstandingAllocations=false, physx::PxPvd *pvd=NULL)
Creates an instance of the physics SDK with minimal additional components registered.
Definition: PxConstraint.h:88
Container for bitfield flag variables associated with a specific enum type.
Definition: PxFlags.h:73
Abstract singleton factory class used for instancing objects in the Physics SDK.
Definition: PxPhysics.h:71
Callback interface that permits PxCooking to insert a TriangleMesh, HeightfieldMesh or ConvexMesh dir...
Definition: PxPhysicsInsertionCallback.h:60
a tree structure of bodies connected by joints that is treated as a unit by the dynamics solver ...
Definition: PxArticulation.h:76
virtual ~PxPhysics()
Definition: PxPhysics.h:79
Class to aggregate actors into a single broad-phase entry.
Definition: PxAggregate.h:70
uint16_t PxU16
Definition: PxSimpleTypes.h:73
uint32_t PxU32
Definition: Px.h:48
PxRigidStatic represents a static rigid body simulation object in the physics SDK.
Definition: PxRigidStatic.h:59
Class representing the bounding volume hierarchy structure.
Definition: PxBVHStructure.h:57
Base class for objects that can be members of a PxCollection.
Definition: PxBase.h:73
#define PX_INLINE
Definition: PxPreprocessor.h:336
PxReal dynamicFriction
dynamic friction coefficient
Definition: PxContact.h:459
PX_C_EXPORT PX_PHYSX_CORE_API void PX_CALL_CONV PxRegisterHeightFields(physx::PxPhysics &physics)
Enables the usage of the heightfield feature.
This class connects a custom constraint to the SDK.
Definition: PxConstraintDesc.h:352