PxSceneDesc.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_SCENEDESC
32 #define PX_PHYSICS_NX_SCENEDESC
33 
37 #include "PxPhysXConfig.h"
38 #include "foundation/PxFlags.h"
39 #include "foundation/PxBounds3.h"
40 #include "PxFiltering.h"
41 #include "PxBroadPhase.h"
43 #include "task/PxTask.h"
44 
45 #if !PX_DOXYGEN
46 namespace physx
47 {
48 #endif
49 
50  class PxCudaContextManager;
51 
71 {
72  enum Enum
73  {
77 
78  eLAST
79  };
80 };
81 
102 {
103  enum Enum
104  {
107  eBUILD_DISABLED_COMMIT_DISABLED
108  };
109 };
110 
111 
128 {
129  enum Enum
130  {
134  eFRICTION_COUNT
135  };
136 };
137 
138 
147 {
148  enum Enum
149  {
151  eTGS
152  };
153 };
154 
155 
163 {
164  enum Enum
165  {
178  eENABLE_ACTIVE_ACTORS = (1<<0),
179 
192  eENABLE_CCD = (1<<1),
193 
213  eDISABLE_CCD_RESWEEP = (1<<2),
214 
222  eADAPTIVE_FORCE = (1<<3),
223 
231  eENABLE_PCM = (1 << 6),
232 
241  eDISABLE_CONTACT_REPORT_BUFFER_RESIZE = (1 << 7),
242 
253  eDISABLE_CONTACT_CACHE = (1 << 8),
254 
270  eREQUIRE_RW_LOCK = (1 << 9),
271 
279  eENABLE_STABILIZATION = (1 << 10),
280 
289  eENABLE_AVERAGE_POINT = (1 << 11),
290 
303  eEXCLUDE_KINEMATICS_FROM_ACTIVE_ACTORS = (1 << 12),
304 
305  /*\brief Enables the GPU dynamics pipeline
306 
307  When set to true, a CUDA ARCH 3.0 or above-enabled NVIDIA GPU is present and the CUDA context manager has been configured, this will run the GPU dynamics pipelin instead of the CPU dynamics pipeline.
308 
309  Note that this flag is not mutable and must be set in PxSceneDesc at scene creation.
310  */
311  eENABLE_GPU_DYNAMICS = (1 << 13),
312 
334  eENABLE_ENHANCED_DETERMINISM = (1<<14),
335 
350  eENABLE_FRICTION_EVERY_ITERATION = (1 << 15),
351 
352  eMUTABLE_FLAGS = eENABLE_ACTIVE_ACTORS|eEXCLUDE_KINEMATICS_FROM_ACTIVE_ACTORS
353  };
354 };
355 
356 
363 PX_FLAGS_OPERATORS(PxSceneFlag::Enum,PxU32)
364 
365 
370 
380 {
381 public:
390 
395 
399  PX_INLINE void setToDefault();
400 
405  PX_INLINE bool isValid() const;
406 };
407 
408 PX_INLINE PxSceneLimits::PxSceneLimits() : //constructor sets to default
409  maxNbActors (0),
410  maxNbBodies (0),
411  maxNbStaticShapes (0),
412  maxNbDynamicShapes (0),
413  maxNbAggregates (0),
414  maxNbConstraints (0),
415  maxNbRegions (0),
416  maxNbBroadPhaseOverlaps (0)
417 {
418 }
419 
421 {
422  *this = PxSceneLimits();
423 }
424 
426 {
427  if(maxNbRegions>256) // max number of regions is currently limited
428  return false;
429 
430  return true;
431 }
432 
433 //#if PX_SUPPORT_GPU_PHYSX
439 {
448 
450  constraintBufferCapacity(32 * 1024 * 1024),
451  contactBufferCapacity(24 * 1024 * 1024),
452  tempBufferCapacity(16 * 1024 * 1024),
453  contactStreamSize(1024 * 512),
454  patchStreamSize(1024 * 80),
455  forceStreamCapacity(1 * 1024 * 1024),
456  heapCapacity(64 * 1024 * 1024),
457  foundLostPairsCapacity(256 * 1024)
458  {
459  }
460 };
461 
462 //#endif
463 
472 {
473 public:
474 
486 
495 
504 
513 
523  const void* filterShaderData;
524 
533 
544 
554 
563 
572 
581 
590 
597 
609 
618 
629 
644 
655 
665 
672 
678  PxCpuDispatcher* cpuDispatcher;
679 
687  PxCudaContextManager* cudaContextManager;
688 
695 
700 
719 
725 
731  void* userData;
732 
749 
766 
781 
801 
819 
834 
847 
863 
875 
886 
891 
899 
904 
905 private:
909  // For internal use only
910  PxTolerancesScale tolerancesScale;
916 public:
926 
935  PX_INLINE void setToDefault(const PxTolerancesScale& scale);
936 
941  PX_INLINE bool isValid() const;
942 
946  // For internal use only
947  PX_INLINE const PxTolerancesScale& getTolerancesScale() const { return tolerancesScale; }
951 };
952 
954  gravity (PxVec3(0.0f)),
955  simulationEventCallback (NULL),
956  contactModifyCallback (NULL),
957  ccdContactModifyCallback (NULL),
958 
959  filterShaderData (NULL),
960  filterShaderDataSize (0),
961  filterShader (NULL),
962  filterCallback (NULL),
963 
964  kineKineFilteringMode (PxPairFilteringMode::eDEFAULT),
965  staticKineFilteringMode (PxPairFilteringMode::eDEFAULT),
966 
967  broadPhaseType (PxBroadPhaseType::eABP),
968  broadPhaseCallback (NULL),
969 
970  frictionType (PxFrictionType::ePATCH),
971  solverType (PxSolverType::ePGS),
972  bounceThresholdVelocity (0.2f * scale.speed),
973  frictionOffsetThreshold (0.04f * scale.length),
974  ccdMaxSeparation (0.04f * scale.length),
975  solverOffsetSlop (0.0f),
976 
977  flags (PxSceneFlag::eENABLE_PCM),
978 
979  cpuDispatcher (NULL),
980  cudaContextManager (NULL),
981 
982  staticStructure (PxPruningStructureType::eDYNAMIC_AABB_TREE),
983  dynamicStructure (PxPruningStructureType::eDYNAMIC_AABB_TREE),
984  dynamicTreeRebuildRateHint (100),
985  sceneQueryUpdateMode (PxSceneQueryUpdateMode::eBUILD_ENABLED_COMMIT_ENABLED),
986 
987  userData (NULL),
988 
989  solverBatchSize (128),
990  solverArticulationBatchSize (16),
991 
992  nbContactDataBlocks (0),
993  maxNbContactDataBlocks (1<<16),
994  maxBiasCoefficient (PX_MAX_F32),
995  contactReportStreamBufferSize (8192),
996  ccdMaxPasses (1),
997  ccdThreshold (PX_MAX_F32),
998  wakeCounterResetValue (20.0f*0.02f),
1000  gpuMaxNumPartitions (8),
1001  gpuComputeVersion (0),
1002  tolerancesScale (scale)
1003 {
1004 }
1005 
1007 {
1008  *this = PxSceneDesc(scale);
1009 }
1010 
1012 {
1013  if(!filterShader)
1014  return false;
1015 
1016  if( ((filterShaderDataSize == 0) && (filterShaderData != NULL)) ||
1017  ((filterShaderDataSize > 0) && (filterShaderData == NULL)) )
1018  return false;
1019 
1020  if(!limits.isValid())
1021  return false;
1022 
1024  return false;
1025 
1027  return false;
1028 
1029  if(bounceThresholdVelocity < 0.0f)
1030  return false;
1031  if(frictionOffsetThreshold < 0.0f)
1032  return false;
1033  if(ccdMaxSeparation < 0.0f)
1034  return false;
1035  if (solverOffsetSlop < 0.f)
1036  return false;
1037 
1038  if(ccdThreshold <= 0.f)
1039  return false;
1040 
1041  if(!cpuDispatcher)
1042  return false;
1043 
1045  return false;
1046 
1048  return false;
1049 
1050  if(wakeCounterResetValue <= 0.0f)
1051  return false;
1052 
1053  //Adaptive force and stabilization are incompatible. You can only have one or the other
1055  return false;
1056 
1057  if(!sanityBounds.isValid())
1058  return false;
1059 
1060 #if PX_SUPPORT_GPU_PHYSX
1061  //gpuMaxNumPartitions must be power of 2
1062  if((gpuMaxNumPartitions&(gpuMaxNumPartitions - 1)) != 0)
1063  return false;
1064  if (gpuMaxNumPartitions > 32)
1065  return false;
1066 #endif
1067 
1068  return true;
1069 }
1070 
1071 
1072 #if !PX_DOXYGEN
1073 } // namespace physx
1074 #endif
1075 
1077 #endif
Definition: GuContactBuffer.h:37
const void * filterShaderData
Shared global filter data which will get passed into the filter shader.
Definition: PxSceneDesc.h:523
PxU32 solverBatchSize
Defines the number of actors required to spawn a separate rigid body solver island task chain...
Definition: PxSceneDesc.h:748
PxSolverType::Enum solverType
Selects the solver algorithm to use.
Definition: PxSceneDesc.h:617
Descriptor class for scenes. See PxScene.
Definition: PxSceneDesc.h:471
PX_INLINE bool isValid() const
Returns true if the descriptor is valid.
Definition: PxSceneDesc.h:1011
Pruning structure used to accelerate scene queries.
Definition: PxSceneDesc.h:70
PxU32 patchStreamSize
Size of the contact patch stream buffer allocated in pinned host memory. This is double-buffered so t...
Definition: PxSceneDesc.h:444
PxFrictionType::Enum frictionType
Selects the friction algorithm to use for simulation.
Definition: PxSceneDesc.h:608
PxSceneQueryUpdateMode::Enum sceneQueryUpdateMode
Defines the scene query update mode. Default: PxSceneQueryUpdateMode::eBUILD_ENABLED_COMMIT_ENABLED.
Definition: PxSceneDesc.h:724
PxReal solverOffsetSlop
A slop value used to zero contact offsets from the body&#39;s COM on an axis if the offset along that axi...
Definition: PxSceneDesc.h:664
PxCudaContextManager * cudaContextManager
The CUDA context manager for the scene.
Definition: PxSceneDesc.h:687
PxSceneFlags flags
Flags used to select scene options.
Definition: PxSceneDesc.h:671
PX_INLINE void setToDefault(const PxTolerancesScale &scale)
(re)sets the structure to the default.
Definition: PxSceneDesc.h:1006
PxSceneLimits limits
Expected scene limits.
Definition: PxSceneDesc.h:596
PxU32 tempBufferCapacity
Capacity of temp buffer allocated in pinned host memory.
Definition: PxSceneDesc.h:442
Using a static AABB tree.
Definition: PxSceneDesc.h:76
Select default patch-friction model.
Definition: PxSceneDesc.h:131
float PxReal
Definition: PxSimpleTypes.h:78
An interface class that the user can implement in order to modify CCD contact constraints.
Definition: PxContactModifyCallback.h:460
PxSimulationFilterCallback * filterCallback
A custom collision filter callback which can be used to implement more complex filtering operations w...
Definition: PxSceneDesc.h:553
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
Sizes of pre-allocated buffers use for GPU dynamics.
Definition: PxSceneDesc.h:438
PxU32 maxNbStaticShapes
Expected maximum number of static shapes.
Definition: PxSceneDesc.h:384
PxVec3 gravity
Gravity vector.
Definition: PxSceneDesc.h:485
PxU32 maxNbActors
Expected maximum number of actors.
Definition: PxSceneDesc.h:382
Enum for selecting the type of solver used for the simulation.
Definition: PxSceneDesc.h:146
PxU32 maxNbBroadPhaseOverlaps
Expected maximum number of broad-phase overlaps.
Definition: PxSceneDesc.h:389
Enable adaptive forces to accelerate convergence of the solver.
Definition: PxSceneDesc.h:222
flags for configuring properties of the scene
Definition: PxSceneDesc.h:162
PxContactModifyCallback * contactModifyCallback
Possible asynchronous callback for contact modification.
Definition: PxSceneDesc.h:503
Broad phase algorithm used in the simulation.
Definition: PxBroadPhase.h:66
PxCpuDispatcher * cpuDispatcher
The CPU task dispatcher for the scene.
Definition: PxSceneDesc.h:678
void * userData
Will be copied to PxScene::userData.
Definition: PxSceneDesc.h:731
PxPairFilteringMode::Enum kineKineFilteringMode
Filtering mode for kinematic-kinematic pairs in the broadphase.
Definition: PxSceneDesc.h:562
PxU32 gpuComputeVersion
Defines which compute version the GPU dynamics should target. DO NOT MODIFY.
Definition: PxSceneDesc.h:903
PxReal ccdThreshold
CCD threshold.
Definition: PxSceneDesc.h:862
An interface class that the user can implement in order to receive simulation events.
Definition: PxSimulationEventCallback.h:793
PxU32 maxNbDynamicShapes
Expected maximum number of dynamic shapes.
Definition: PxSceneDesc.h:385
PxSimulationFilterShader filterShader
The custom filter shader to use for collision filtering.
Definition: PxSceneDesc.h:543
PxU32 contactReportStreamBufferSize
Size of the contact report stream (in bytes).
Definition: PxSceneDesc.h:833
Enum
Definition: PxSceneDesc.h:72
Both scene query build and commit are executed.
Definition: PxSceneDesc.h:105
PxU32 maxNbRegions
Expected maximum number of broad-phase regions.
Definition: PxSceneDesc.h:388
PxCCDContactModifyCallback * ccdContactModifyCallback
Possible asynchronous callback for contact modification.
Definition: PxSceneDesc.h:512
An interface class that the user can implement in order to modify contact constraints.
Definition: PxContactModifyCallback.h:422
PxPairFilteringMode::Enum staticKineFilteringMode
Filtering mode for static-kinematic pairs in the broadphase.
Definition: PxSceneDesc.h:571
PxU32 gpuMaxNumPartitions
Limitation for the partitions in the GPU dynamics pipeline. This variable must be power of 2...
Definition: PxSceneDesc.h:898
PxFlags< PxSceneFlag::Enum, PxU32 > PxSceneFlags
collection of set bits defined in PxSceneFlag.
Definition: PxSceneDesc.h:362
Default Projected Gauss-Seidel iterative solver.
Definition: PxSceneDesc.h:150
PxReal wakeCounterResetValue
The wake counter reset value.
Definition: PxSceneDesc.h:874
Definition: PxFiltering.h:699
Enum
Definition: PxSceneDesc.h:129
PxgDynamicsMemoryConfig gpuDynamicsConfig
The pre-allocations performed in the GPU dynamics pipeline.
Definition: PxSceneDesc.h:890
Using a simple data structure.
Definition: PxSceneDesc.h:74
PxU32 ccdMaxPasses
Maximum number of CCD passes.
Definition: PxSceneDesc.h:846
PxU16 flags
a set of Px1DConstraintFlags
Definition: PxConstraintDesc.h:110
PxU32 heapCapacity
Initial capacity of the GPU and pinned host memory heaps. Additional memory will be allocated if more...
Definition: PxSceneDesc.h:446
PxReal maxBiasCoefficient
The maximum bias coefficient used in the constraint solver.
Definition: PxSceneDesc.h:818
#define PX_MAX_F32
Definition: PxSimpleTypes.h:86
Enum
Definition: PxSceneDesc.h:148
#define PX_MAX_BOUNDS_EXTENTS
Definition: PxBounds3.h:46
PxU32 nbContactDataBlocks
Setting to define the number of 16K blocks that will be initially reserved to store contact...
Definition: PxSceneDesc.h:780
PxBroadPhaseType::Enum broadPhaseType
Selects the broad-phase algorithm to use.
Definition: PxSceneDesc.h:580
PX_INLINE PxSceneLimits()
constructor sets to default
Definition: PxSceneDesc.h:408
PxU32 dynamicTreeRebuildRateHint
Hint for how much work should be done per simulation frame to rebuild the pruning structure...
Definition: PxSceneDesc.h:718
PxU32 maxNbAggregates
Expected maximum number of aggregates.
Definition: PxSceneDesc.h:386
PxU32 maxNbConstraints
Expected maximum number of constraint shaders.
Definition: PxSceneDesc.h:387
PxU32 maxNbContactDataBlocks
Setting to define the maximum number of 16K blocks that can be allocated to store contact...
Definition: PxSceneDesc.h:800
Select one directional per-contact friction model.
Definition: PxSceneDesc.h:132
PxBroadPhaseCallback * broadPhaseCallback
Broad-phase callback.
Definition: PxSceneDesc.h:589
Enum
Definition: PxBroadPhase.h:68
PxPruningStructureType::Enum dynamicStructure
Defines the structure used to store dynamic objects.
Definition: PxSceneDesc.h:699
PX_INLINE PxSceneDesc(const PxTolerancesScale &scale)
constructor sets to default.
Definition: PxSceneDesc.h:953
Select two directional per-contact friction model.
Definition: PxSceneDesc.h:133
Class to define the scale at which simulation runs. Most simulation tolerances are calculated in term...
Definition: PxTolerancesScale.h:56
PxgDynamicsMemoryConfig()
Definition: PxSceneDesc.h:449
PxU32 contactBufferCapacity
Capacity of contact buffer allocated in GPU global memory.
Definition: PxSceneDesc.h:441
PxU32 maxNbBodies
Expected maximum number of dynamic rigid bodies.
Definition: PxSceneDesc.h:383
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
Enables additional stabilization pass in solver.
Definition: PxSceneDesc.h:279
PxReal frictionOffsetThreshold
A threshold of contact separation distance used to decide if a contact point will experience friction...
Definition: PxSceneDesc.h:643
PxSimulationEventCallback * simulationEventCallback
Possible notification callback.
Definition: PxSceneDesc.h:494
PxReal ccdMaxSeparation
A threshold for speculative CCD. Used to control whether bias, restitution or a combination of the tw...
Definition: PxSceneDesc.h:654
PX_INLINE bool isValid() const
Returns true if the descriptor is valid.
Definition: PxSceneDesc.h:425
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
PxU32 solverArticulationBatchSize
Defines the number of articulations required to spawn a separate rigid body solver island task chain...
Definition: PxSceneDesc.h:765
PxU32 foundLostPairsCapacity
Capacity of found and lost buffers allocated in GPU global memory. This is used for the found/lost pa...
Definition: PxSceneDesc.h:447
PxU32 contactStreamSize
Size of contact stream buffer allocated in pinned host memory. This is double-buffered so total alloc...
Definition: PxSceneDesc.h:443
PxBounds3 sanityBounds
The bounds used to sanity check user-set positions of actors and articulation links.
Definition: PxSceneDesc.h:885
PX_CUDA_CALLABLE PX_FORCE_INLINE bool isValid() const
Definition: PxBounds3.h:467
Enum for selecting the friction algorithm used for simulation.
Definition: PxSceneDesc.h:127
PxU32 filterShaderDataSize
Size (in bytes) of the shared global filter data filterShaderData.
Definition: PxSceneDesc.h:532
PxU32 forceStreamCapacity
Capacity of force buffer allocated in pinned host memory.
Definition: PxSceneDesc.h:445
uint32_t PxU32
Definition: Px.h:48
Using a dynamic AABB tree.
Definition: PxSceneDesc.h:75
PxReal bounceThresholdVelocity
A contact with a relative velocity below this will not bounce. A typical value for simulation...
Definition: PxSceneDesc.h:628
Broad-phase callback to receive broad-phase related events.
Definition: PxBroadPhase.h:96
PX_INLINE void setToDefault()
(re)sets the structure to the default
Definition: PxSceneDesc.h:420
PxPruningStructureType::Enum staticStructure
Defines the structure used to store static objects.
Definition: PxSceneDesc.h:694
PxU32 constraintBufferCapacity
Capacity of constraint buffer allocated in GPU global memory.
Definition: PxSceneDesc.h:440
#define PX_INLINE
Definition: PxPreprocessor.h:336
Enum
Definition: PxFiltering.h:701
Enum
Definition: PxSceneDesc.h:164
Scene query update mode.
Definition: PxSceneDesc.h:101
3 Element vector class.
Definition: PxVec3.h:49
Scene query build only is executed.
Definition: PxSceneDesc.h:106