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-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 
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 PxGpuDispatcher* getGpuDispatcher() 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 
780  getFilterShader() const = 0;
781 
790  getFilterCallback() const = 0;
791 
821  virtual void resetFiltering(PxActor& actor) = 0;
822 
837  virtual void resetFiltering(PxRigidActor& actor, PxShape*const* shapes, PxU32 shapeCount) = 0;
838 
840  /************************************************************************************************/
841 
876  virtual void simulate(PxReal elapsedTime, physx::PxBaseTask* completionTask = NULL,
877  void* scratchMemBlock = 0, PxU32 scratchMemBlockSize = 0, bool controlSimulation = true) = 0;
878 
879 
890  virtual void advance(physx::PxBaseTask* completionTask = 0) = 0;
891 
909  virtual void collide(PxReal elapsedTime, physx::PxBaseTask* completionTask = 0, void* scratchMemBlock = 0,
910  PxU32 scratchMemBlockSize = 0, bool controlSimulation = true) = 0;
911 
923  virtual bool checkResults(bool block = false) = 0;
924 
932  virtual bool fetchCollision(bool block = false) = 0;
933 
955  virtual bool fetchResults(bool block = false, PxU32* errorState = 0) = 0;
956 
957 
973  virtual bool fetchResultsStart(const PxContactPairHeader*& contactPairs, PxU32& nbContactPairs, bool block = false) = 0;
974 
975 
984  virtual void processCallbacks(physx::PxBaseTask* continuation) = 0;
985 
986 
998  virtual void fetchResultsFinish(PxU32* errorState = 0) = 0;
999 
1000 
1011  virtual void flushSimulation(bool sendPendingReports = false) = 0;
1012 
1022  virtual void setGravity(const PxVec3& vec) = 0;
1023 
1031  virtual PxVec3 getGravity() const = 0;
1032 
1038  virtual void setBounceThresholdVelocity(const PxReal t) = 0;
1039 
1045  virtual PxReal getBounceThresholdVelocity() const = 0;
1046 
1047 
1056  virtual void setCCDMaxPasses(PxU32 ccdMaxPasses) = 0;
1057 
1066  virtual PxU32 getCCDMaxPasses() const = 0;
1067 
1073  virtual PxReal getFrictionOffsetThreshold() const = 0;
1074 
1079  virtual void setFrictionType(PxFrictionType::Enum frictionType) = 0;
1080 
1085  virtual PxFrictionType::Enum getFrictionType() const = 0;
1086 
1088  /************************************************************************************************/
1089 
1104  virtual bool setVisualizationParameter(PxVisualizationParameter::Enum param, PxReal value) = 0;
1105 
1114  virtual PxReal getVisualizationParameter(PxVisualizationParameter::Enum paramEnum) const = 0;
1115 
1116 
1123  virtual void setVisualizationCullingBox(const PxBounds3& box) = 0;
1124 
1131  virtual PxBounds3 getVisualizationCullingBox() const = 0;
1132 
1144  virtual const PxRenderBuffer& getRenderBuffer() = 0;
1145 
1155  virtual void getSimulationStatistics(PxSimulationStatistics& stats) const = 0;
1156 
1157 
1159  /************************************************************************************************/
1160 
1164 
1170  virtual PxPruningStructureType::Enum getStaticStructure() const = 0;
1171 
1177  virtual PxPruningStructureType::Enum getDynamicStructure() const = 0;
1178 
1194  virtual void flushQueryUpdates() = 0;
1195 
1207  PX_DEPRECATED virtual PxBatchQuery* createBatchQuery(const PxBatchQueryDesc& desc) = 0;
1208 
1216  virtual void setDynamicTreeRebuildRateHint(PxU32 dynamicTreeRebuildRateHint) = 0;
1217 
1225  virtual PxU32 getDynamicTreeRebuildRateHint() const = 0;
1226 
1235  virtual void forceDynamicTreeRebuild(bool rebuildStaticStructure, bool rebuildDynamicStructure) = 0;
1236 
1244  virtual void setSceneQueryUpdateMode(PxSceneQueryUpdateMode::Enum updateMode) = 0;
1245 
1253  virtual PxSceneQueryUpdateMode::Enum getSceneQueryUpdateMode() const = 0;
1254 
1272  virtual void sceneQueriesUpdate(physx::PxBaseTask* completionTask = NULL, bool controlSimulation = true) = 0;
1273 
1285  virtual bool checkQueries(bool block = false) = 0;
1286 
1296  virtual bool fetchQueries(bool block = false) = 0;
1297 
1320  virtual bool raycast(
1321  const PxVec3& origin, const PxVec3& unitDir, const PxReal distance,
1322  PxRaycastCallback& hitCall, PxHitFlags hitFlags = PxHitFlags(PxHitFlag::eDEFAULT),
1323  const PxQueryFilterData& filterData = PxQueryFilterData(), PxQueryFilterCallback* filterCall = NULL,
1324  const PxQueryCache* cache = NULL) const = 0;
1325 
1353  virtual bool sweep(const PxGeometry& geometry, const PxTransform& pose, const PxVec3& unitDir, const PxReal distance,
1354  PxSweepCallback& hitCall, PxHitFlags hitFlags = PxHitFlags(PxHitFlag::eDEFAULT),
1355  const PxQueryFilterData& filterData = PxQueryFilterData(), PxQueryFilterCallback* filterCall = NULL,
1356  const PxQueryCache* cache = NULL, const PxReal inflation = 0.f) const = 0;
1357 
1358 
1378  virtual bool overlap(const PxGeometry& geometry, const PxTransform& pose, PxOverlapCallback& hitCall,
1379  const PxQueryFilterData& filterData = PxQueryFilterData(), PxQueryFilterCallback* filterCall = NULL
1380  ) const = 0;
1381 
1382 
1389  virtual PxU32 getSceneQueryStaticTimestamp() const = 0;
1391 
1392  /************************************************************************************************/
1396 
1402  virtual PxBroadPhaseType::Enum getBroadPhaseType() const = 0;
1403 
1410  virtual bool getBroadPhaseCaps(PxBroadPhaseCaps& caps) const = 0;
1411 
1417  virtual PxU32 getNbBroadPhaseRegions() const = 0;
1418 
1427  virtual PxU32 getBroadPhaseRegions(PxBroadPhaseRegionInfo* userBuffer, PxU32 bufferSize, PxU32 startIndex=0) const = 0;
1428 
1445  virtual PxU32 addBroadPhaseRegion(const PxBroadPhaseRegion& region, bool populateRegion=false) = 0;
1446 
1460  virtual bool removeBroadPhaseRegion(PxU32 handle) = 0;
1461 
1463 
1464  /************************************************************************************************/
1465 
1469 
1475  virtual PxTaskManager* getTaskManager() const = 0;
1476 
1477 
1496  virtual void lockRead(const char* file=NULL, PxU32 line=0) = 0;
1497 
1503  virtual void unlockRead() = 0;
1504 
1530  virtual void lockWrite(const char* file=NULL, PxU32 line=0) = 0;
1531 
1537  virtual void unlockWrite() = 0;
1538 
1539 
1553  virtual void setNbContactDataBlocks(PxU32 numBlocks) = 0;
1554 
1555 
1565  virtual PxU32 getNbContactDataBlocksUsed() const = 0;
1566 
1576  virtual PxU32 getMaxNbContactDataBlocksUsed() const = 0;
1577 
1578 
1584  virtual PxU32 getContactReportStreamBufferSize() const = 0;
1585 
1586 
1594  virtual void setSolverBatchSize(PxU32 solverBatchSize) = 0;
1595 
1603  virtual PxU32 getSolverBatchSize() const = 0;
1604 
1605 
1607 
1615  virtual PxReal getWakeCounterResetValue() const = 0;
1616 
1633  virtual void shiftOrigin(const PxVec3& shift) = 0;
1634 
1639  virtual PxPvdSceneClient* getScenePvdClient() = 0;
1640 
1641  void* userData;
1642 };
1643 
1644 #if !PX_DOXYGEN
1645 } // namespace physx
1646 #endif
1647 
1649 #endif
Definition: GuContactBuffer.h:37
PxU8 dominance1
Definition: PxScene.h:88
Base class of all task types.
Definition: PxTask.h:45
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:54
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:70
#define PX_DEPRECATED
Definition: PxPreprocessor.h:437
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:127
void * userData
user can assign this to whatever, usually to create a 1:1 relationship with a user object...
Definition: PxScene.h:1641
PxDominanceGroupPair(PxU8 a, PxU8 b)
Definition: PxScene.h:85
Definition: PxQueryReport.h:81
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:101
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:401
Collection class for serialization.
Definition: PxCollection.h:105
Material class to represent a set of surface properties.
Definition: PxMaterial.h:130
a tree structure of bodies connected by joints that is treated as a unit by the dynamics solver ...
Definition: PxArticulationBase.h:57
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:349
Enum
Definition: PxSceneDesc.h:162
Class representing the geometry of a box.
Definition: PxBoxGeometry.h:50
3 Element vector class.
Definition: PxVec3.h:49