RavEngine
Loading...
Searching...
No Matches
PxSceneDesc.h
1// Redistribution and use in source and binary forms, with or without
2// modification, are permitted provided that the following conditions
3// are met:
4// * Redistributions of source code must retain the above copyright
5// notice, this list of conditions and the following disclaimer.
6// * Redistributions in binary form must reproduce the above copyright
7// notice, this list of conditions and the following disclaimer in the
8// documentation and/or other materials provided with the distribution.
9// * Neither the name of NVIDIA CORPORATION nor the names of its
10// contributors may be used to endorse or promote products derived
11// from this software without specific prior written permission.
12//
13// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
14// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24//
25// Copyright (c) 2008-2022 NVIDIA Corporation. All rights reserved.
26// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
27// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
28
29#ifndef PX_SCENE_DESC_H
30#define PX_SCENE_DESC_H
35#include "PxSceneQueryDesc.h"
36#include "PxPhysXConfig.h"
37#include "foundation/PxFlags.h"
38#include "foundation/PxBounds3.h"
39#include "foundation/PxBitUtils.h"
40#include "PxFiltering.h"
41#include "PxBroadPhase.h"
42#include "common/PxTolerancesScale.h"
43#include "task/PxTask.h"
44
45#if !PX_DOXYGEN
46namespace physx
47{
48#endif
49
50 class PxBroadPhaseCallback;
51 class PxCudaContextManager;
52
78
87{
88 enum Enum
89 {
91 eTGS
92 };
93};
94
101{
102 enum Enum
103 {
117
130 eENABLE_CCD = (1<<1),
131
152
160 eENABLE_PCM = (1 << 6),
161
171
183
200
209
219
233
234 /*\brief Enables the GPU dynamics pipeline
235
236 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.
237
238 Note that this flag is not mutable and must be set in PxSceneDesc at scene creation.
239 */
240 eENABLE_GPU_DYNAMICS = (1 << 13),
241
264
280
281 /*
282 \brief Disables GPU readback of articulation data when running on GPU.
283 Useful if your application only needs to communicate to the GPU via GPU buffers. Can be significantly faster
284 */
285 eSUPPRESS_READBACK = (1<<16),
286
287 /*
288 \brief Forces GPU readback of articulation data when user raise eSUPPRESS_READBACK.
289 */
290 eFORCE_READBACK = (1 << 17),
291
292 eMUTABLE_FLAGS = eENABLE_ACTIVE_ACTORS|eEXCLUDE_KINEMATICS_FROM_ACTIVE_ACTORS|eSUPPRESS_READBACK
293 };
294};
295
302PX_FLAGS_OPERATORS(PxSceneFlag::Enum,PxU32)
303
308
345
346PX_INLINE PxSceneLimits::PxSceneLimits() : //constructor sets to default
347 maxNbActors (0),
348 maxNbBodies (0),
349 maxNbStaticShapes (0),
350 maxNbDynamicShapes (0),
351 maxNbAggregates (0),
352 maxNbConstraints (0),
353 maxNbRegions (0),
354 maxNbBroadPhaseOverlaps (0)
355{
356}
357
362
364{
365 if(maxNbRegions>256) // max number of regions is currently limited
366 return false;
367
368 return true;
369}
370
371//#if PX_SUPPORT_GPU_PHYSX
377{
385 PxU32 maxSoftBodyContacts;
386 PxU32 maxFemClothContacts;
387 PxU32 maxParticleContacts;
388 PxU32 collisionStackSize;
389 PxU32 maxHairContacts;
390
392 tempBufferCapacity(16 * 1024 * 1024),
393 maxRigidContactCount(1024 * 512),
394 maxRigidPatchCount(1024 * 80),
395 heapCapacity(64 * 1024 * 1024),
396 foundLostPairsCapacity(256 * 1024),
399 maxSoftBodyContacts(1 * 1024 * 1024),
400 maxFemClothContacts(1 * 1024 * 1024),
401 maxParticleContacts(1*1024*1024),
402 collisionStackSize(64*1024*1024),
403 maxHairContacts(1 * 1024 * 1024)
404 {
405 }
406
407 PX_PHYSX_CORE_API bool isValid() const;
408};
409
410PX_INLINE bool PxgDynamicsMemoryConfig::isValid() const
411{
412 const bool isPowerOfTwo = PxIsPowerOfTwo(heapCapacity);
413 return isPowerOfTwo;
414}
415
416//#endif
417
426{
427public:
428
440
449
458
467
477 const void* filterShaderData;
478
487
498
508
517
526
535
544
551
562
571
582
599
613
622
629
637 PxCudaContextManager* cudaContextManager;
638
644 void* userData;
645
662
679
694
714
733
749
764
781
793
805
816
821
829
836
841
852
863
864private:
868 // For internal use only
869 PxTolerancesScale tolerancesScale;
874public:
884
893 PX_INLINE void setToDefault(const PxTolerancesScale& scale);
894
899 PX_INLINE bool isValid() const;
900
904 // For internal use only
905 PX_INLINE const PxTolerancesScale& getTolerancesScale() const { return tolerancesScale; }
909};
910
912 gravity (PxVec3(0.0f)),
913 simulationEventCallback (NULL),
914 contactModifyCallback (NULL),
915 ccdContactModifyCallback (NULL),
916
917 filterShaderData (NULL),
918 filterShaderDataSize (0),
919 filterShader (NULL),
920 filterCallback (NULL),
921
922 kineKineFilteringMode (PxPairFilteringMode::eDEFAULT),
923 staticKineFilteringMode (PxPairFilteringMode::eDEFAULT),
924
925 broadPhaseType (PxBroadPhaseType::ePABP),
926 broadPhaseCallback (NULL),
927
928 frictionType (PxFrictionType::ePATCH),
929 solverType (PxSolverType::ePGS),
930 bounceThresholdVelocity (0.2f * scale.speed),
931 frictionOffsetThreshold (0.04f * scale.length),
932 frictionCorrelationDistance (0.025f * scale.length),
933
934 flags (PxSceneFlag::eENABLE_PCM),
935
936 cpuDispatcher (NULL),
937 cudaContextManager (NULL),
938
939 userData (NULL),
940
941 solverBatchSize (128),
942 solverArticulationBatchSize (16),
943
944 nbContactDataBlocks (0),
945 maxNbContactDataBlocks (1<<16),
946 maxBiasCoefficient (PX_MAX_F32),
947 contactReportStreamBufferSize (8192),
948 ccdMaxPasses (1),
949 ccdThreshold (PX_MAX_F32),
950 ccdMaxSeparation (0.04f * scale.length),
951 wakeCounterResetValue (20.0f*0.02f),
952 sanityBounds (PxBounds3(PxVec3(-PX_MAX_BOUNDS_EXTENTS), PxVec3(PX_MAX_BOUNDS_EXTENTS))),
953 gpuMaxNumPartitions (8),
954 gpuMaxNumStaticPartitions (16),
955 gpuComputeVersion (0),
956 contactPairSlabSize (256),
957 sceneQuerySystem (NULL),
958 tolerancesScale (scale)
959{
960}
961
963{
964 *this = PxSceneDesc(scale);
965}
966
968{
970 return false;
971
972 if(!filterShader)
973 return false;
974
975 if( ((filterShaderDataSize == 0) && (filterShaderData != NULL)) ||
976 ((filterShaderDataSize > 0) && (filterShaderData == NULL)) )
977 return false;
978
979 if(!limits.isValid())
980 return false;
981
982 if(bounceThresholdVelocity <= 0.0f)
983 return false;
984 if(frictionOffsetThreshold < 0.0f)
985 return false;
987 return false;
988
989 if(maxBiasCoefficient < 0.0f)
990 return false;
991
992 if(!ccdMaxPasses)
993 return false;
994 if(ccdThreshold <= 0.0f)
995 return false;
996 if(ccdMaxSeparation < 0.0f)
997 return false;
998
999 if(!cpuDispatcher)
1000 return false;
1001
1003 return false;
1004
1006 return false;
1007
1008 if(wakeCounterResetValue <= 0.0f)
1009 return false;
1010
1011 if(!sanityBounds.isValid())
1012 return false;
1013
1014#if PX_SUPPORT_GPU_PHYSX
1015 if(!PxIsPowerOfTwo(gpuMaxNumPartitions))
1016 return false;
1017 if(gpuMaxNumPartitions > 32)
1018 return false;
1019 if (gpuMaxNumPartitions == 0)
1020 return false;
1021 if(!gpuDynamicsConfig.isValid())
1022 return false;
1023
1024 if (flags & PxSceneFlag::eSUPPRESS_READBACK)
1025 {
1026 if(!(flags & PxSceneFlag::eENABLE_GPU_DYNAMICS && broadPhaseType == PxBroadPhaseType::eGPU))
1027 return false;
1028 }
1029#endif
1030
1031 if(contactPairSlabSize == 0)
1032 return false;
1033
1034 return true;
1035}
1036
1037#if !PX_DOXYGEN
1038} // namespace physx
1039#endif
1040
1042#endif
Class representing 3D range or axis aligned bounding box.
Definition PxBounds3.h:58
PX_CUDA_CALLABLE PX_FORCE_INLINE bool isValid() const
Definition PxBounds3.h:482
Broad-phase callback to receive broad-phase related events.
Definition PxScene.h:144
An interface class that the user can implement in order to modify CCD contact constraints.
Definition PxContactModifyCallback.h:500
An interface class that the user can implement in order to modify contact constraints.
Definition PxContactModifyCallback.h:459
A CpuDispatcher is responsible for scheduling the execution of tasks passed to it by the SDK.
Definition PxCpuDispatcher.h:50
Container for bitfield flag variables associated with a specific enum type.
Definition PxFlags.h:73
Descriptor class for scenes. See #PxScene.
Definition PxSceneDesc.h:426
PX_INLINE bool isValid() const
Returns true if the descriptor is valid.
Definition PxSceneDesc.h:967
PxU32 gpuMaxNumStaticPartitions
Limitation for the number of static rigid body partitions in the GPU dynamics pipeline....
Definition PxSceneDesc.h:835
PxSceneQuerySystem * sceneQuerySystem
The scene query sub-system for the scene.
Definition PxSceneDesc.h:862
PxCCDContactModifyCallback * ccdContactModifyCallback
Possible asynchronous callback for contact modification.
Definition PxSceneDesc.h:466
PxBroadPhaseType::Enum broadPhaseType
Selects the broad-phase algorithm to use.
Definition PxSceneDesc.h:534
PxPairFilteringMode::Enum kineKineFilteringMode
Filtering mode for kinematic-kinematic pairs in the broadphase.
Definition PxSceneDesc.h:516
PxU32 maxNbContactDataBlocks
Setting to define the maximum number of 16K blocks that can be allocated to store contact,...
Definition PxSceneDesc.h:713
PxSimulationEventCallback * simulationEventCallback
Possible notification callback.
Definition PxSceneDesc.h:448
PxReal ccdThreshold
CCD threshold.
Definition PxSceneDesc.h:780
void * userData
Will be copied to PxScene::userData.
Definition PxSceneDesc.h:644
PxU32 gpuComputeVersion
Defines which compute version the GPU dynamics should target. DO NOT MODIFY.
Definition PxSceneDesc.h:840
PxgDynamicsMemoryConfig gpuDynamicsConfig
The pre-allocations performed in the GPU dynamics pipeline.
Definition PxSceneDesc.h:820
PxContactModifyCallback * contactModifyCallback
Possible asynchronous callback for contact modification.
Definition PxSceneDesc.h:457
const void * filterShaderData
Shared global filter data which will get passed into the filter shader.
Definition PxSceneDesc.h:477
PxVec3 gravity
Gravity vector.
Definition PxSceneDesc.h:439
PxU32 contactReportStreamBufferSize
Size of the contact report stream (in bytes).
Definition PxSceneDesc.h:748
PxReal frictionCorrelationDistance
Friction correlation distance used to decide whether contacts are close enough to be merged into a si...
Definition PxSceneDesc.h:612
PxU32 ccdMaxPasses
Maximum number of CCD passes.
Definition PxSceneDesc.h:763
PxSolverType::Enum solverType
Selects the solver algorithm to use.
Definition PxSceneDesc.h:570
PxU32 filterShaderDataSize
Size (in bytes) of the shared global filter data filterShaderData.
Definition PxSceneDesc.h:486
PxSimulationFilterShader filterShader
The custom filter shader to use for collision filtering.
Definition PxSceneDesc.h:497
PxSimulationFilterCallback * filterCallback
A custom collision filter callback which can be used to implement more complex filtering operations w...
Definition PxSceneDesc.h:507
PxBroadPhaseCallback * broadPhaseCallback
Broad-phase callback.
Definition PxSceneDesc.h:543
PxReal wakeCounterResetValue
The wake counter reset value.
Definition PxSceneDesc.h:804
PxU32 nbContactDataBlocks
Setting to define the number of 16K blocks that will be initially reserved to store contact,...
Definition PxSceneDesc.h:693
PxBounds3 sanityBounds
The bounds used to sanity check user-set positions of actors and articulation links.
Definition PxSceneDesc.h:815
PxReal bounceThresholdVelocity
A contact with a relative velocity below this will not bounce. A typical value for simulation....
Definition PxSceneDesc.h:581
PX_INLINE PxSceneDesc(const PxTolerancesScale &scale)
constructor sets to default.
Definition PxSceneDesc.h:911
PxCpuDispatcher * cpuDispatcher
The CPU task dispatcher for the scene.
Definition PxSceneDesc.h:628
PxSceneLimits limits
Expected scene limits.
Definition PxSceneDesc.h:550
PxFrictionType::Enum frictionType
Selects the friction algorithm to use for simulation.
Definition PxSceneDesc.h:561
PxU32 solverArticulationBatchSize
Defines the number of articulations required to spawn a separate rigid body solver island task chain.
Definition PxSceneDesc.h:678
PxPairFilteringMode::Enum staticKineFilteringMode
Filtering mode for static-kinematic pairs in the broadphase.
Definition PxSceneDesc.h:525
PxCudaContextManager * cudaContextManager
The CUDA context manager for the scene.
Definition PxSceneDesc.h:637
PxReal maxBiasCoefficient
The maximum bias coefficient used in the constraint solver.
Definition PxSceneDesc.h:732
PxU32 contactPairSlabSize
Defines the size of a contact pool slab. Contact pairs and associated data are allocated using a pool...
Definition PxSceneDesc.h:851
PxU32 solverBatchSize
Defines the number of actors required to spawn a separate rigid body solver island task chain.
Definition PxSceneDesc.h:661
PxU32 gpuMaxNumPartitions
Limitation for the partitions in the GPU dynamics pipeline. This variable must be power of 2....
Definition PxSceneDesc.h:828
PxSceneFlags flags
Flags used to select scene options.
Definition PxSceneDesc.h:621
PxReal ccdMaxSeparation
A threshold for speculative CCD. Used to control whether bias, restitution or a combination of the tw...
Definition PxSceneDesc.h:792
PxReal frictionOffsetThreshold
A threshold of contact separation distance used to decide if a contact point will experience friction...
Definition PxSceneDesc.h:598
Class used to retrieve limits(e.g. maximum number of bodies) for a scene. The limits are used as a hi...
Definition PxSceneDesc.h:318
PxU32 maxNbConstraints
Expected maximum number of constraint shaders.
Definition PxSceneDesc.h:325
PX_INLINE PxSceneLimits()
constructor sets to default
Definition PxSceneDesc.h:346
PxU32 maxNbStaticShapes
Expected maximum number of static shapes.
Definition PxSceneDesc.h:322
PxU32 maxNbDynamicShapes
Expected maximum number of dynamic shapes.
Definition PxSceneDesc.h:323
PX_INLINE bool isValid() const
Returns true if the descriptor is valid.
Definition PxSceneDesc.h:363
PxU32 maxNbRegions
Expected maximum number of broad-phase regions.
Definition PxSceneDesc.h:326
PxU32 maxNbActors
Expected maximum number of actors.
Definition PxSceneDesc.h:320
PxU32 maxNbBroadPhaseOverlaps
Expected maximum number of broad-phase overlaps.
Definition PxSceneDesc.h:327
PxU32 maxNbBodies
Expected maximum number of dynamic rigid bodies.
Definition PxSceneDesc.h:321
PX_INLINE void setToDefault()
(re)sets the structure to the default
Definition PxSceneDesc.h:358
PxU32 maxNbAggregates
Expected maximum number of aggregates.
Definition PxSceneDesc.h:324
Descriptor class for scene query system. See #PxSceneQuerySystem.
Definition PxSceneQueryDesc.h:145
PX_INLINE bool isValid() const
Returns true if the descriptor is valid.
Definition PxSceneQueryDesc.h:312
PX_INLINE void setToDefault()
(re)sets the structure to the default.
Definition PxSceneQueryDesc.h:307
Scene-queries external sub-system for PxScene-based objects.
Definition PxSceneQuerySystem.h:421
An interface class that the user can implement in order to receive simulation events.
Definition PxSimulationEventCallback.h:792
Filter callback to specify handling of collision pairs.
Definition PxFiltering.h:633
Class to define the scale at which simulation runs. Most simulation tolerances are calculated in term...
Definition PxTolerancesScale.h:53
3 Element vector class.
Definition PxVec3.h:50
#define PX_INLINE
Definition PxPreprocessor.h:320
Sorts an array of objects in ascending order, assuming that the predicate implements the < operator:
Definition PxBoxController.h:39
PxFlags< PxSceneFlag::Enum, PxU32 > PxSceneFlags
collection of set bits defined in PxSceneFlag.
Definition PxSceneDesc.h:301
PxFilterFlags(* PxSimulationFilterShader)(PxFilterObjectAttributes attributes0, PxFilterData filterData0, PxFilterObjectAttributes attributes1, PxFilterData filterData1, PxPairFlags &pairFlags, const void *constantBlock, PxU32 constantBlockSize)
Filter method to specify how a pair of potentially colliding objects should be processed.
Definition PxFiltering.h:604
Broad phase algorithm used in the simulation.
Definition PxBroadPhase.h:77
Enum
Definition PxBroadPhase.h:79
@ eGPU
GPU broad phase.
Definition PxBroadPhase.h:84
Enum for selecting the friction algorithm used for simulation.
Definition PxSceneDesc.h:69
Enum
Definition PxSceneDesc.h:71
@ eFRICTION_COUNT
The total number of friction models supported by the SDK.
Definition PxSceneDesc.h:75
@ ePATCH
Select default patch-friction model.
Definition PxSceneDesc.h:72
@ eTWO_DIRECTIONAL
Select two directional per-contact friction model.
Definition PxSceneDesc.h:74
@ eONE_DIRECTIONAL
Select one directional per-contact friction model.
Definition PxSceneDesc.h:73
Definition PxFiltering.h:715
Enum
Definition PxFiltering.h:717
flags for configuring properties of the scene
Definition PxSceneDesc.h:101
Enum
Definition PxSceneDesc.h:103
@ eENABLE_AVERAGE_POINT
Enables average points in contact manifolds.
Definition PxSceneDesc.h:218
@ eENABLE_ACTIVE_ACTORS
Enable Active Actors Notification.
Definition PxSceneDesc.h:116
@ eENABLE_ENHANCED_DETERMINISM
Provides improved determinism at the expense of performance.
Definition PxSceneDesc.h:263
@ eDISABLE_CONTACT_REPORT_BUFFER_RESIZE
Disable contact report buffer resize. Once the contact buffer is full, the rest of the contact report...
Definition PxSceneDesc.h:170
@ eDISABLE_CONTACT_CACHE
Disable contact cache.
Definition PxSceneDesc.h:182
@ eENABLE_STABILIZATION
Enables additional stabilization pass in solver.
Definition PxSceneDesc.h:208
@ eENABLE_FRICTION_EVERY_ITERATION
Controls processing friction in all solver iterations.
Definition PxSceneDesc.h:279
@ eDISABLE_CCD_RESWEEP
Enables a simplified swept integration strategy, which sacrifices some accuracy for improved performa...
Definition PxSceneDesc.h:151
@ eENABLE_PCM
Enable GJK-based distance collision detection system.
Definition PxSceneDesc.h:160
@ eENABLE_CCD
Enables a second broad phase check after integration that makes it possible to prevent objects from t...
Definition PxSceneDesc.h:130
@ eREQUIRE_RW_LOCK
Require scene-level locking.
Definition PxSceneDesc.h:199
@ eEXCLUDE_KINEMATICS_FROM_ACTIVE_ACTORS
Do not report kinematics in list of active actors.
Definition PxSceneDesc.h:232
Enum for selecting the type of solver used for the simulation.
Definition PxSceneDesc.h:87
Enum
Definition PxSceneDesc.h:89
@ eTGS
Default Temporal Gauss-Seidel solver.
Definition PxSceneDesc.h:91
@ ePGS
Projected Gauss-Seidel iterative solver.
Definition PxSceneDesc.h:90
Sizes of pre-allocated buffers use for GPU dynamics.
Definition PxSceneDesc.h:377
PxU32 heapCapacity
Initial capacity of the GPU and pinned host memory heaps. Additional memory will be allocated if more...
Definition PxSceneDesc.h:381
PxU32 maxRigidContactCount
Size of contact stream buffer allocated in pinned host memory. This is double-buffered so total alloc...
Definition PxSceneDesc.h:379
PxU32 foundLostAggregatePairsCapacity
Capacity of found and lost buffers in aggregate system allocated in GPU global memory....
Definition PxSceneDesc.h:383
PxU32 totalAggregatePairsCapacity
Capacity of total number of aggregate pairs allocated in GPU global memory.
Definition PxSceneDesc.h:384
PxU32 maxRigidPatchCount
Size of the contact patch stream buffer allocated in pinned host memory. This is double-buffered so t...
Definition PxSceneDesc.h:380
PxU32 foundLostPairsCapacity
Capacity of found and lost buffers allocated in GPU global memory. This is used for the found/lost pa...
Definition PxSceneDesc.h:382
PxU32 tempBufferCapacity
Capacity of temp buffer allocated in pinned host memory.
Definition PxSceneDesc.h:378