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 
00819     PxU32                   gpuMaxNumPartitions;
00820 
00824     PxU32                   gpuComputeVersion;
00825 
00826 private:
00830     // For internal use only
00831     PxTolerancesScale       tolerancesScale;
00837 public:
00846     PX_INLINE PxSceneDesc(const PxTolerancesScale& scale);
00847 
00856     PX_INLINE void setToDefault(const PxTolerancesScale& scale);
00857 
00862     PX_INLINE bool isValid() const;
00863 
00867     // For internal use only
00868     PX_INLINE const PxTolerancesScale& getTolerancesScale() const { return tolerancesScale; }
00872 };
00873 
00874 PX_INLINE PxSceneDesc::PxSceneDesc(const PxTolerancesScale& scale):
00875     gravity                             (PxVec3(0.0f)),
00876     simulationEventCallback             (NULL),
00877     contactModifyCallback               (NULL),
00878     ccdContactModifyCallback            (NULL),
00879 
00880     filterShaderData                    (NULL),
00881     filterShaderDataSize                (0),
00882     filterShader                        (NULL),
00883     filterCallback                      (NULL),
00884     broadPhaseType                      (PxBroadPhaseType::eSAP),
00885     broadPhaseCallback                  (NULL),
00886 
00887     frictionType                        (PxFrictionType::ePATCH),
00888     bounceThresholdVelocity             (0.2f * scale.speed),
00889     frictionOffsetThreshold             (0.04f * scale.length),
00890     ccdMaxSeparation                    (0.04f * scale.length),
00891 
00892     flags                               (PxSceneFlag::eENABLE_PCM),
00893 
00894     cpuDispatcher                       (NULL),
00895     gpuDispatcher                       (NULL),
00896 
00897     staticStructure                     (PxPruningStructureType::eDYNAMIC_AABB_TREE),
00898     dynamicStructure                    (PxPruningStructureType::eDYNAMIC_AABB_TREE),
00899     dynamicTreeRebuildRateHint          (100),
00900 
00901     userData                            (NULL),
00902 
00903     solverBatchSize                     (128),
00904 
00905     nbContactDataBlocks                 (0),
00906     maxNbContactDataBlocks              (1<<16),
00907     contactReportStreamBufferSize       (8192),
00908     ccdMaxPasses                        (1),
00909     wakeCounterResetValue               (20.0f*0.02f),
00910     sanityBounds                        (PxBounds3(PxVec3(-PX_MAX_BOUNDS_EXTENTS), PxVec3(PX_MAX_BOUNDS_EXTENTS))),
00911 #if PX_SUPPORT_GPU_PHYSX
00912     gpuMaxNumPartitions                 (8),
00913     gpuComputeVersion                   (0),
00914 #endif
00915     tolerancesScale                     (scale)
00916 {
00917 }
00918 
00919 PX_INLINE void PxSceneDesc::setToDefault(const PxTolerancesScale& scale)
00920 {
00921     *this = PxSceneDesc(scale);
00922 }
00923 
00924 PX_INLINE bool PxSceneDesc::isValid() const
00925 {
00926     if(!filterShader)
00927         return false;
00928 
00929     if( ((filterShaderDataSize == 0) && (filterShaderData != NULL)) ||
00930         ((filterShaderDataSize > 0) && (filterShaderData == NULL)) )
00931         return false;
00932 
00933     if(!limits.isValid())
00934         return false;
00935 
00936     if(staticStructure!=PxPruningStructureType::eSTATIC_AABB_TREE && staticStructure!=PxPruningStructureType::eDYNAMIC_AABB_TREE)
00937         return false;
00938 
00939     if(dynamicTreeRebuildRateHint < 4)
00940         return false;
00941 
00942     if(bounceThresholdVelocity < 0.0f)
00943         return false;
00944     if(frictionOffsetThreshold < 0.0f)
00945         return false;
00946     if(ccdMaxSeparation < 0.0f)
00947         return false;
00948 
00949     if(!cpuDispatcher)
00950         return false;
00951 
00952     if(!contactReportStreamBufferSize)
00953         return false;
00954 
00955     if(maxNbContactDataBlocks < nbContactDataBlocks)
00956         return false;
00957 
00958     if(wakeCounterResetValue <= 0.0f)
00959         return false;
00960 
00961     //Adaptive force and stabilization are incompatible. You can only have one or the other
00962     if((flags & (PxSceneFlag::eADAPTIVE_FORCE | PxSceneFlag::eENABLE_STABILIZATION)) == (PxSceneFlag::eADAPTIVE_FORCE | PxSceneFlag::eENABLE_STABILIZATION))
00963         return false;
00964 
00965     if(!sanityBounds.isValid())
00966         return false;
00967 
00968 #if PX_SUPPORT_GPU_PHYSX
00969     //gpuMaxNumPartitions must be power of 2
00970     if((gpuMaxNumPartitions&(gpuMaxNumPartitions - 1)) != 0)
00971         return false;
00972     if (gpuMaxNumPartitions > 32)
00973         return false;
00974 #endif
00975 
00976     return true;
00977 }
00978 
00979 
00980 #if !PX_DOXYGEN
00981 } // namespace physx
00982 #endif
00983 
00985 #endif


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