00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #ifndef PX_PHYSICS_NX_SCENEDESC
00032 #define PX_PHYSICS_NX_SCENEDESC
00033
00037 #include "PxPhysXConfig.h"
00038 #include "foundation/PxFlags.h"
00039 #include "foundation/PxBounds3.h"
00040 #include "PxFiltering.h"
00041 #include "PxBroadPhase.h"
00042 #include "common/PxTolerancesScale.h"
00043 #include "task/PxTask.h"
00044
00045 #if !PX_DOXYGEN
00046 namespace physx
00047 {
00048 #endif
00049
00067 struct PxPruningStructureType
00068 {
00069 enum Enum
00070 {
00071 eNONE,
00072 eDYNAMIC_AABB_TREE,
00073 eSTATIC_AABB_TREE,
00074
00075 eLAST
00076 };
00077 };
00078
00079
00095 struct PxFrictionType
00096 {
00097 enum Enum
00098 {
00099 ePATCH,
00100 eONE_DIRECTIONAL,
00101 eTWO_DIRECTIONAL,
00102 eFRICTION_COUNT
00103 };
00104 };
00105
00112 struct PxSceneFlag
00113 {
00114 enum Enum
00115 {
00128 eENABLE_ACTIVE_ACTORS = (1<<0),
00129
00142 eENABLE_ACTIVETRANSFORMS PX_DEPRECATED = (1<<1),
00143
00156 eENABLE_CCD = (1<<2),
00157
00177 eDISABLE_CCD_RESWEEP = (1<<3),
00178
00179
00187 eADAPTIVE_FORCE = (1<<4),
00188
00189
00200 eENABLE_KINEMATIC_STATIC_PAIRS = (1<<5),
00201
00202
00213 eENABLE_KINEMATIC_PAIRS = (1<<6),
00214
00215
00223 eENABLE_PCM = (1 << 9),
00224
00233 eDISABLE_CONTACT_REPORT_BUFFER_RESIZE = (1 << 10),
00234
00245 eDISABLE_CONTACT_CACHE = (1 << 11),
00246
00247
00263 eREQUIRE_RW_LOCK = (1 << 12),
00264
00272 eENABLE_STABILIZATION = (1 << 14),
00273
00282 eENABLE_AVERAGE_POINT = (1 << 15),
00283
00297 eDEPRECATED_TRIGGER_TRIGGER_REPORTS = (1 << 16),
00298
00311 eEXCLUDE_KINEMATICS_FROM_ACTIVE_ACTORS = (1 << 17),
00312
00325 eSUPPRESS_EAGER_SCENE_QUERY_REFIT = (1 << 18),
00326
00327
00328
00329
00330
00331
00332
00333
00334
00335 eENABLE_GPU_DYNAMICS = (1 << 19),
00336
00359 eENABLE_ENHANCED_DETERMINISM = (1<<20),
00360
00361 eMUTABLE_FLAGS = eENABLE_ACTIVE_ACTORS|eENABLE_ACTIVETRANSFORMS|eEXCLUDE_KINEMATICS_FROM_ACTIVE_ACTORS
00362 };
00363 };
00364
00365
00371 typedef PxFlags<PxSceneFlag::Enum,PxU32> PxSceneFlags;
00372 PX_FLAGS_OPERATORS(PxSceneFlag::Enum,PxU32)
00373
00374
00375 class PxSimulationEventCallback;
00376 class PxContactModifyCallback;
00377 class PxCCDContactModifyCallback;
00378 class PxSimulationFilterCallback;
00379
00388 class PxSceneLimits
00389 {
00390 public:
00391 PxU32 maxNbActors;
00392 PxU32 maxNbBodies;
00393 PxU32 maxNbStaticShapes;
00394 PxU32 maxNbDynamicShapes;
00395 PxU32 maxNbAggregates;
00396 PxU32 maxNbConstraints;
00397 PxU32 maxNbRegions;
00398 PxU32 maxNbBroadPhaseOverlaps;
00399 PX_DEPRECATED PxU32 maxNbObjectsPerRegion;
00400
00404 PX_INLINE PxSceneLimits();
00405
00409 PX_INLINE void setToDefault();
00410
00415 PX_INLINE bool isValid() const;
00416 };
00417
00418 PX_INLINE PxSceneLimits::PxSceneLimits() :
00419 maxNbActors (0),
00420 maxNbBodies (0),
00421 maxNbStaticShapes (0),
00422 maxNbDynamicShapes (0),
00423 maxNbAggregates (0),
00424 maxNbConstraints (0),
00425 maxNbRegions (0),
00426 maxNbBroadPhaseOverlaps (0),
00427 maxNbObjectsPerRegion (0)
00428 {
00429 }
00430
00431 PX_INLINE void PxSceneLimits::setToDefault()
00432 {
00433 *this = PxSceneLimits();
00434 }
00435
00436 PX_INLINE bool PxSceneLimits::isValid() const
00437 {
00438 if(maxNbRegions>256)
00439 return false;
00440
00441 return true;
00442 }
00443
00444
00449 struct PxgDynamicsMemoryConfig
00450 {
00451 PxU32 constraintBufferCapacity;
00452 PxU32 contactBufferCapacity;
00453 PxU32 tempBufferCapacity;
00454 PxU32 contactStreamSize;
00455 PxU32 patchStreamSize;
00456 PxU32 forceStreamCapacity;
00457 PxU32 heapCapacity;
00458 PxU32 foundLostPairsCapacity;
00459
00460 PxgDynamicsMemoryConfig() :
00461 constraintBufferCapacity(32 * 1024 * 1024),
00462 contactBufferCapacity(24 * 1024 * 1024),
00463 tempBufferCapacity(16 * 1024 * 1024),
00464 contactStreamSize(1024 * 512),
00465 patchStreamSize(1024 * 80),
00466 forceStreamCapacity(1 * 1024 * 1024),
00467 heapCapacity(64 * 1024 * 1024),
00468 foundLostPairsCapacity(256 * 1024)
00469 {
00470 }
00471 };
00472
00473
00474
00482 class PxSceneDesc
00483 {
00484 public:
00485
00496 PxVec3 gravity;
00497
00508 PxSimulationEventCallback* simulationEventCallback;
00509
00517 PxContactModifyCallback* contactModifyCallback;
00518
00526 PxCCDContactModifyCallback* ccdContactModifyCallback;
00527
00537 const void* filterShaderData;
00538
00546 PxU32 filterShaderDataSize;
00547
00557 PxSimulationFilterShader filterShader;
00558
00567 PxSimulationFilterCallback* filterCallback;
00568
00576 PxBroadPhaseType::Enum broadPhaseType;
00577
00588 PxBroadPhaseCallback* broadPhaseCallback;
00589
00595 PxSceneLimits limits;
00596
00607 PxFrictionType::Enum frictionType;
00608
00618 PxReal bounceThresholdVelocity;
00619
00633 PxReal frictionOffsetThreshold;
00634
00644 PxReal ccdMaxSeparation;
00645
00651 PxSceneFlags flags;
00652
00658 PxCpuDispatcher* cpuDispatcher;
00659
00667 PxGpuDispatcher* gpuDispatcher;
00668
00674 PxPruningStructureType::Enum staticStructure;
00675
00679 PxPruningStructureType::Enum dynamicStructure;
00680
00698 PxU32 dynamicTreeRebuildRateHint;
00699
00705 void* userData;
00706
00720 PxU32 solverBatchSize;
00721
00735 PxU32 nbContactDataBlocks;
00736
00755 PxU32 maxNbContactDataBlocks;
00756
00770 PxU32 contactReportStreamBufferSize;
00771
00783 PxU32 ccdMaxPasses;
00784
00795 PxReal wakeCounterResetValue;
00796
00806 PxBounds3 sanityBounds;
00807
00811 PxgDynamicsMemoryConfig gpuDynamicsConfig;
00812
00817 PxU32 gpuMaxNumPartitions;
00818
00822 PxU32 gpuComputeVersion;
00823
00824 private:
00828
00829 PxTolerancesScale tolerancesScale;
00835 public:
00844 PX_INLINE PxSceneDesc(const PxTolerancesScale& scale);
00845
00854 PX_INLINE void setToDefault(const PxTolerancesScale& scale);
00855
00860 PX_INLINE bool isValid() const;
00861
00865
00866 PX_INLINE const PxTolerancesScale& getTolerancesScale() const { return tolerancesScale; }
00870 };
00871
00872 PX_INLINE PxSceneDesc::PxSceneDesc(const PxTolerancesScale& scale):
00873 gravity (PxVec3(0.0f)),
00874 simulationEventCallback (NULL),
00875 contactModifyCallback (NULL),
00876 ccdContactModifyCallback (NULL),
00877
00878 filterShaderData (NULL),
00879 filterShaderDataSize (0),
00880 filterShader (NULL),
00881 filterCallback (NULL),
00882 broadPhaseType (PxBroadPhaseType::eSAP),
00883 broadPhaseCallback (NULL),
00884
00885 frictionType (PxFrictionType::ePATCH),
00886 bounceThresholdVelocity (0.2f * scale.speed),
00887 frictionOffsetThreshold (0.04f * scale.length),
00888 ccdMaxSeparation (0.04f * scale.length),
00889
00890 flags (PxSceneFlag::eENABLE_PCM),
00891
00892 cpuDispatcher (NULL),
00893 gpuDispatcher (NULL),
00894
00895 staticStructure (PxPruningStructureType::eDYNAMIC_AABB_TREE),
00896 dynamicStructure (PxPruningStructureType::eDYNAMIC_AABB_TREE),
00897 dynamicTreeRebuildRateHint (100),
00898
00899 userData (NULL),
00900
00901 solverBatchSize (128),
00902
00903 nbContactDataBlocks (0),
00904 maxNbContactDataBlocks (1<<16),
00905 contactReportStreamBufferSize (8192),
00906 ccdMaxPasses (1),
00907 wakeCounterResetValue (20.0f*0.02f),
00908 sanityBounds (PxBounds3(PxVec3(-PX_MAX_BOUNDS_EXTENTS), PxVec3(PX_MAX_BOUNDS_EXTENTS))),
00909 #if PX_SUPPORT_GPU_PHYSX
00910 gpuMaxNumPartitions (8),
00911 gpuComputeVersion (0),
00912 #endif
00913 tolerancesScale (scale)
00914 {
00915 }
00916
00917 PX_INLINE void PxSceneDesc::setToDefault(const PxTolerancesScale& scale)
00918 {
00919 *this = PxSceneDesc(scale);
00920 }
00921
00922 PX_INLINE bool PxSceneDesc::isValid() const
00923 {
00924 if(!filterShader)
00925 return false;
00926
00927 if( ((filterShaderDataSize == 0) && (filterShaderData != NULL)) ||
00928 ((filterShaderDataSize > 0) && (filterShaderData == NULL)) )
00929 return false;
00930
00931 if(!limits.isValid())
00932 return false;
00933
00934 if(staticStructure!=PxPruningStructureType::eSTATIC_AABB_TREE && staticStructure!=PxPruningStructureType::eDYNAMIC_AABB_TREE)
00935 return false;
00936
00937 if(dynamicTreeRebuildRateHint < 4)
00938 return false;
00939
00940 if(bounceThresholdVelocity < 0.0f)
00941 return false;
00942 if(frictionOffsetThreshold < 0.0f)
00943 return false;
00944 if(ccdMaxSeparation < 0.0f)
00945 return false;
00946
00947 if(!cpuDispatcher)
00948 return false;
00949
00950 if(!contactReportStreamBufferSize)
00951 return false;
00952
00953 if(maxNbContactDataBlocks < nbContactDataBlocks)
00954 return false;
00955
00956 if(wakeCounterResetValue <= 0.0f)
00957 return false;
00958
00959
00960 if((flags & (PxSceneFlag::eADAPTIVE_FORCE | PxSceneFlag::eENABLE_STABILIZATION)) == (PxSceneFlag::eADAPTIVE_FORCE | PxSceneFlag::eENABLE_STABILIZATION))
00961 return false;
00962
00963 if(!sanityBounds.isValid())
00964 return false;
00965
00966 #if PX_SUPPORT_GPU_PHYSX
00967
00968 if((gpuMaxNumPartitions&(gpuMaxNumPartitions - 1)) != 0)
00969 return false;
00970 #endif
00971
00972 return true;
00973 }
00974
00975
00976 #if !PX_DOXYGEN
00977 }
00978 #endif
00979
00981 #endif