NVIDIA(R) PhysX(R) SDK 3.4 API Reference: PxSceneDesc.h Source File

NVIDIA PhysX SDK 3.4 API

PxSceneDesc.h

Go to the documentation of this file.
00001 // This code contains NVIDIA Confidential Information and is disclosed to you
00002 // under a form of NVIDIA software license agreement provided separately to you.
00003 //
00004 // Notice
00005 // NVIDIA Corporation and its licensors retain all intellectual property and
00006 // proprietary rights in and to this software and related documentation and
00007 // any modifications thereto. Any use, reproduction, disclosure, or
00008 // distribution of this software and related documentation without an express
00009 // license agreement from NVIDIA Corporation is strictly prohibited.
00010 //
00011 // ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
00012 // NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
00013 // THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
00014 // MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
00015 //
00016 // Information and code furnished is believed to be accurate and reliable.
00017 // However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
00018 // information or for any infringement of patents or other rights of third parties that may
00019 // result from its use. No license is granted by implication or otherwise under any patent
00020 // or patent rights of NVIDIA Corporation. Details are subject to change without notice.
00021 // This code supersedes and replaces all information previously supplied.
00022 // NVIDIA Corporation products are not authorized for use as critical
00023 // components in life support devices or systems without express written approval of
00024 // NVIDIA Corporation.
00025 //
00026 // Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved.
00027 // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
00028 // Copyright (c) 2001-2004 NovodeX AG. All rights reserved.  
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         /*\brief Enables the GPU dynamics pipeline
00328 
00329         When set to true, a CUDA 2.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.
00330 
00331         Note that this flag is not mutable and must be set in PxSceneDesc at scene creation.
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() :  //constructor sets to default
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)    // max number of regions is currently limited
00439         return false;
00440 
00441     return true;
00442 }
00443 
00444 //#if PX_SUPPORT_GPU_PHYSX
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 //#endif
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 
00654     PxReal solverOffsetSlop;
00655 
00661     PxSceneFlags            flags;
00662 
00668     PxCpuDispatcher*        cpuDispatcher;
00669 
00677     PxGpuDispatcher*        gpuDispatcher;
00678 
00684     PxPruningStructureType::Enum    staticStructure;
00685 
00689     PxPruningStructureType::Enum    dynamicStructure;
00690 
00708     PxU32                   dynamicTreeRebuildRateHint;
00709 
00715     void*                   userData;
00716 
00730     PxU32                   solverBatchSize;
00731 
00745     PxU32                   nbContactDataBlocks;
00746 
00765     PxU32                   maxNbContactDataBlocks;
00766 
00783     PxReal                  maxBiasCoefficient;
00784 
00798     PxU32                   contactReportStreamBufferSize;
00799 
00811     PxU32                   ccdMaxPasses;
00812 
00823     PxReal                  wakeCounterResetValue;
00824 
00834     PxBounds3               sanityBounds;
00835 
00839     PxgDynamicsMemoryConfig gpuDynamicsConfig;
00840 
00847     PxU32                   gpuMaxNumPartitions;
00848 
00852     PxU32                   gpuComputeVersion;
00853 
00854 private:
00858     // For internal use only
00859     PxTolerancesScale       tolerancesScale;
00865 public:
00874     PX_INLINE PxSceneDesc(const PxTolerancesScale& scale);
00875 
00884     PX_INLINE void setToDefault(const PxTolerancesScale& scale);
00885 
00890     PX_INLINE bool isValid() const;
00891 
00895     // For internal use only
00896     PX_INLINE const PxTolerancesScale& getTolerancesScale() const { return tolerancesScale; }
00900 };
00901 
00902 PX_INLINE PxSceneDesc::PxSceneDesc(const PxTolerancesScale& scale):
00903     gravity                             (PxVec3(0.0f)),
00904     simulationEventCallback             (NULL),
00905     contactModifyCallback               (NULL),
00906     ccdContactModifyCallback            (NULL),
00907 
00908     filterShaderData                    (NULL),
00909     filterShaderDataSize                (0),
00910     filterShader                        (NULL),
00911     filterCallback                      (NULL),
00912     broadPhaseType                      (PxBroadPhaseType::eSAP),
00913     broadPhaseCallback                  (NULL),
00914 
00915     frictionType                        (PxFrictionType::ePATCH),
00916     bounceThresholdVelocity             (0.2f * scale.speed),
00917     frictionOffsetThreshold             (0.04f * scale.length),
00918     ccdMaxSeparation                    (0.04f * scale.length),
00919     solverOffsetSlop                    (0.0f),
00920 
00921     flags                               (PxSceneFlag::eENABLE_PCM),
00922 
00923     cpuDispatcher                       (NULL),
00924     gpuDispatcher                       (NULL),
00925 
00926     staticStructure                     (PxPruningStructureType::eDYNAMIC_AABB_TREE),
00927     dynamicStructure                    (PxPruningStructureType::eDYNAMIC_AABB_TREE),
00928     dynamicTreeRebuildRateHint          (100),
00929 
00930     userData                            (NULL),
00931 
00932     solverBatchSize                     (128),
00933 
00934     nbContactDataBlocks                 (0),
00935     maxNbContactDataBlocks              (1<<16),
00936     maxBiasCoefficient                  (PX_MAX_F32),
00937     contactReportStreamBufferSize       (8192),
00938     ccdMaxPasses                        (1),
00939     wakeCounterResetValue               (20.0f*0.02f),
00940     sanityBounds                        (PxBounds3(PxVec3(-PX_MAX_BOUNDS_EXTENTS), PxVec3(PX_MAX_BOUNDS_EXTENTS))),
00941 
00942     gpuMaxNumPartitions                 (8),
00943     gpuComputeVersion                   (0),
00944 
00945     tolerancesScale                     (scale)
00946 {
00947 }
00948 
00949 PX_INLINE void PxSceneDesc::setToDefault(const PxTolerancesScale& scale)
00950 {
00951     *this = PxSceneDesc(scale);
00952 }
00953 
00954 PX_INLINE bool PxSceneDesc::isValid() const
00955 {
00956     if(!filterShader)
00957         return false;
00958 
00959     if( ((filterShaderDataSize == 0) && (filterShaderData != NULL)) ||
00960         ((filterShaderDataSize > 0) && (filterShaderData == NULL)) )
00961         return false;
00962 
00963     if(!limits.isValid())
00964         return false;
00965 
00966     if(staticStructure!=PxPruningStructureType::eSTATIC_AABB_TREE && staticStructure!=PxPruningStructureType::eDYNAMIC_AABB_TREE)
00967         return false;
00968 
00969     if(dynamicTreeRebuildRateHint < 4)
00970         return false;
00971 
00972     if(bounceThresholdVelocity < 0.0f)
00973         return false;
00974     if(frictionOffsetThreshold < 0.0f)
00975         return false;
00976     if(ccdMaxSeparation < 0.0f)
00977         return false;
00978 
00979     if(!cpuDispatcher)
00980         return false;
00981 
00982     if(!contactReportStreamBufferSize)
00983         return false;
00984 
00985     if(maxNbContactDataBlocks < nbContactDataBlocks)
00986         return false;
00987 
00988     if(wakeCounterResetValue <= 0.0f)
00989         return false;
00990 
00991     //Adaptive force and stabilization are incompatible. You can only have one or the other
00992     if((flags & (PxSceneFlag::eADAPTIVE_FORCE | PxSceneFlag::eENABLE_STABILIZATION)) == (PxSceneFlag::eADAPTIVE_FORCE | PxSceneFlag::eENABLE_STABILIZATION))
00993         return false;
00994 
00995     if(!sanityBounds.isValid())
00996         return false;
00997 
00998     //gpuMaxNumPartitions must be power of 2
00999     if((gpuMaxNumPartitions&(gpuMaxNumPartitions - 1)) != 0)
01000         return false;
01001     if (gpuMaxNumPartitions > 32)
01002         return false;
01003 
01004     return true;
01005 }
01006 
01007 
01008 #if !PX_DOXYGEN
01009 } // namespace physx
01010 #endif
01011 
01013 #endif


Copyright © 2008-2017 NVIDIA Corporation, 2701 San Tomas Expressway, Santa Clara, CA 95050 U.S.A. All rights reserved. www.nvidia.com