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-2016 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 
00461     PxgDynamicsMemoryConfig() :
00462         constraintBufferCapacity(32 * 1024 * 1024),
00463         contactBufferCapacity(24 * 1024 * 1024),
00464         tempBufferCapacity(16 * 1024 * 1024),
00465         contactStreamSize(1024 * 512),
00466         patchStreamSize(1024 * 80),
00467         forceStreamCapacity(1 * 1024 * 1024),
00468         heapCapacity(64 * 1024 * 1024),
00469         foundLostPairsCapacity(256 * 1024)
00470     {
00471     }
00472 };
00473 
00474 //#endif
00475 
00483 class PxSceneDesc
00484 {
00485 public:
00486 
00497     PxVec3                  gravity;
00498 
00509     PxSimulationEventCallback*  simulationEventCallback;
00510 
00518     PxContactModifyCallback*    contactModifyCallback;
00519 
00527     PxCCDContactModifyCallback* ccdContactModifyCallback;
00528 
00538     const void*             filterShaderData;
00539 
00547     PxU32                   filterShaderDataSize;
00548 
00558     PxSimulationFilterShader    filterShader;
00559 
00568     PxSimulationFilterCallback* filterCallback;
00569 
00577     PxBroadPhaseType::Enum      broadPhaseType;
00578 
00589     PxBroadPhaseCallback*       broadPhaseCallback;
00590 
00596     PxSceneLimits               limits;
00597 
00598 
00609     PxFrictionType::Enum frictionType;
00610 
00620     PxReal bounceThresholdVelocity; 
00621 
00635     PxReal frictionOffsetThreshold;
00636 
00646     PxReal ccdMaxSeparation;
00647 
00653     PxSceneFlags            flags;
00654 
00660     PxCpuDispatcher*        cpuDispatcher;
00661 
00669     PxGpuDispatcher*        gpuDispatcher;
00670 
00676     PxPruningStructureType::Enum    staticStructure;
00677 
00681     PxPruningStructureType::Enum    dynamicStructure;
00682 
00700     PxU32                   dynamicTreeRebuildRateHint;
00701 
00707     void*                   userData;
00708 
00722     PxU32                   solverBatchSize;
00723 
00737     PxU32                   nbContactDataBlocks;
00738 
00757     PxU32                   maxNbContactDataBlocks;
00758 
00772     PxU32                   contactReportStreamBufferSize;
00773 
00785     PxU32                   ccdMaxPasses;
00786 
00787 
00798     PxReal                  wakeCounterResetValue;
00799 
00800 
00810     PxBounds3               sanityBounds;
00811 
00812 
00817     PxgDynamicsMemoryConfig gpuDynamicsConfig;
00818 
00824     PxU32                   gpuMaxNumPartitions;
00825 
00829     PxU32                   gpuComputeVersion;
00830 
00831 
00832 
00833 private:
00837     // For internal use only
00838     PxTolerancesScale       tolerancesScale;
00844 public:
00853     PX_INLINE PxSceneDesc(const PxTolerancesScale& scale);
00854 
00863     PX_INLINE void setToDefault(const PxTolerancesScale& scale);
00864 
00869     PX_INLINE bool isValid() const;
00870 
00874     // For internal use only
00875     PX_INLINE const PxTolerancesScale& getTolerancesScale() const { return tolerancesScale; }
00879 };
00880 
00881 PX_INLINE PxSceneDesc::PxSceneDesc(const PxTolerancesScale& scale):
00882     gravity                             (PxVec3(0.0f)),
00883     simulationEventCallback             (NULL),
00884     contactModifyCallback               (NULL),
00885     ccdContactModifyCallback            (NULL),
00886 
00887     filterShaderData                    (NULL),
00888     filterShaderDataSize                (0),
00889     filterShader                        (NULL),
00890     filterCallback                      (NULL),
00891     broadPhaseType                      (PxBroadPhaseType::eSAP),
00892     broadPhaseCallback                  (NULL),
00893 
00894     frictionType                        (PxFrictionType::ePATCH),
00895     bounceThresholdVelocity             (0.2f * scale.speed),
00896     frictionOffsetThreshold             (0.04f * scale.length),
00897     ccdMaxSeparation                    (0.04f * scale.length),
00898 
00899     flags                               (PxSceneFlag::eENABLE_PCM),
00900 
00901     cpuDispatcher                       (NULL),
00902     gpuDispatcher                       (NULL),
00903 
00904     staticStructure                     (PxPruningStructureType::eDYNAMIC_AABB_TREE),
00905     dynamicStructure                    (PxPruningStructureType::eDYNAMIC_AABB_TREE),
00906     dynamicTreeRebuildRateHint          (100),
00907 
00908     userData                            (NULL),
00909 
00910     solverBatchSize                     (128),
00911 
00912     nbContactDataBlocks                 (0),
00913     maxNbContactDataBlocks              (1<<16),
00914     contactReportStreamBufferSize       (8192),
00915     ccdMaxPasses                        (1),
00916     wakeCounterResetValue               (20.0f*0.02f),
00917     sanityBounds                        (PxBounds3(PxVec3(-PX_MAX_BOUNDS_EXTENTS, -PX_MAX_BOUNDS_EXTENTS, -PX_MAX_BOUNDS_EXTENTS),
00918                                                    PxVec3(PX_MAX_BOUNDS_EXTENTS, PX_MAX_BOUNDS_EXTENTS, PX_MAX_BOUNDS_EXTENTS))),
00919 #if PX_SUPPORT_GPU_PHYSX
00920     gpuMaxNumPartitions                 (8),
00921     gpuComputeVersion                   (0),
00922 #endif
00923     tolerancesScale                     (scale)
00924 {
00925 }
00926 
00927 PX_INLINE void PxSceneDesc::setToDefault(const PxTolerancesScale& scale)
00928 {
00929     *this = PxSceneDesc(scale);
00930 }
00931 
00932 PX_INLINE bool PxSceneDesc::isValid() const
00933 {
00934     if(filterShader == NULL)
00935         return false;
00936 
00937     if( ((filterShaderDataSize == 0) && (filterShaderData != NULL)) ||
00938         ((filterShaderDataSize > 0) && (filterShaderData == NULL)) )
00939         return false;
00940 
00941     if(!limits.isValid())
00942         return false;
00943 
00944     if(staticStructure!=PxPruningStructureType::eSTATIC_AABB_TREE && staticStructure!=PxPruningStructureType::eDYNAMIC_AABB_TREE)
00945         return false;
00946 
00947     if(dynamicTreeRebuildRateHint < 4)
00948         return false;
00949 
00950     if(bounceThresholdVelocity < 0.0f)
00951         return false;
00952     if(frictionOffsetThreshold < 0.f)
00953         return false;
00954     if (ccdMaxSeparation < 0.f)
00955         return false;
00956 
00957     if(cpuDispatcher == NULL)
00958         return false;
00959 
00960     if(contactReportStreamBufferSize == 0)
00961         return false;
00962 
00963     if(maxNbContactDataBlocks < nbContactDataBlocks)
00964         return false;
00965 
00966     if (wakeCounterResetValue <= 0.0f)
00967         return false;
00968 
00969     //Adaptive force and stabilization are incompatible. You can only have one or the other
00970     if((flags & (PxSceneFlag::eADAPTIVE_FORCE | PxSceneFlag::eENABLE_STABILIZATION)) == (PxSceneFlag::eADAPTIVE_FORCE | PxSceneFlag::eENABLE_STABILIZATION))
00971         return false;
00972 
00973     if(!sanityBounds.isValid())
00974         return false;
00975 
00976 #if PX_SUPPORT_GPU_PHYSX
00977     //gpuMaxNumPartitions must be power of 2
00978     if ((gpuMaxNumPartitions&(gpuMaxNumPartitions - 1)) != 0)
00979         return false;
00980 #endif
00981 
00982     return true;
00983 }
00984 
00985 
00986 #if !PX_DOXYGEN
00987 } // namespace physx
00988 #endif
00989 
00991 #endif


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