PxSceneDesc.h

Go to the documentation of this file.
00001 //
00002 // Redistribution and use in source and binary forms, with or without
00003 // modification, are permitted provided that the following conditions
00004 // are met:
00005 //  * Redistributions of source code must retain the above copyright
00006 //    notice, this list of conditions and the following disclaimer.
00007 //  * Redistributions in binary form must reproduce the above copyright
00008 //    notice, this list of conditions and the following disclaimer in the
00009 //    documentation and/or other materials provided with the distribution.
00010 //  * Neither the name of NVIDIA CORPORATION nor the names of its
00011 //    contributors may be used to endorse or promote products derived
00012 //    from this software without specific prior written permission.
00013 //
00014 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
00015 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00016 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00017 // PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
00018 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00019 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00020 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00021 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
00022 // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00023 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00024 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
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 
00067 struct PxPruningStructureType
00068 {
00069     enum Enum
00070     {
00071         eNONE,                  
00072         eDYNAMIC_AABB_TREE,     
00073         eSTATIC_AABB_TREE,      
00074 
00075         eLAST
00076     };
00077 };
00078 
00098 struct PxSceneQueryUpdateMode
00099 {
00100     enum Enum
00101     {
00102         eBUILD_ENABLED_COMMIT_ENABLED,      
00103         eBUILD_ENABLED_COMMIT_DISABLED,     
00104         eBUILD_DISABLED_COMMIT_DISABLED     
00105     };
00106 };
00107 
00108 
00124     struct PxFrictionType
00125     {
00126         enum Enum
00127         {
00128             ePATCH,             
00129             eONE_DIRECTIONAL,   
00130             eTWO_DIRECTIONAL,   
00131             eFRICTION_COUNT     
00132         };
00133     };
00134 
00141 struct PxSceneFlag
00142 {
00143     enum Enum
00144     {
00157         eENABLE_ACTIVE_ACTORS   = (1<<0),
00158 
00171         eENABLE_ACTIVETRANSFORMS    PX_DEPRECATED = (1<<1),
00172 
00185         eENABLE_CCD = (1<<2),
00186 
00206         eDISABLE_CCD_RESWEEP    = (1<<3),
00207 
00215         eADAPTIVE_FORCE             = (1<<4),
00216 
00227         eENABLE_KINEMATIC_STATIC_PAIRS  PX_DEPRECATED   = (1<<5),
00228 
00239         eENABLE_KINEMATIC_PAIRS PX_DEPRECATED   = (1<<6),
00240 
00248         eENABLE_PCM = (1 << 9),
00249 
00258         eDISABLE_CONTACT_REPORT_BUFFER_RESIZE   = (1 << 10),
00259 
00270         eDISABLE_CONTACT_CACHE  = (1 << 11),
00271 
00287         eREQUIRE_RW_LOCK = (1 << 12),
00288 
00296         eENABLE_STABILIZATION = (1 << 14),
00297 
00306         eENABLE_AVERAGE_POINT = (1 << 15),
00307 
00321         eDEPRECATED_TRIGGER_TRIGGER_REPORTS = (1 << 16),
00322 
00335         eEXCLUDE_KINEMATICS_FROM_ACTIVE_ACTORS = (1 << 17),
00336 
00352         eSUPPRESS_EAGER_SCENE_QUERY_REFIT PX_DEPRECATED = (1 << 18),
00353 
00354         /*\brief Enables the GPU dynamics pipeline
00355 
00356         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.
00357 
00358         Note that this flag is not mutable and must be set in PxSceneDesc at scene creation.
00359         */
00360         eENABLE_GPU_DYNAMICS = (1 << 19),
00361 
00383         eENABLE_ENHANCED_DETERMINISM = (1<<20),
00384 
00385         eMUTABLE_FLAGS = eENABLE_ACTIVE_ACTORS|eENABLE_ACTIVETRANSFORMS|eEXCLUDE_KINEMATICS_FROM_ACTIVE_ACTORS
00386     };
00387 };
00388 
00389 
00395 typedef PxFlags<PxSceneFlag::Enum,PxU32> PxSceneFlags;
00396 PX_FLAGS_OPERATORS(PxSceneFlag::Enum,PxU32)
00397 
00398 
00399 class PxSimulationEventCallback;
00400 class PxContactModifyCallback;
00401 class PxCCDContactModifyCallback;
00402 class PxSimulationFilterCallback;
00403 
00412 class PxSceneLimits
00413 {
00414 public:
00415     PxU32       maxNbActors;                
00416     PxU32       maxNbBodies;                
00417     PxU32       maxNbStaticShapes;          
00418     PxU32       maxNbDynamicShapes;         
00419     PxU32       maxNbAggregates;            
00420     PxU32       maxNbConstraints;           
00421     PxU32       maxNbRegions;               
00422     PxU32       maxNbBroadPhaseOverlaps;    
00423     PX_DEPRECATED   PxU32       maxNbObjectsPerRegion;      
00424 
00428     PX_INLINE PxSceneLimits();
00429 
00433     PX_INLINE void setToDefault();
00434 
00439     PX_INLINE bool isValid() const;
00440 };
00441 
00442 PX_INLINE PxSceneLimits::PxSceneLimits() :  //constructor sets to default
00443     maxNbActors             (0),
00444     maxNbBodies             (0),
00445     maxNbStaticShapes       (0),
00446     maxNbDynamicShapes      (0),
00447     maxNbAggregates         (0),
00448     maxNbConstraints        (0),
00449     maxNbRegions            (0),
00450     maxNbBroadPhaseOverlaps (0),
00451     maxNbObjectsPerRegion   (0)
00452 {
00453 }
00454 
00455 PX_INLINE void PxSceneLimits::setToDefault()
00456 {
00457     *this = PxSceneLimits();
00458 }
00459 
00460 PX_INLINE bool PxSceneLimits::isValid() const   
00461 {
00462     if(maxNbRegions>256)    // max number of regions is currently limited
00463         return false;
00464 
00465     return true;
00466 }
00467 
00468 //#if PX_SUPPORT_GPU_PHYSX
00473 struct PxgDynamicsMemoryConfig
00474 {
00475     PxU32 constraintBufferCapacity; 
00476     PxU32 contactBufferCapacity;    
00477     PxU32 tempBufferCapacity;       
00478     PxU32 contactStreamSize;        
00479     PxU32 patchStreamSize;          
00480     PxU32 forceStreamCapacity;      
00481     PxU32 heapCapacity;             
00482     PxU32 foundLostPairsCapacity;   
00483 
00484     PxgDynamicsMemoryConfig() :
00485         constraintBufferCapacity(32 * 1024 * 1024),
00486         contactBufferCapacity(24 * 1024 * 1024),
00487         tempBufferCapacity(16 * 1024 * 1024),
00488         contactStreamSize(1024 * 512),
00489         patchStreamSize(1024 * 80),
00490         forceStreamCapacity(1 * 1024 * 1024),
00491         heapCapacity(64 * 1024 * 1024),
00492         foundLostPairsCapacity(256 * 1024)
00493     {
00494     }
00495 };
00496 
00497 //#endif
00498 
00506 class PxSceneDesc
00507 {
00508 public:
00509 
00520     PxVec3                  gravity;
00521 
00532     PxSimulationEventCallback*  simulationEventCallback;
00533 
00541     PxContactModifyCallback*    contactModifyCallback;
00542 
00550     PxCCDContactModifyCallback* ccdContactModifyCallback;
00551 
00561     const void*             filterShaderData;
00562 
00570     PxU32                   filterShaderDataSize;
00571 
00581     PxSimulationFilterShader    filterShader;
00582 
00591     PxSimulationFilterCallback* filterCallback;
00592 
00600     PxPairFilteringMode::Enum       kineKineFilteringMode;
00601 
00609     PxPairFilteringMode::Enum       staticKineFilteringMode;
00610 
00618     PxBroadPhaseType::Enum      broadPhaseType;
00619 
00630     PxBroadPhaseCallback*       broadPhaseCallback;
00631 
00637     PxSceneLimits               limits;
00638 
00649     PxFrictionType::Enum frictionType;
00650 
00660     PxReal bounceThresholdVelocity; 
00661 
00675     PxReal frictionOffsetThreshold;
00676 
00686     PxReal ccdMaxSeparation;
00687 
00696     PxReal solverOffsetSlop;
00697 
00703     PxSceneFlags            flags;
00704 
00710     PxCpuDispatcher*        cpuDispatcher;
00711 
00719     PxGpuDispatcher*        gpuDispatcher;
00720 
00726     PxPruningStructureType::Enum    staticStructure;
00727 
00731     PxPruningStructureType::Enum    dynamicStructure;
00732 
00750     PxU32                   dynamicTreeRebuildRateHint;
00751 
00759     PxSceneQueryUpdateMode::Enum sceneQueryUpdateMode;
00760 
00766     void*                   userData;
00767 
00781     PxU32                   solverBatchSize;
00782 
00796     PxU32                   nbContactDataBlocks;
00797 
00816     PxU32                   maxNbContactDataBlocks;
00817 
00834     PxReal                  maxBiasCoefficient;
00835 
00849     PxU32                   contactReportStreamBufferSize;
00850 
00862     PxU32                   ccdMaxPasses;
00863 
00874     PxReal                  wakeCounterResetValue;
00875 
00885     PxBounds3               sanityBounds;
00886 
00890     PxgDynamicsMemoryConfig gpuDynamicsConfig;
00891 
00898     PxU32                   gpuMaxNumPartitions;
00899 
00903     PxU32                   gpuComputeVersion;
00904 
00905 private:
00909     // For internal use only
00910     PxTolerancesScale       tolerancesScale;
00916 public:
00925     PX_INLINE PxSceneDesc(const PxTolerancesScale& scale);
00926 
00935     PX_INLINE void setToDefault(const PxTolerancesScale& scale);
00936 
00941     PX_INLINE bool isValid() const;
00942 
00946     // For internal use only
00947     PX_INLINE const PxTolerancesScale& getTolerancesScale() const { return tolerancesScale; }
00951 };
00952 
00953 PX_INLINE PxSceneDesc::PxSceneDesc(const PxTolerancesScale& scale):
00954     gravity                             (PxVec3(0.0f)),
00955     simulationEventCallback             (NULL),
00956     contactModifyCallback               (NULL),
00957     ccdContactModifyCallback            (NULL),
00958 
00959     filterShaderData                    (NULL),
00960     filterShaderDataSize                (0),
00961     filterShader                        (NULL),
00962     filterCallback                      (NULL),
00963 
00964     kineKineFilteringMode               (PxPairFilteringMode::eDEFAULT),
00965     staticKineFilteringMode             (PxPairFilteringMode::eDEFAULT),
00966 
00967     broadPhaseType                      (PxBroadPhaseType::eSAP),
00968     broadPhaseCallback                  (NULL),
00969 
00970     frictionType                        (PxFrictionType::ePATCH),
00971     bounceThresholdVelocity             (0.2f * scale.speed),
00972     frictionOffsetThreshold             (0.04f * scale.length),
00973     ccdMaxSeparation                    (0.04f * scale.length),
00974     solverOffsetSlop                    (0.0f),
00975 
00976     flags                               (PxSceneFlag::eENABLE_PCM),
00977 
00978     cpuDispatcher                       (NULL),
00979     gpuDispatcher                       (NULL),
00980 
00981     staticStructure                     (PxPruningStructureType::eDYNAMIC_AABB_TREE),
00982     dynamicStructure                    (PxPruningStructureType::eDYNAMIC_AABB_TREE),
00983     dynamicTreeRebuildRateHint          (100),
00984     sceneQueryUpdateMode                (PxSceneQueryUpdateMode::eBUILD_ENABLED_COMMIT_ENABLED),
00985 
00986     userData                            (NULL),
00987 
00988     solverBatchSize                     (128),
00989 
00990     nbContactDataBlocks                 (0),
00991     maxNbContactDataBlocks              (1<<16),
00992     maxBiasCoefficient                  (PX_MAX_F32),
00993     contactReportStreamBufferSize       (8192),
00994     ccdMaxPasses                        (1),
00995     wakeCounterResetValue               (20.0f*0.02f),
00996     sanityBounds                        (PxBounds3(PxVec3(-PX_MAX_BOUNDS_EXTENTS), PxVec3(PX_MAX_BOUNDS_EXTENTS))),
00997 
00998     gpuMaxNumPartitions                 (8),
00999     gpuComputeVersion                   (0),
01000 
01001     tolerancesScale                     (scale)
01002 {
01003 }
01004 
01005 PX_INLINE void PxSceneDesc::setToDefault(const PxTolerancesScale& scale)
01006 {
01007     *this = PxSceneDesc(scale);
01008 }
01009 
01010 PX_INLINE bool PxSceneDesc::isValid() const
01011 {
01012     if(!filterShader)
01013         return false;
01014 
01015     if( ((filterShaderDataSize == 0) && (filterShaderData != NULL)) ||
01016         ((filterShaderDataSize > 0) && (filterShaderData == NULL)) )
01017         return false;
01018 
01019     if(!limits.isValid())
01020         return false;
01021 
01022     if(staticStructure!=PxPruningStructureType::eSTATIC_AABB_TREE && staticStructure!=PxPruningStructureType::eDYNAMIC_AABB_TREE)
01023         return false;
01024 
01025     if(dynamicTreeRebuildRateHint < 4)
01026         return false;
01027 
01028     if(bounceThresholdVelocity < 0.0f)
01029         return false;
01030     if(frictionOffsetThreshold < 0.0f)
01031         return false;
01032     if(ccdMaxSeparation < 0.0f)
01033         return false;
01034 
01035     if(!cpuDispatcher)
01036         return false;
01037 
01038     if(!contactReportStreamBufferSize)
01039         return false;
01040 
01041     if(maxNbContactDataBlocks < nbContactDataBlocks)
01042         return false;
01043 
01044     if(wakeCounterResetValue <= 0.0f)
01045         return false;
01046 
01047     //Adaptive force and stabilization are incompatible. You can only have one or the other
01048     if((flags & (PxSceneFlag::eADAPTIVE_FORCE | PxSceneFlag::eENABLE_STABILIZATION)) == (PxSceneFlag::eADAPTIVE_FORCE | PxSceneFlag::eENABLE_STABILIZATION))
01049         return false;
01050 
01051     if(!sanityBounds.isValid())
01052         return false;
01053 
01054     //gpuMaxNumPartitions must be power of 2
01055     if((gpuMaxNumPartitions&(gpuMaxNumPartitions - 1)) != 0)
01056         return false;
01057     if (gpuMaxNumPartitions > 32)
01058         return false;
01059 
01060     return true;
01061 }
01062 
01063 
01064 #if !PX_DOXYGEN
01065 } // namespace physx
01066 #endif
01067 
01069 #endif


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