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-2019 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 
69 {
70  enum Enum
71  {
75 
76  eLAST
77  };
78 };
79 
100 {
101  enum Enum
102  {
105  eBUILD_DISABLED_COMMIT_DISABLED
106  };
107 };
108 
109 
126 {
127  enum Enum
128  {
132  eFRICTION_COUNT
133  };
134 };
135 
136 
145 {
146  enum Enum
147  {
149  eTGS
150  };
151 };
152 
153 
161 {
162  enum Enum
163  {
176  eENABLE_ACTIVE_ACTORS = (1<<0),
177 
190  eENABLE_CCD = (1<<1),
191 
211  eDISABLE_CCD_RESWEEP = (1<<2),
212 
220  eADAPTIVE_FORCE = (1<<3),
221 
232  eENABLE_KINEMATIC_STATIC_PAIRS PX_DEPRECATED = (1<<4),
233 
244  eENABLE_KINEMATIC_PAIRS PX_DEPRECATED = (1<<5),
245 
253  eENABLE_PCM = (1 << 6),
254 
263  eDISABLE_CONTACT_REPORT_BUFFER_RESIZE = (1 << 7),
264 
275  eDISABLE_CONTACT_CACHE = (1 << 8),
276 
292  eREQUIRE_RW_LOCK = (1 << 9),
293 
301  eENABLE_STABILIZATION = (1 << 10),
302 
311  eENABLE_AVERAGE_POINT = (1 << 11),
312 
325  eEXCLUDE_KINEMATICS_FROM_ACTIVE_ACTORS = (1 << 12),
326 
327  /*\brief Enables the GPU dynamics pipeline
328 
329  When set to true, a CUDA ARCH 3.0 or above-enabled NVIDIA GPU is present and the GPU dispatcher has been configured, this will run the GPU dynamics pipelin instead of the CPU dynamics pipeline.
330 
331  Note that this flag is not mutable and must be set in PxSceneDesc at scene creation.
332  */
333  eENABLE_GPU_DYNAMICS = (1 << 13),
334 
356  eENABLE_ENHANCED_DETERMINISM = (1<<14),
357 
372  eENABLE_FRICTION_EVERY_ITERATION = (1 << 15),
373 
374  eMUTABLE_FLAGS = eENABLE_ACTIVE_ACTORS|eEXCLUDE_KINEMATICS_FROM_ACTIVE_ACTORS
375  };
376 };
377 
378 
385 PX_FLAGS_OPERATORS(PxSceneFlag::Enum,PxU32)
386 
387 
392 
402 {
403 public:
412 
417 
421  PX_INLINE void setToDefault();
422 
427  PX_INLINE bool isValid() const;
428 };
429 
430 PX_INLINE PxSceneLimits::PxSceneLimits() : //constructor sets to default
431  maxNbActors (0),
432  maxNbBodies (0),
433  maxNbStaticShapes (0),
434  maxNbDynamicShapes (0),
435  maxNbAggregates (0),
436  maxNbConstraints (0),
437  maxNbRegions (0),
438  maxNbBroadPhaseOverlaps (0)
439 {
440 }
441 
443 {
444  *this = PxSceneLimits();
445 }
446 
448 {
449  if(maxNbRegions>256) // max number of regions is currently limited
450  return false;
451 
452  return true;
453 }
454 
455 //#if PX_SUPPORT_GPU_PHYSX
461 {
470 
472  constraintBufferCapacity(32 * 1024 * 1024),
473  contactBufferCapacity(24 * 1024 * 1024),
474  tempBufferCapacity(16 * 1024 * 1024),
475  contactStreamSize(1024 * 512),
476  patchStreamSize(1024 * 80),
477  forceStreamCapacity(1 * 1024 * 1024),
478  heapCapacity(64 * 1024 * 1024),
479  foundLostPairsCapacity(256 * 1024)
480  {
481  }
482 };
483 
484 //#endif
485 
494 {
495 public:
496 
508 
517 
526 
535 
545  const void* filterShaderData;
546 
555 
566 
576 
585 
594 
603 
612 
619 
631 
640 
651 
666 
677 
687 
694 
700  PxCpuDispatcher* cpuDispatcher;
701 
709  PxGpuDispatcher* gpuDispatcher;
710 
717 
722 
741 
747 
753  void* userData;
754 
769 
784 
804 
822 
837 
850 
866 
878 
889 
894 
902 
907 
908 private:
912  // For internal use only
913  PxTolerancesScale tolerancesScale;
919 public:
929 
938  PX_INLINE void setToDefault(const PxTolerancesScale& scale);
939 
944  PX_INLINE bool isValid() const;
945 
949  // For internal use only
950  PX_INLINE const PxTolerancesScale& getTolerancesScale() const { return tolerancesScale; }
954 };
955 
957  gravity (PxVec3(0.0f)),
958  simulationEventCallback (NULL),
959  contactModifyCallback (NULL),
960  ccdContactModifyCallback (NULL),
961 
962  filterShaderData (NULL),
963  filterShaderDataSize (0),
964  filterShader (NULL),
965  filterCallback (NULL),
966 
967  kineKineFilteringMode (PxPairFilteringMode::eDEFAULT),
968  staticKineFilteringMode (PxPairFilteringMode::eDEFAULT),
969 
970  broadPhaseType (PxBroadPhaseType::eABP),
971  broadPhaseCallback (NULL),
972 
973  frictionType (PxFrictionType::ePATCH),
974  solverType (PxSolverType::ePGS),
975  bounceThresholdVelocity (0.2f * scale.speed),
976  frictionOffsetThreshold (0.04f * scale.length),
977  ccdMaxSeparation (0.04f * scale.length),
978  solverOffsetSlop (0.0f),
979 
980  flags (PxSceneFlag::eENABLE_PCM),
981 
982  cpuDispatcher (NULL),
983  gpuDispatcher (NULL),
984 
985  staticStructure (PxPruningStructureType::eDYNAMIC_AABB_TREE),
986  dynamicStructure (PxPruningStructureType::eDYNAMIC_AABB_TREE),
987  dynamicTreeRebuildRateHint (100),
988  sceneQueryUpdateMode (PxSceneQueryUpdateMode::eBUILD_ENABLED_COMMIT_ENABLED),
989 
990  userData (NULL),
991 
992  solverBatchSize (128),
993 
994  nbContactDataBlocks (0),
995  maxNbContactDataBlocks (1<<16),
996  maxBiasCoefficient (PX_MAX_F32),
997  contactReportStreamBufferSize (8192),
998  ccdMaxPasses (1),
999  ccdThreshold (PX_MAX_F32),
1000  wakeCounterResetValue (20.0f*0.02f),
1002  gpuMaxNumPartitions (8),
1003  gpuComputeVersion (0),
1004  tolerancesScale (scale)
1005 {
1006 }
1007 
1009 {
1010  *this = PxSceneDesc(scale);
1011 }
1012 
1014 {
1015  if(!filterShader)
1016  return false;
1017 
1018  if( ((filterShaderDataSize == 0) && (filterShaderData != NULL)) ||
1019  ((filterShaderDataSize > 0) && (filterShaderData == NULL)) )
1020  return false;
1021 
1022  if(!limits.isValid())
1023  return false;
1024 
1026  return false;
1027 
1029  return false;
1030 
1031  if(bounceThresholdVelocity < 0.0f)
1032  return false;
1033  if(frictionOffsetThreshold < 0.0f)
1034  return false;
1035  if(ccdMaxSeparation < 0.0f)
1036  return false;
1037  if (solverOffsetSlop < 0.f)
1038  return false;
1039 
1040  if(ccdThreshold <= 0.f)
1041  return false;
1042 
1043  if(!cpuDispatcher)
1044  return false;
1045 
1047  return false;
1048 
1050  return false;
1051 
1052  if(wakeCounterResetValue <= 0.0f)
1053  return false;
1054 
1055  //Adaptive force and stabilization are incompatible. You can only have one or the other
1057  return false;
1058 
1059  if(!sanityBounds.isValid())
1060  return false;
1061 
1062 #if PX_SUPPORT_GPU_PHYSX
1063  //gpuMaxNumPartitions must be power of 2
1064  if((gpuMaxNumPartitions&(gpuMaxNumPartitions - 1)) != 0)
1065  return false;
1066  if (gpuMaxNumPartitions > 32)
1067  return false;
1068 #endif
1069 
1070  return true;
1071 }
1072 
1073 
1074 #if !PX_DOXYGEN
1075 } // namespace physx
1076 #endif
1077 
1079 #endif
Definition: GuContactBuffer.h:37
const void * filterShaderData
Shared global filter data which will get passed into the filter shader.
Definition: PxSceneDesc.h:545
PxU32 solverBatchSize
Defines the number of actors required to spawn a separate rigid body solver island task chain...
Definition: PxSceneDesc.h:768
PxSolverType::Enum solverType
Selects the solver algorithm to use.
Definition: PxSceneDesc.h:639
Descriptor class for scenes. See PxScene.
Definition: PxSceneDesc.h:493
PX_INLINE bool isValid() const
Returns true if the descriptor is valid.
Definition: PxSceneDesc.h:1013
Pruning structure used to accelerate scene queries.
Definition: PxSceneDesc.h:68
PxU32 patchStreamSize
Size of the contact patch stream buffer allocated in pinned host memory. This is double-buffered so t...
Definition: PxSceneDesc.h:466
PxFrictionType::Enum frictionType
Selects the friction algorithm to use for simulation.
Definition: PxSceneDesc.h:630
PxSceneQueryUpdateMode::Enum sceneQueryUpdateMode
Defines the scene query update mode. Default: PxSceneQueryUpdateMode::eBUILD_ENABLED_COMMIT_ENABLED.
Definition: PxSceneDesc.h:746
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:686
PxSceneFlags flags
Flags used to select scene options.
Definition: PxSceneDesc.h:693
PX_INLINE void setToDefault(const PxTolerancesScale &scale)
(re)sets the structure to the default.
Definition: PxSceneDesc.h:1008
PxSceneLimits limits
Expected scene limits.
Definition: PxSceneDesc.h:618
PxU32 tempBufferCapacity
Capacity of temp buffer allocated in pinned host memory.
Definition: PxSceneDesc.h:464
Using a static AABB tree.
Definition: PxSceneDesc.h:74
Select default patch-friction model.
Definition: PxSceneDesc.h:129
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:575
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:460
PxU32 maxNbStaticShapes
Expected maximum number of static shapes.
Definition: PxSceneDesc.h:406
PxVec3 gravity
Gravity vector.
Definition: PxSceneDesc.h:507
PxU32 maxNbActors
Expected maximum number of actors.
Definition: PxSceneDesc.h:404
Enum for selecting the type of solver used for the simulation.
Definition: PxSceneDesc.h:144
PxU32 maxNbBroadPhaseOverlaps
Expected maximum number of broad-phase overlaps.
Definition: PxSceneDesc.h:411
Enable adaptive forces to accelerate convergence of the solver.
Definition: PxSceneDesc.h:220
flags for configuring properties of the scene
Definition: PxSceneDesc.h:160
PxContactModifyCallback * contactModifyCallback
Possible asynchronous callback for contact modification.
Definition: PxSceneDesc.h:525
Broad phase algorithm used in the simulation.
Definition: PxBroadPhase.h:66
PxCpuDispatcher * cpuDispatcher
The CPU task dispatcher for the scene.
Definition: PxSceneDesc.h:700
void * userData
Will be copied to PxScene::userData.
Definition: PxSceneDesc.h:753
PxPairFilteringMode::Enum kineKineFilteringMode
Filtering mode for kinematic-kinematic pairs in the broadphase.
Definition: PxSceneDesc.h:584
PxU32 gpuComputeVersion
Defines which compute version the GPU dynamics should target. DO NOT MODIFY.
Definition: PxSceneDesc.h:906
PxReal ccdThreshold
CCD threshold.
Definition: PxSceneDesc.h:865
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:407
PxSimulationFilterShader filterShader
The custom filter shader to use for collision filtering.
Definition: PxSceneDesc.h:565
PxU32 contactReportStreamBufferSize
Size of the contact report stream (in bytes).
Definition: PxSceneDesc.h:836
Enum
Definition: PxSceneDesc.h:70
Both scene query build and commit are executed.
Definition: PxSceneDesc.h:103
PxU32 maxNbRegions
Expected maximum number of broad-phase regions.
Definition: PxSceneDesc.h:410
PxCCDContactModifyCallback * ccdContactModifyCallback
Possible asynchronous callback for contact modification.
Definition: PxSceneDesc.h:534
#define PX_DEPRECATED
Definition: PxPreprocessor.h:412
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:593
PxU32 gpuMaxNumPartitions
Limitation for the partitions in the GPU dynamics pipeline. This variable must be power of 2...
Definition: PxSceneDesc.h:901
PxFlags< PxSceneFlag::Enum, PxU32 > PxSceneFlags
collection of set bits defined in PxSceneFlag.
Definition: PxSceneDesc.h:384
Default Projected Gauss-Seidel iterative solver.
Definition: PxSceneDesc.h:148
PxReal wakeCounterResetValue
The wake counter reset value.
Definition: PxSceneDesc.h:877
Definition: PxFiltering.h:699
Enum
Definition: PxSceneDesc.h:127
PxgDynamicsMemoryConfig gpuDynamicsConfig
The pre-allocations performed in the GPU dynamics pipeline.
Definition: PxSceneDesc.h:893
Using a simple data structure.
Definition: PxSceneDesc.h:72
PxU32 ccdMaxPasses
Maximum number of CCD passes.
Definition: PxSceneDesc.h:849
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:468
PxGpuDispatcher * gpuDispatcher
The GPU task dispatcher for the scene.
Definition: PxSceneDesc.h:709
PxReal maxBiasCoefficient
The maximum bias coefficient used in the constraint solver.
Definition: PxSceneDesc.h:821
#define PX_MAX_F32
Definition: PxSimpleTypes.h:86
Enum
Definition: PxSceneDesc.h:146
#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:783
PxBroadPhaseType::Enum broadPhaseType
Selects the broad-phase algorithm to use.
Definition: PxSceneDesc.h:602
PX_INLINE PxSceneLimits()
constructor sets to default
Definition: PxSceneDesc.h:430
PxU32 dynamicTreeRebuildRateHint
Hint for how much work should be done per simulation frame to rebuild the pruning structure...
Definition: PxSceneDesc.h:740
PxU32 maxNbAggregates
Expected maximum number of aggregates.
Definition: PxSceneDesc.h:408
PxU32 maxNbConstraints
Expected maximum number of constraint shaders.
Definition: PxSceneDesc.h:409
PxU32 maxNbContactDataBlocks
Setting to define the maximum number of 16K blocks that can be allocated to store contact...
Definition: PxSceneDesc.h:803
Select one directional per-contact friction model.
Definition: PxSceneDesc.h:130
PxBroadPhaseCallback * broadPhaseCallback
Broad-phase callback.
Definition: PxSceneDesc.h:611
Enum
Definition: PxBroadPhase.h:68
PxPruningStructureType::Enum dynamicStructure
Defines the structure used to store dynamic objects.
Definition: PxSceneDesc.h:721
PX_INLINE PxSceneDesc(const PxTolerancesScale &scale)
constructor sets to default.
Definition: PxSceneDesc.h:956
Select two directional per-contact friction model.
Definition: PxSceneDesc.h:131
Class to define the scale at which simulation runs. Most simulation tolerances are calculated in term...
Definition: PxTolerancesScale.h:56
PxgDynamicsMemoryConfig()
Definition: PxSceneDesc.h:471
PxU32 contactBufferCapacity
Capacity of contact buffer allocated in GPU global memory.
Definition: PxSceneDesc.h:463
PxU32 maxNbBodies
Expected maximum number of dynamic rigid bodies.
Definition: PxSceneDesc.h:405
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
Enables additional stabilization pass in solver.
Definition: PxSceneDesc.h:301
PxReal frictionOffsetThreshold
A threshold of contact separation distance used to decide if a contact point will experience friction...
Definition: PxSceneDesc.h:665
PxSimulationEventCallback * simulationEventCallback
Possible notification callback.
Definition: PxSceneDesc.h:516
PxReal ccdMaxSeparation
A threshold for speculative CCD. Used to control whether bias, restitution or a combination of the tw...
Definition: PxSceneDesc.h:676
PX_INLINE bool isValid() const
Returns true if the descriptor is valid.
Definition: PxSceneDesc.h:447
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
PxU32 foundLostPairsCapacity
Capacity of found and lost buffers allocated in GPU global memory. This is used for the found/lost pa...
Definition: PxSceneDesc.h:469
PxU32 contactStreamSize
Size of contact stream buffer allocated in pinned host memory. This is double-buffered so total alloc...
Definition: PxSceneDesc.h:465
PxBounds3 sanityBounds
The bounds used to sanity check user-set positions of actors and articulation links.
Definition: PxSceneDesc.h:888
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:125
PxU32 filterShaderDataSize
Size (in bytes) of the shared global filter data filterShaderData.
Definition: PxSceneDesc.h:554
PxU32 forceStreamCapacity
Capacity of force buffer allocated in pinned host memory.
Definition: PxSceneDesc.h:467
uint32_t PxU32
Definition: Px.h:48
Using a dynamic AABB tree.
Definition: PxSceneDesc.h:73
PxReal bounceThresholdVelocity
A contact with a relative velocity below this will not bounce. A typical value for simulation...
Definition: PxSceneDesc.h:650
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:442
PxPruningStructureType::Enum staticStructure
Defines the structure used to store static objects.
Definition: PxSceneDesc.h:716
PxU32 constraintBufferCapacity
Capacity of constraint buffer allocated in GPU global memory.
Definition: PxSceneDesc.h:462
#define PX_INLINE
Definition: PxPreprocessor.h:324
Enum
Definition: PxFiltering.h:701
Enum
Definition: PxSceneDesc.h:162
Scene query update mode.
Definition: PxSceneDesc.h:99
3 Element vector class.
Definition: PxVec3.h:49
Scene query build only is executed.
Definition: PxSceneDesc.h:104