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-2018 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 
00068 struct PxPruningStructureType
00069 {
00070     enum Enum
00071     {
00072         eNONE,                  
00073         eDYNAMIC_AABB_TREE,     
00074         eSTATIC_AABB_TREE,      
00075 
00076         eLAST
00077     };
00078 };
00079 
00099 struct PxSceneQueryUpdateMode
00100 {
00101     enum Enum
00102     {
00103         eBUILD_ENABLED_COMMIT_ENABLED,      
00104         eBUILD_ENABLED_COMMIT_DISABLED,     
00105         eBUILD_DISABLED_COMMIT_DISABLED     
00106     };
00107 };
00108 
00109 
00125 struct PxFrictionType
00126 {
00127     enum Enum
00128     {
00129         ePATCH,             
00130         eONE_DIRECTIONAL,   
00131         eTWO_DIRECTIONAL,   
00132         eFRICTION_COUNT     
00133     };
00134 };
00135 
00136 
00144 struct PxSolverType
00145 {
00146     enum Enum
00147     {
00148         ePGS,           
00149         eTGS            
00150     };
00151 };
00152 
00153 
00160 struct PxSceneFlag
00161 {
00162     enum Enum
00163     {
00176         eENABLE_ACTIVE_ACTORS   = (1<<0),
00177 
00190         eENABLE_CCD = (1<<1),
00191 
00211         eDISABLE_CCD_RESWEEP    = (1<<2),
00212 
00220         eADAPTIVE_FORCE         = (1<<3),
00221 
00232         eENABLE_KINEMATIC_STATIC_PAIRS  PX_DEPRECATED = (1<<4),
00233 
00244         eENABLE_KINEMATIC_PAIRS PX_DEPRECATED = (1<<5),
00245 
00253         eENABLE_PCM = (1 << 6),
00254 
00263         eDISABLE_CONTACT_REPORT_BUFFER_RESIZE   = (1 << 7),
00264 
00275         eDISABLE_CONTACT_CACHE  = (1 << 8),
00276 
00292         eREQUIRE_RW_LOCK = (1 << 9),
00293 
00301         eENABLE_STABILIZATION = (1 << 10),
00302 
00311         eENABLE_AVERAGE_POINT = (1 << 11),
00312 
00325         eEXCLUDE_KINEMATICS_FROM_ACTIVE_ACTORS = (1 << 12),
00326 
00327         /*\brief Enables the GPU dynamics pipeline
00328 
00329         When set to true, a CUDA ARCH 3.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         eENABLE_GPU_DYNAMICS = (1 << 13),
00334 
00356         eENABLE_ENHANCED_DETERMINISM = (1<<14),
00357 
00372         eENABLE_FRICTION_EVERY_ITERATION,
00373 
00374         eMUTABLE_FLAGS = eENABLE_ACTIVE_ACTORS|eEXCLUDE_KINEMATICS_FROM_ACTIVE_ACTORS
00375     };
00376 };
00377 
00378 
00384 typedef PxFlags<PxSceneFlag::Enum,PxU32> PxSceneFlags;
00385 PX_FLAGS_OPERATORS(PxSceneFlag::Enum,PxU32)
00386 
00387 
00388 class PxSimulationEventCallback;
00389 class PxContactModifyCallback;
00390 class PxCCDContactModifyCallback;
00391 class PxSimulationFilterCallback;
00392 
00401 class PxSceneLimits
00402 {
00403 public:
00404     PxU32       maxNbActors;                
00405     PxU32       maxNbBodies;                
00406     PxU32       maxNbStaticShapes;          
00407     PxU32       maxNbDynamicShapes;         
00408     PxU32       maxNbAggregates;            
00409     PxU32       maxNbConstraints;           
00410     PxU32       maxNbRegions;               
00411     PxU32       maxNbBroadPhaseOverlaps;    
00412 
00416     PX_INLINE PxSceneLimits();
00417 
00421     PX_INLINE void setToDefault();
00422 
00427     PX_INLINE bool isValid() const;
00428 };
00429 
00430 PX_INLINE PxSceneLimits::PxSceneLimits() :  //constructor sets to default
00431     maxNbActors             (0),
00432     maxNbBodies             (0),
00433     maxNbStaticShapes       (0),
00434     maxNbDynamicShapes      (0),
00435     maxNbAggregates         (0),
00436     maxNbConstraints        (0),
00437     maxNbRegions            (0),
00438     maxNbBroadPhaseOverlaps (0)
00439 {
00440 }
00441 
00442 PX_INLINE void PxSceneLimits::setToDefault()
00443 {
00444     *this = PxSceneLimits();
00445 }
00446 
00447 PX_INLINE bool PxSceneLimits::isValid() const   
00448 {
00449     if(maxNbRegions>256)    // max number of regions is currently limited
00450         return false;
00451 
00452     return true;
00453 }
00454 
00455 //#if PX_SUPPORT_GPU_PHYSX
00460 struct PxgDynamicsMemoryConfig
00461 {
00462     PxU32 constraintBufferCapacity; 
00463     PxU32 contactBufferCapacity;    
00464     PxU32 tempBufferCapacity;       
00465     PxU32 contactStreamSize;        
00466     PxU32 patchStreamSize;          
00467     PxU32 forceStreamCapacity;      
00468     PxU32 heapCapacity;             
00469     PxU32 foundLostPairsCapacity;   
00470 
00471     PxgDynamicsMemoryConfig() :
00472         constraintBufferCapacity(32 * 1024 * 1024),
00473         contactBufferCapacity(24 * 1024 * 1024),
00474         tempBufferCapacity(16 * 1024 * 1024),
00475         contactStreamSize(1024 * 512),
00476         patchStreamSize(1024 * 80),
00477         forceStreamCapacity(1 * 1024 * 1024),
00478         heapCapacity(64 * 1024 * 1024),
00479         foundLostPairsCapacity(256 * 1024)
00480     {
00481     }
00482 };
00483 
00484 //#endif
00485 
00493 class PxSceneDesc
00494 {
00495 public:
00496 
00507     PxVec3                  gravity;
00508 
00516     PxSimulationEventCallback*  simulationEventCallback;
00517 
00525     PxContactModifyCallback*    contactModifyCallback;
00526 
00534     PxCCDContactModifyCallback* ccdContactModifyCallback;
00535 
00545     const void*             filterShaderData;
00546 
00554     PxU32                   filterShaderDataSize;
00555 
00565     PxSimulationFilterShader    filterShader;
00566 
00575     PxSimulationFilterCallback* filterCallback;
00576 
00584     PxPairFilteringMode::Enum       kineKineFilteringMode;
00585 
00593     PxPairFilteringMode::Enum       staticKineFilteringMode;
00594 
00602     PxBroadPhaseType::Enum      broadPhaseType;
00603 
00611     PxBroadPhaseCallback*       broadPhaseCallback;
00612 
00618     PxSceneLimits               limits;
00619 
00630     PxFrictionType::Enum frictionType;
00631 
00639     PxSolverType::Enum          solverType;
00640 
00650     PxReal bounceThresholdVelocity; 
00651 
00665     PxReal frictionOffsetThreshold;
00666 
00676     PxReal ccdMaxSeparation;
00677 
00686     PxReal solverOffsetSlop;
00687 
00693     PxSceneFlags            flags;
00694 
00700     PxCpuDispatcher*        cpuDispatcher;
00701 
00709     PxGpuDispatcher*        gpuDispatcher;
00710 
00716     PxPruningStructureType::Enum    staticStructure;
00717 
00721     PxPruningStructureType::Enum    dynamicStructure;
00722 
00740     PxU32                   dynamicTreeRebuildRateHint;
00741 
00746     PxSceneQueryUpdateMode::Enum sceneQueryUpdateMode;
00747 
00753     void*                   userData;
00754 
00768     PxU32                   solverBatchSize;
00769 
00783     PxU32                   nbContactDataBlocks;
00784 
00803     PxU32                   maxNbContactDataBlocks;
00804 
00821     PxReal                  maxBiasCoefficient;
00822 
00836     PxU32                   contactReportStreamBufferSize;
00837 
00849     PxU32                   ccdMaxPasses;
00850 
00861     PxReal                  wakeCounterResetValue;
00862 
00872     PxBounds3               sanityBounds;
00873 
00877     PxgDynamicsMemoryConfig gpuDynamicsConfig;
00878 
00885     PxU32                   gpuMaxNumPartitions;
00886 
00890     PxU32                   gpuComputeVersion;
00891 
00892 private:
00896     // For internal use only
00897     PxTolerancesScale       tolerancesScale;
00903 public:
00912     PX_INLINE PxSceneDesc(const PxTolerancesScale& scale);
00913 
00922     PX_INLINE void setToDefault(const PxTolerancesScale& scale);
00923 
00928     PX_INLINE bool isValid() const;
00929 
00933     // For internal use only
00934     PX_INLINE const PxTolerancesScale& getTolerancesScale() const { return tolerancesScale; }
00938 };
00939 
00940 PX_INLINE PxSceneDesc::PxSceneDesc(const PxTolerancesScale& scale):
00941     gravity                             (PxVec3(0.0f)),
00942     simulationEventCallback             (NULL),
00943     contactModifyCallback               (NULL),
00944     ccdContactModifyCallback            (NULL),
00945 
00946     filterShaderData                    (NULL),
00947     filterShaderDataSize                (0),
00948     filterShader                        (NULL),
00949     filterCallback                      (NULL),
00950 
00951     kineKineFilteringMode               (PxPairFilteringMode::eDEFAULT),
00952     staticKineFilteringMode             (PxPairFilteringMode::eDEFAULT),
00953 
00954     broadPhaseType                      (PxBroadPhaseType::eABP),
00955     broadPhaseCallback                  (NULL),
00956 
00957     frictionType                        (PxFrictionType::ePATCH),
00958     solverType                          (PxSolverType::ePGS),
00959     bounceThresholdVelocity             (0.2f * scale.speed),
00960     frictionOffsetThreshold             (0.04f * scale.length),
00961     ccdMaxSeparation                    (0.04f * scale.length),
00962     solverOffsetSlop                    (0.0f),
00963 
00964     flags                               (PxSceneFlag::eENABLE_PCM),
00965 
00966     cpuDispatcher                       (NULL),
00967     gpuDispatcher                       (NULL),
00968 
00969     staticStructure                     (PxPruningStructureType::eDYNAMIC_AABB_TREE),
00970     dynamicStructure                    (PxPruningStructureType::eDYNAMIC_AABB_TREE),
00971     dynamicTreeRebuildRateHint          (100),
00972     sceneQueryUpdateMode                (PxSceneQueryUpdateMode::eBUILD_ENABLED_COMMIT_ENABLED),
00973 
00974     userData                            (NULL),
00975 
00976     solverBatchSize                     (128),
00977 
00978     nbContactDataBlocks                 (0),
00979     maxNbContactDataBlocks              (1<<16),
00980     maxBiasCoefficient                  (PX_MAX_F32),
00981     contactReportStreamBufferSize       (8192),
00982     ccdMaxPasses                        (1),
00983     wakeCounterResetValue               (20.0f*0.02f),
00984     sanityBounds                        (PxBounds3(PxVec3(-PX_MAX_BOUNDS_EXTENTS), PxVec3(PX_MAX_BOUNDS_EXTENTS))),
00985     gpuMaxNumPartitions                 (8),
00986     gpuComputeVersion                   (0),
00987     tolerancesScale                     (scale)
00988 {
00989 }
00990 
00991 PX_INLINE void PxSceneDesc::setToDefault(const PxTolerancesScale& scale)
00992 {
00993     *this = PxSceneDesc(scale);
00994 }
00995 
00996 PX_INLINE bool PxSceneDesc::isValid() const
00997 {
00998     if(!filterShader)
00999         return false;
01000 
01001     if( ((filterShaderDataSize == 0) && (filterShaderData != NULL)) ||
01002         ((filterShaderDataSize > 0) && (filterShaderData == NULL)) )
01003         return false;
01004 
01005     if(!limits.isValid())
01006         return false;
01007 
01008     if(staticStructure!=PxPruningStructureType::eSTATIC_AABB_TREE && staticStructure!=PxPruningStructureType::eDYNAMIC_AABB_TREE)
01009         return false;
01010 
01011     if(dynamicTreeRebuildRateHint < 4)
01012         return false;
01013 
01014     if(bounceThresholdVelocity < 0.0f)
01015         return false;
01016     if(frictionOffsetThreshold < 0.0f)
01017         return false;
01018     if(ccdMaxSeparation < 0.0f)
01019         return false;
01020     if (solverOffsetSlop < 0.f)
01021         return false;
01022 
01023     if(!cpuDispatcher)
01024         return false;
01025 
01026     if(!contactReportStreamBufferSize)
01027         return false;
01028 
01029     if(maxNbContactDataBlocks < nbContactDataBlocks)
01030         return false;
01031 
01032     if(wakeCounterResetValue <= 0.0f)
01033         return false;
01034 
01035     //Adaptive force and stabilization are incompatible. You can only have one or the other
01036     if((flags & (PxSceneFlag::eADAPTIVE_FORCE | PxSceneFlag::eENABLE_STABILIZATION)) == (PxSceneFlag::eADAPTIVE_FORCE | PxSceneFlag::eENABLE_STABILIZATION))
01037         return false;
01038 
01039     if(!sanityBounds.isValid())
01040         return false;
01041 
01042 #if PX_SUPPORT_GPU_PHYSX
01043     //gpuMaxNumPartitions must be power of 2
01044     if((gpuMaxNumPartitions&(gpuMaxNumPartitions - 1)) != 0)
01045         return false;
01046     if (gpuMaxNumPartitions > 32)
01047         return false;
01048 #endif
01049 
01050     return true;
01051 }
01052 
01053 
01054 #if !PX_DOXYGEN
01055 } // namespace physx
01056 #endif
01057 
01059 #endif


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