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-2012 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 "PxPhysX.h" 00038 #include "foundation/PxFlags.h" 00039 #include "foundation/PxBounds3.h" 00040 #include "PxPhysics.h" 00041 #include "PxFiltering.h" 00042 #include "common/PxTolerancesScale.h" 00043 00044 #ifndef PX_DOXYGEN 00045 namespace physx 00046 { 00047 #endif 00048 00049 namespace pxtask 00050 { 00051 class CpuDispatcher; 00052 class GpuDispatcher; 00053 class SpuDispatcher; 00054 } 00055 00073 struct PxPruningStructure 00074 { 00075 enum Enum 00076 { 00077 eNONE, 00078 eDYNAMIC_AABB_TREE, 00079 eSTATIC_AABB_TREE, 00080 00081 eLAST 00082 }; 00083 }; 00084 00091 struct PxSceneFlag 00092 { 00093 enum Enum 00094 { 00107 eDISABLE_SSE = (1<<0), 00108 00121 eENABLE_ACTIVETRANSFORMS =(1<<1), 00122 00123 00133 eENABLE_SWEPT_INTEGRATION =(1<<2), 00134 00135 00143 eADAPTIVE_FORCE =(1<<3), 00144 00145 00156 eENABLE_KINEMATIC_STATIC_PAIRS =(1<<4), 00157 00158 00169 eENABLE_KINEMATIC_PAIRS =(1<<5), 00170 00171 00179 eENABLE_ONE_DIRECTIONAL_FRICTION = (1<<6), 00180 00188 eENABLE_TWO_DIRECTIONAL_FRICTION = (1<<7), 00189 00199 eENABLE_PCM = (1 << 8), 00200 00209 eDISABLE_CONTACT_REPORT_BUFFER_RESIZE = (1 << 9), 00210 00221 eDISABLE_CONTACT_CACHE = (1 << 10), 00222 }; 00223 }; 00224 00230 typedef PxFlags<PxSceneFlag::Enum,PxU16> PxSceneFlags; 00231 PX_FLAGS_OPERATORS(PxSceneFlag::Enum,PxU16); 00232 00233 00234 class PxSimulationEventCallback; 00235 class PxContactModifyCallback; 00236 class PxSimulationFilterCallback; 00237 00245 class PxSceneLimits 00246 { 00247 public: 00248 PxU32 maxNbActors; 00249 PxU32 maxNbBodies; 00250 PxU32 maxNbStaticShapes; 00251 PxU32 maxNbDynamicShapes; 00252 PxU32 maxNbConstraints; 00253 00257 PX_INLINE PxSceneLimits(); 00258 00262 PX_INLINE void setToDefault(); 00263 00268 PX_INLINE bool isValid() const; 00269 }; 00270 00271 PX_INLINE PxSceneLimits::PxSceneLimits() //constructor sets to default 00272 { 00273 maxNbActors = 0; 00274 maxNbBodies = 0; 00275 maxNbStaticShapes = 0; 00276 maxNbDynamicShapes = 0; 00277 maxNbConstraints = 0; 00278 00279 } 00280 00281 PX_INLINE void PxSceneLimits::setToDefault() 00282 { 00283 *this = PxSceneLimits(); 00284 } 00285 00286 PX_INLINE bool PxSceneLimits::isValid() const 00287 { 00288 return true; 00289 } 00290 00296 class PxSceneDesc 00297 { 00298 public: 00299 00310 PxVec3 gravity; 00311 00322 PxSimulationEventCallback* simulationEventCallback; 00323 00331 PxContactModifyCallback* contactModifyCallback; 00332 00342 const void* filterShaderData; 00343 00351 PxU32 filterShaderDataSize; 00352 00362 PxSimulationFilterShader filterShader; 00363 00372 PxSimulationFilterCallback* filterCallback; 00373 00379 PxSceneLimits limits; 00380 00387 PxReal sweepEpsilonDistance; 00388 00389 00398 PxReal contactCorrelationDistance; 00399 00400 00410 PxReal bounceThresholdVelocity; 00411 00412 00424 PxSceneFlags flags; 00425 00437 pxtask::CpuDispatcher* cpuDispatcher; 00438 00451 pxtask::GpuDispatcher* gpuDispatcher; 00452 00464 pxtask::SpuDispatcher* spuDispatcher; 00465 00471 PxPruningStructure::Enum staticStructure; 00472 00476 PxPruningStructure::Enum dynamicStructure; 00477 00495 PxU32 dynamicTreeRebuildRateHint; 00496 00502 void* userData; 00503 00517 PxU32 solverBatchSize; 00518 00543 PxReal sweptIntegrationLinearSpeedFactor; 00544 00552 PxReal sweptIntegrationAngularSpeedFactor; 00553 00554 00571 PxU32 nbContactDataBlocks; 00572 00573 00591 PxU32 maxNbContactDataBlocks; 00592 00593 00607 PxU32 contactReportStreamBufferSize; 00608 00618 PX_INLINE PxSceneDesc(const PxTolerancesScale& scale); 00619 00630 PX_INLINE void setToDefault(const PxTolerancesScale& scale); 00631 00636 PX_INLINE bool isValid() const; 00637 00638 }; 00639 00640 PX_INLINE PxSceneDesc::PxSceneDesc(const PxTolerancesScale& scale): 00641 gravity(PxVec3(0)), 00642 simulationEventCallback(NULL), 00643 contactModifyCallback(NULL), 00644 00645 filterShaderData(NULL), 00646 filterShaderDataSize(0), 00647 filterShader(NULL), 00648 filterCallback(NULL), 00649 00650 sweepEpsilonDistance(0.01f * scale.length), 00651 contactCorrelationDistance(0.025f * scale.length), 00652 bounceThresholdVelocity(0.2f * scale.speed), 00653 00654 flags(0), 00655 00656 cpuDispatcher(NULL), 00657 gpuDispatcher(NULL), 00658 spuDispatcher(NULL), 00659 00660 staticStructure(PxPruningStructure::eSTATIC_AABB_TREE), 00661 dynamicStructure(PxPruningStructure::eDYNAMIC_AABB_TREE), 00662 dynamicTreeRebuildRateHint(100), 00663 00664 userData(NULL), 00665 00666 solverBatchSize(32), 00667 00668 sweptIntegrationLinearSpeedFactor(2), 00669 sweptIntegrationAngularSpeedFactor(2), 00670 00671 #ifdef PX_PS3 00672 nbContactDataBlocks(256), 00673 #else 00674 nbContactDataBlocks(0), 00675 #endif 00676 00677 maxNbContactDataBlocks(1<<16), 00678 contactReportStreamBufferSize(8192) 00679 { 00680 } 00681 00682 PX_INLINE void PxSceneDesc::setToDefault(const PxTolerancesScale& scale) 00683 { 00684 *this = PxSceneDesc(scale); 00685 } 00686 00687 PX_INLINE bool PxIsPowerOfTwo(PxU32 n) { return ((n&(n-1))==0); } 00688 00689 PX_INLINE bool PxSceneDesc::isValid() const 00690 { 00691 if (filterShader == NULL) 00692 return false; 00693 00694 if ( ((filterShaderDataSize == 0) && (filterShaderData != NULL)) || 00695 ((filterShaderDataSize > 0) && (filterShaderData == NULL)) ) 00696 return false; 00697 00698 if (!limits.isValid()) 00699 return false; 00700 00701 if(staticStructure!=PxPruningStructure::eSTATIC_AABB_TREE && staticStructure!=PxPruningStructure::eDYNAMIC_AABB_TREE) 00702 return false; 00703 00704 if (dynamicTreeRebuildRateHint < 5) 00705 return false; 00706 if (sweptIntegrationLinearSpeedFactor < 0.0f) 00707 return false; 00708 if (sweptIntegrationAngularSpeedFactor < 0.0f) 00709 return false; 00710 00711 if (sweepEpsilonDistance < 0.0f) 00712 return false; 00713 if (contactCorrelationDistance < 0.0f) 00714 return false; 00715 if (bounceThresholdVelocity < 0.0f) 00716 return false; 00717 00718 if(cpuDispatcher == NULL) 00719 return false; 00720 00721 if(contactReportStreamBufferSize == 0) 00722 return false; 00723 00724 if(maxNbContactDataBlocks < nbContactDataBlocks) 00725 return false; 00726 00727 return true; 00728 } 00729 00730 #ifndef PX_DOXYGEN 00731 } // namespace physx 00732 #endif 00733 00735 #endif
Copyright © 2008-2012 NVIDIA Corporation, 2701 San Tomas Expressway, Santa Clara, CA 95050 U.S.A. All rights reserved. www.nvidia.com