PxScene.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 
31 #ifndef PX_PHYSICS_NX_SCENE
32 #define PX_PHYSICS_NX_SCENE
33 
38 #include "PxSceneDesc.h"
39 #include "PxSimulationStatistics.h"
40 #include "PxQueryReport.h"
41 #include "PxQueryFiltering.h"
42 #include "PxClient.h"
43 #include "task/PxTask.h"
44 
45 #include "pvd/PxPvdSceneClient.h"
46 
47 #if !PX_DOXYGEN
48 namespace physx
49 {
50 #endif
51 
52 class PxRigidStatic;
53 class PxRigidDynamic;
54 class PxConstraint;
55 class PxMaterial;
57 class PxPhysics;
58 class PxBatchQueryDesc;
59 class PxBatchQuery;
60 class PxAggregate;
61 class PxRenderBuffer;
62 
63 class PxSphereGeometry;
64 class PxBoxGeometry;
65 class PxCapsuleGeometry;
66 
67 class PxPruningStructure;
68 class PxBVHStructure;
70 
71 typedef PxU8 PxDominanceGroup;
72 
73 class PxPvdSceneClient;
74 
84 {
86  : dominance0(a), dominance1(b) {}
89 };
90 
91 
100 {
101  enum Enum
102  {
107  eRIGID_STATIC = (1 << 0),
108 
113  eRIGID_DYNAMIC = (1 << 1)
114  };
115 };
116 
123 PX_FLAGS_OPERATORS(PxActorTypeFlag::Enum,PxU16)
124 
125 
144 {
148  PX_INLINE PxQueryCache() : shape(NULL), actor(NULL), faceIndex(0xffffffff) {}
149 
153  PX_INLINE PxQueryCache(PxShape* s, PxU32 findex) : shape(s), actor(NULL), faceIndex(findex) {}
154 
158 };
159 
169 class PxScene
170 {
171  protected:
172 
173  /************************************************************************************************/
174 
178 
179  PxScene(): userData(0) {}
180  virtual ~PxScene() {}
181 
182  public:
183 
195  virtual void release() = 0;
196 
204  virtual void setFlag(PxSceneFlag::Enum flag, bool value) = 0;
205 
213  virtual PxSceneFlags getFlags() const = 0;
214 
215 
226  virtual void setLimits(const PxSceneLimits& limits) = 0;
227 
233  virtual PxSceneLimits getLimits() const = 0;
234 
235 
243  virtual PxPhysics& getPhysics() = 0;
244 
250  virtual PxU32 getTimestamp() const = 0;
251 
252 
254  /************************************************************************************************/
255 
268  virtual void addArticulation(PxArticulationBase& articulation) = 0;
269 
282  virtual void removeArticulation(PxArticulationBase& articulation, bool wakeOnLostTouch = true) = 0;
283 
284 
286  /************************************************************************************************/
287 
288 
311  virtual void addActor(PxActor& actor, const PxBVHStructure* bvhStructure = NULL) = 0;
312 
331  virtual void addActors(PxActor*const* actors, PxU32 nbActors) = 0;
332 
351  virtual void addActors(const PxPruningStructure& pruningStructure) = 0;
352 
369  virtual void removeActor(PxActor& actor, bool wakeOnLostTouch = true) = 0;
370 
386  virtual void removeActors(PxActor*const* actors, PxU32 nbActors, bool wakeOnLostTouch = true) = 0;
387 
400  virtual void addAggregate(PxAggregate& aggregate) = 0;
401 
414  virtual void removeAggregate(PxAggregate& aggregate, bool wakeOnLostTouch = true) = 0;
415 
428  virtual void addCollection(const PxCollection& collection) = 0;
430  /************************************************************************************************/
431 
435 
444  virtual PxU32 getNbActors(PxActorTypeFlags types) const = 0;
445 
457  virtual PxU32 getActors(PxActorTypeFlags types, PxActor** userBuffer, PxU32 bufferSize, PxU32 startIndex=0) const = 0;
458 
473  virtual PxActor** getActiveActors(PxU32& nbActorsOut) = 0;
474 
482  virtual PxU32 getNbArticulations() const = 0;
483 
494  virtual PxU32 getArticulations(PxArticulationBase** userBuffer, PxU32 bufferSize, PxU32 startIndex=0) const = 0;
495 
503  virtual PxU32 getNbConstraints() const = 0;
504 
515  virtual PxU32 getConstraints(PxConstraint** userBuffer, PxU32 bufferSize, PxU32 startIndex=0) const = 0;
516 
517 
525  virtual PxU32 getNbAggregates() const = 0;
526 
537  virtual PxU32 getAggregates(PxAggregate** userBuffer, PxU32 bufferSize, PxU32 startIndex=0) const = 0;
538 
540  /************************************************************************************************/
541 
545 
596  virtual void setDominanceGroupPair(
597  PxDominanceGroup group1, PxDominanceGroup group2, const PxDominanceGroupPair& dominance) = 0;
598 
604  virtual PxDominanceGroupPair getDominanceGroupPair(PxDominanceGroup group1, PxDominanceGroup group2) const = 0;
605 
607  /************************************************************************************************/
608 
612 
618  virtual PxCpuDispatcher* getCpuDispatcher() const = 0;
619 
627  virtual PxCudaContextManager* getCudaContextManager() const = 0;
628 
630  /************************************************************************************************/
643  virtual PxClientID createClient() = 0;
644 
646 
647  /************************************************************************************************/
648 
652 
662  virtual void setSimulationEventCallback(PxSimulationEventCallback* callback) = 0;
663 
671  virtual PxSimulationEventCallback* getSimulationEventCallback() const = 0;
672 
680  virtual void setContactModifyCallback(PxContactModifyCallback* callback) = 0;
681 
689  virtual void setCCDContactModifyCallback(PxCCDContactModifyCallback* callback) = 0;
690 
698  virtual PxContactModifyCallback* getContactModifyCallback() const = 0;
699 
707  virtual PxCCDContactModifyCallback* getCCDContactModifyCallback() const = 0;
708 
716  virtual void setBroadPhaseCallback(PxBroadPhaseCallback* callback) = 0;
717 
725  virtual PxBroadPhaseCallback* getBroadPhaseCallback() const = 0;
726 
728  /************************************************************************************************/
729 
733 
750  virtual void setFilterShaderData(const void* data, PxU32 dataSize) = 0;
751 
761  virtual const void* getFilterShaderData() const = 0;
762 
770  virtual PxU32 getFilterShaderDataSize() const = 0;
771 
779  virtual PxSimulationFilterShader getFilterShader() const = 0;
780 
788  virtual PxSimulationFilterCallback* getFilterCallback() const = 0;
789 
819  virtual void resetFiltering(PxActor& actor) = 0;
820 
835  virtual void resetFiltering(PxRigidActor& actor, PxShape*const* shapes, PxU32 shapeCount) = 0;
836 
844  virtual PxPairFilteringMode::Enum getKinematicKinematicFilteringMode() const = 0;
845 
853  virtual PxPairFilteringMode::Enum getStaticKinematicFilteringMode() const = 0;
854 
856  /************************************************************************************************/
857 
892  virtual void simulate(PxReal elapsedTime, physx::PxBaseTask* completionTask = NULL,
893  void* scratchMemBlock = 0, PxU32 scratchMemBlockSize = 0, bool controlSimulation = true) = 0;
894 
895 
906  virtual void advance(physx::PxBaseTask* completionTask = 0) = 0;
907 
925  virtual void collide(PxReal elapsedTime, physx::PxBaseTask* completionTask = 0, void* scratchMemBlock = 0,
926  PxU32 scratchMemBlockSize = 0, bool controlSimulation = true) = 0;
927 
939  virtual bool checkResults(bool block = false) = 0;
940 
948  virtual bool fetchCollision(bool block = false) = 0;
949 
971  virtual bool fetchResults(bool block = false, PxU32* errorState = 0) = 0;
972 
973 
989  virtual bool fetchResultsStart(const PxContactPairHeader*& contactPairs, PxU32& nbContactPairs, bool block = false) = 0;
990 
991 
1000  virtual void processCallbacks(physx::PxBaseTask* continuation) = 0;
1001 
1002 
1014  virtual void fetchResultsFinish(PxU32* errorState = 0) = 0;
1015 
1016 
1027  virtual void flushSimulation(bool sendPendingReports = false) = 0;
1028 
1038  virtual void setGravity(const PxVec3& vec) = 0;
1039 
1047  virtual PxVec3 getGravity() const = 0;
1048 
1054  virtual void setBounceThresholdVelocity(const PxReal t) = 0;
1055 
1061  virtual PxReal getBounceThresholdVelocity() const = 0;
1062 
1063 
1072  virtual void setCCDMaxPasses(PxU32 ccdMaxPasses) = 0;
1073 
1082  virtual PxU32 getCCDMaxPasses() const = 0;
1083 
1089  virtual PxReal getFrictionOffsetThreshold() const = 0;
1090 
1098  PX_DEPRECATED virtual void setFrictionType(PxFrictionType::Enum frictionType) = 0;
1099 
1104  virtual PxFrictionType::Enum getFrictionType() const = 0;
1105 
1107  /************************************************************************************************/
1108 
1123  virtual bool setVisualizationParameter(PxVisualizationParameter::Enum param, PxReal value) = 0;
1124 
1133  virtual PxReal getVisualizationParameter(PxVisualizationParameter::Enum paramEnum) const = 0;
1134 
1135 
1142  virtual void setVisualizationCullingBox(const PxBounds3& box) = 0;
1143 
1150  virtual PxBounds3 getVisualizationCullingBox() const = 0;
1151 
1163  virtual const PxRenderBuffer& getRenderBuffer() = 0;
1164 
1174  virtual void getSimulationStatistics(PxSimulationStatistics& stats) const = 0;
1175 
1176 
1178  /************************************************************************************************/
1179 
1183 
1189  virtual PxPruningStructureType::Enum getStaticStructure() const = 0;
1190 
1196  virtual PxPruningStructureType::Enum getDynamicStructure() const = 0;
1197 
1212  virtual void flushQueryUpdates() = 0;
1213 
1225  PX_DEPRECATED virtual PxBatchQuery* createBatchQuery(const PxBatchQueryDesc& desc) = 0;
1226 
1234  virtual void setDynamicTreeRebuildRateHint(PxU32 dynamicTreeRebuildRateHint) = 0;
1235 
1243  virtual PxU32 getDynamicTreeRebuildRateHint() const = 0;
1244 
1253  virtual void forceDynamicTreeRebuild(bool rebuildStaticStructure, bool rebuildDynamicStructure) = 0;
1254 
1262  virtual void setSceneQueryUpdateMode(PxSceneQueryUpdateMode::Enum updateMode) = 0;
1263 
1271  virtual PxSceneQueryUpdateMode::Enum getSceneQueryUpdateMode() const = 0;
1272 
1290  virtual void sceneQueriesUpdate(physx::PxBaseTask* completionTask = NULL, bool controlSimulation = true) = 0;
1291 
1303  virtual bool checkQueries(bool block = false) = 0;
1304 
1314  virtual bool fetchQueries(bool block = false) = 0;
1315 
1338  virtual bool raycast(
1339  const PxVec3& origin, const PxVec3& unitDir, const PxReal distance,
1340  PxRaycastCallback& hitCall, PxHitFlags hitFlags = PxHitFlags(PxHitFlag::eDEFAULT),
1341  const PxQueryFilterData& filterData = PxQueryFilterData(), PxQueryFilterCallback* filterCall = NULL,
1342  const PxQueryCache* cache = NULL) const = 0;
1343 
1371  virtual bool sweep(const PxGeometry& geometry, const PxTransform& pose, const PxVec3& unitDir, const PxReal distance,
1372  PxSweepCallback& hitCall, PxHitFlags hitFlags = PxHitFlags(PxHitFlag::eDEFAULT),
1373  const PxQueryFilterData& filterData = PxQueryFilterData(), PxQueryFilterCallback* filterCall = NULL,
1374  const PxQueryCache* cache = NULL, const PxReal inflation = 0.f) const = 0;
1375 
1376 
1396  virtual bool overlap(const PxGeometry& geometry, const PxTransform& pose, PxOverlapCallback& hitCall,
1397  const PxQueryFilterData& filterData = PxQueryFilterData(), PxQueryFilterCallback* filterCall = NULL
1398  ) const = 0;
1399 
1400 
1407  virtual PxU32 getSceneQueryStaticTimestamp() const = 0;
1409 
1410  /************************************************************************************************/
1414 
1420  virtual PxBroadPhaseType::Enum getBroadPhaseType() const = 0;
1421 
1428  virtual bool getBroadPhaseCaps(PxBroadPhaseCaps& caps) const = 0;
1429 
1435  virtual PxU32 getNbBroadPhaseRegions() const = 0;
1436 
1445  virtual PxU32 getBroadPhaseRegions(PxBroadPhaseRegionInfo* userBuffer, PxU32 bufferSize, PxU32 startIndex=0) const = 0;
1446 
1463  virtual PxU32 addBroadPhaseRegion(const PxBroadPhaseRegion& region, bool populateRegion=false) = 0;
1464 
1478  virtual bool removeBroadPhaseRegion(PxU32 handle) = 0;
1479 
1481 
1482  /************************************************************************************************/
1483 
1487 
1493  virtual PxTaskManager* getTaskManager() const = 0;
1494 
1495 
1514  virtual void lockRead(const char* file=NULL, PxU32 line=0) = 0;
1515 
1521  virtual void unlockRead() = 0;
1522 
1548  virtual void lockWrite(const char* file=NULL, PxU32 line=0) = 0;
1549 
1555  virtual void unlockWrite() = 0;
1556 
1557 
1571  virtual void setNbContactDataBlocks(PxU32 numBlocks) = 0;
1572 
1573 
1583  virtual PxU32 getNbContactDataBlocksUsed() const = 0;
1584 
1594  virtual PxU32 getMaxNbContactDataBlocksUsed() const = 0;
1595 
1596 
1602  virtual PxU32 getContactReportStreamBufferSize() const = 0;
1603 
1604 
1612  virtual void setSolverBatchSize(PxU32 solverBatchSize) = 0;
1613 
1621  virtual PxU32 getSolverBatchSize() const = 0;
1622 
1630  virtual void setSolverArticulationBatchSize(PxU32 solverBatchSize) = 0;
1631 
1639  virtual PxU32 getSolverArticulationBatchSize() const = 0;
1640 
1641 
1643 
1651  virtual PxReal getWakeCounterResetValue() const = 0;
1652 
1669  virtual void shiftOrigin(const PxVec3& shift) = 0;
1670 
1675  virtual PxPvdSceneClient* getScenePvdClient() = 0;
1676 
1677  void* userData;
1678 };
1679 
1680 #if !PX_DOXYGEN
1681 } // namespace physx
1682 #endif
1683 
1685 #endif
Definition: GuContactBuffer.h:37
PxU8 dominance1
Definition: PxScene.h:88
Base class of all task types.
Definition: PxTask.h:44
A scene is a collection of bodies and constraints which can interact.
Definition: PxScene.h:169
PxRigidActor * actor
Actor to which the shape belongs.
Definition: PxScene.h:156
Scene query filtering callbacks.
Definition: PxQueryFiltering.h:169
Special client for PxScene. It provides access to the PxPvdSceneFlag. It also provides simple user de...
Definition: PxPvdSceneClient.h:82
Class used to retrieve statistics for a simulation step.
Definition: PxSimulationStatistics.h:51
PxRigidDynamic represents a dynamic rigid simulation object in the physics SDK.
Definition: PxRigidDynamic.h:83
PxU8 PxDominanceGroup
Definition: PxScene.h:69
Expresses the dominance relationship of a contact. For the time being only three settings are permitt...
Definition: PxScene.h:83
An Instance of this class is passed to PxSimulationEventCallback.onContact().
Definition: PxSimulationEventCallback.h:347
Class representing the geometry of a capsule.
Definition: PxCapsuleGeometry.h:55
PxActor is the base class for the main simulation objects in the physics SDK.
Definition: PxActor.h:154
Abstract class for collision shapes.
Definition: PxShape.h:142
Batched queries object. This is used to perform several queries at the same time. ...
Definition: PxBatchQuery.h:57
float PxReal
Definition: PxSimpleTypes.h:78
A class representing the geometry of a sphere.
Definition: PxSphereGeometry.h:49
An interface class that the user can implement in order to modify CCD contact constraints.
Definition: PxContactModifyCallback.h:460
Scene query filtering data.
Definition: PxQueryFiltering.h:132
Identifies each type of actor for retrieving actors from a scene.
Definition: PxScene.h:99
"Region of interest" for the broad-phase.
Definition: PxBroadPhase.h:141
PxFilterFlags(* PxSimulationFilterShader)(PxFilterObjectAttributes attributes0, PxFilterData filterData0, PxFilterObjectAttributes attributes1, PxFilterData filterData1, PxPairFlags &pairFlags, const void *constantBlock, PxU32 constantBlockSize)
Filter shader to specify handling of collision pairs.
Definition: PxFiltering.h:589
A geometry object.
Definition: PxGeometry.h:75
A precomputed pruning structure to accelerate scene queries against newly added actors.
Definition: PxPruningStructure.h:62
PxU8 dominance0
Definition: PxScene.h:87
PxRigidActor represents a base class shared between dynamic and static rigid bodies in the physics SD...
Definition: PxRigidActor.h:58
An interface class that the user can implement in order to receive simulation events.
Definition: PxSimulationEventCallback.h:793
Enum
Definition: PxSceneDesc.h:72
#define PX_DEPRECATED
Definition: PxPreprocessor.h:424
An interface class that the user can implement in order to modify contact constraints.
Definition: PxContactModifyCallback.h:422
virtual ~PxScene()
Definition: PxScene.h:180
Descriptor class for PxBatchQuery.
Definition: PxBatchQueryDesc.h:217
single hit cache for scene queries.
Definition: PxScene.h:143
Information & stats structure for a region.
Definition: PxBroadPhase.h:150
PxShape * shape
Shape to test for intersection first.
Definition: PxScene.h:155
PxU8 geometry[sizeof(PxGeometry)]
Definition: PxGeometryHelpers.h:215
Enum
Definition: PxSceneDesc.h:129
void * userData
user can assign this to whatever, usually to create a 1:1 relationship with a user object...
Definition: PxScene.h:1677
PxDominanceGroupPair(PxU8 a, PxU8 b)
Definition: PxScene.h:85
Definition: PxQueryReport.h:82
uint8_t PxU8
Definition: PxSimpleTypes.h:75
Interface for points, lines, triangles, and text buffer.
Definition: PxRenderBuffer.h:131
class representing a rigid euclidean transform as a quaternion and a vector
Definition: PxTransform.h:48
A plugin class for implementing constraints.
Definition: PxConstraint.h:108
PX_INLINE PxQueryCache(PxShape *s, PxU32 findex)
constructor to set properties
Definition: PxScene.h:153
PxU32 faceIndex
Triangle index to test first - NOT CURRENTLY SUPPORTED.
Definition: PxScene.h:157
Enum
Definition: PxBroadPhase.h:68
PX_INLINE PxQueryCache()
constructor sets to default
Definition: PxScene.h:148
PxU8 PxClientID
An ID to identify different clients for multiclient support.
Definition: PxClient.h:46
Class representing 3D range or axis aligned bounding box.
Definition: PxBounds3.h:58
Enum
Definition: PxSceneDesc.h:103
Filter callback to specify handling of collision pairs.
Definition: PxFiltering.h:617
Enum
Definition: PxScene.h:101
Class used to retrieve limits(e.g. maximum number of bodies) for a scene. The limits are used as a hi...
Definition: PxSceneDesc.h:379
Collection class for serialization.
Definition: PxCollection.h:105
Material class to represent a set of surface properties.
Definition: PxMaterial.h:143
a tree structure of bodies connected by joints that is treated as a unit by the dynamics solver ...
Definition: PxArticulationBase.h:56
Enum
Definition: PxVisualizationParameter.h:64
PxU8 box[sizeof(PxBoxGeometry)]
Definition: PxGeometryHelpers.h:216
PxScene()
Definition: PxScene.h:179
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
Class to aggregate actors into a single broad-phase entry.
Definition: PxAggregate.h:70
PxFlags< PxActorTypeFlag::Enum, PxU16 > PxActorTypeFlags
Collection of set bits defined in PxActorTypeFlag.
Definition: PxScene.h:122
Caps class for broad phase.
Definition: PxBroadPhase.h:162
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
Broad-phase callback to receive broad-phase related events.
Definition: PxBroadPhase.h:96
Class representing the bounding volume hierarchy structure.
Definition: PxBVHStructure.h:57
#define PX_INLINE
Definition: PxPreprocessor.h:336
Enum
Definition: PxFiltering.h:701
Enum
Definition: PxSceneDesc.h:164
Class representing the geometry of a box.
Definition: PxBoxGeometry.h:50
3 Element vector class.
Definition: PxVec3.h:49