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 
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     // For internal use only
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     // For internal use only
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     //Adaptive force and stabilization are incompatible. You can only have one or the other
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     //gpuMaxNumPartitions must be power of 2
00968     if((gpuMaxNumPartitions&(gpuMaxNumPartitions - 1)) != 0)
00969         return false;
00970 #endif
00971 
00972     return true;
00973 }
00974 
00975 
00976 #if !PX_DOXYGEN
00977 } // namespace physx
00978 #endif
00979 
00981 #endif


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