DestructibleAsset.h
00001 /* 00002 * Copyright (c) 2008-2017, NVIDIA CORPORATION. All rights reserved. 00003 * 00004 * NVIDIA CORPORATION and its licensors retain all intellectual property 00005 * and proprietary rights in and to this software, related documentation 00006 * and any modifications thereto. Any use, reproduction, disclosure or 00007 * distribution of this software and related documentation without an express 00008 * license agreement from NVIDIA CORPORATION is strictly prohibited. 00009 */ 00010 00011 00012 #ifndef DESTRUCTIBLE_ASSET_H 00013 #define DESTRUCTIBLE_ASSET_H 00014 00015 #define DESTRUCTIBLE_AUTHORING_TYPE_NAME "DestructibleAsset" 00016 00017 #include "foundation/Px.h" 00018 #include "FractureToolsAPI.h" 00019 // TODO: Remove this include when we remove the APEX_RUNTIME_FRACTURE define 00020 #include "ModuleDestructible.h" 00021 00022 #if PX_PHYSICS_VERSION_MAJOR == 3 00023 #include "PxFiltering.h" 00024 #endif 00025 00026 namespace nvidia 00027 { 00028 namespace apex 00029 { 00030 00031 struct IntPair; 00032 class DestructibleActor; 00033 class DestructiblePreview; 00034 00035 PX_PUSH_PACK_DEFAULT 00036 #if !PX_PS4 00037 #pragma warning(push) 00038 #pragma warning(disable:4121) 00039 #endif //!PX_PS4 00040 00044 struct DestructibleDepthParametersFlag 00045 { 00049 enum Enum 00050 { 00056 OVERRIDE_IMPACT_DAMAGE = (1 << 0), 00057 00061 OVERRIDE_IMPACT_DAMAGE_VALUE = (1 << 1), 00062 00066 IGNORE_POSE_UPDATES = (1 << 2), 00067 00071 IGNORE_RAYCAST_CALLBACKS = (1 << 3), 00072 00076 IGNORE_CONTACT_CALLBACKS = (1 << 4), 00077 00081 USER_FLAG_0 = (1 << 24), 00082 USER_FLAG_1 = (1 << 25), 00083 USER_FLAG_2 = (1 << 26), 00084 USER_FLAG_3 = (1 << 27) 00085 }; 00086 }; 00087 00088 00092 struct DestructibleDepthParameters 00093 { 00097 PX_INLINE DestructibleDepthParameters(); 00098 00102 PX_INLINE void setToDefault(); 00103 00107 PX_INLINE void setToMostExpensive(); 00108 00112 PX_INLINE bool overrideImpactDamage() const; 00113 00117 PX_INLINE bool overrideImpactDamageValue() const; 00118 00122 PX_INLINE bool ignoresPoseUpdates() const; 00123 00127 PX_INLINE bool ignoresRaycastCallbacks() const; 00128 00132 PX_INLINE bool ignoresContactCallbacks() const; 00133 00137 PX_INLINE bool hasUserFlagSet(uint32_t flagIndex) const; 00138 00142 uint32_t flags; 00143 }; 00144 00145 // DestructibleDepthParameters inline functions 00146 00147 PX_INLINE DestructibleDepthParameters::DestructibleDepthParameters() 00148 { 00149 setToDefault(); 00150 } 00151 00152 PX_INLINE void DestructibleDepthParameters::setToDefault() 00153 { 00154 flags = 0; 00155 } 00156 00157 PX_INLINE bool DestructibleDepthParameters::overrideImpactDamage() const 00158 { 00159 return (flags & DestructibleDepthParametersFlag::OVERRIDE_IMPACT_DAMAGE) != 0; 00160 } 00161 00162 PX_INLINE bool DestructibleDepthParameters::overrideImpactDamageValue() const 00163 { 00164 return (flags & DestructibleDepthParametersFlag::OVERRIDE_IMPACT_DAMAGE_VALUE) != 0; 00165 } 00166 00167 PX_INLINE bool DestructibleDepthParameters::ignoresPoseUpdates() const 00168 { 00169 return (flags & DestructibleDepthParametersFlag::IGNORE_POSE_UPDATES) != 0; 00170 } 00171 00172 PX_INLINE bool DestructibleDepthParameters::ignoresRaycastCallbacks() const 00173 { 00174 return (flags & DestructibleDepthParametersFlag::IGNORE_RAYCAST_CALLBACKS) != 0; 00175 } 00176 00177 PX_INLINE bool DestructibleDepthParameters::ignoresContactCallbacks() const 00178 { 00179 return (flags & DestructibleDepthParametersFlag::IGNORE_CONTACT_CALLBACKS) != 0; 00180 } 00181 00182 PX_INLINE bool DestructibleDepthParameters::hasUserFlagSet(uint32_t flagIndex) const 00183 { 00184 switch (flagIndex) 00185 { 00186 case 0: 00187 return (flags & DestructibleDepthParametersFlag::USER_FLAG_0) != 0; 00188 case 1: 00189 return (flags & DestructibleDepthParametersFlag::USER_FLAG_1) != 0; 00190 case 2: 00191 return (flags & DestructibleDepthParametersFlag::USER_FLAG_2) != 0; 00192 case 3: 00193 return (flags & DestructibleDepthParametersFlag::USER_FLAG_3) != 0; 00194 default: 00195 return false; 00196 } 00197 } 00198 00202 struct DestructibleRTFractureParameters 00203 { 00208 bool sheetFracture; 00209 00214 uint32_t depthLimit; 00215 00220 bool destroyIfAtDepthLimit; 00221 00225 float minConvexSize; 00226 00230 float impulseScale; 00231 00235 struct FractureGlass 00236 { 00240 uint32_t numSectors; 00241 00245 float sectorRand; 00246 00250 float firstSegmentSize; 00251 00255 float segmentScale; 00256 00260 float segmentRand; 00261 }glass; 00262 00266 struct FractureAttachment 00267 { 00271 bool posX; 00272 00276 bool negX; 00277 00281 bool posY; 00282 00286 bool negY; 00287 00291 bool posZ; 00292 00296 bool negZ; 00297 }attachment; 00298 00302 PX_INLINE void setToDefault(); 00303 }; 00304 00305 PX_INLINE void DestructibleRTFractureParameters::setToDefault() 00306 { 00307 sheetFracture = true; 00308 depthLimit = 2; 00309 destroyIfAtDepthLimit = false; 00310 minConvexSize = 0.02f; 00311 impulseScale = 1.0f; 00312 glass.numSectors = 10; 00313 glass.sectorRand = 0.3f; 00314 glass.firstSegmentSize = 0.06f; 00315 glass.segmentScale = 1.4f; 00316 glass.segmentRand = 0.3f; 00317 attachment.posX = false; 00318 attachment.negX = false; 00319 attachment.posY = false; 00320 attachment.negY = false; 00321 attachment.posZ = false; 00322 attachment.negZ = false; 00323 } 00324 00328 struct DestructibleParametersFlag 00329 { 00333 enum Enum 00334 { 00340 ACCUMULATE_DAMAGE = (1 << 0), 00341 00347 DEBRIS_TIMEOUT = (1 << 1), 00348 00355 DEBRIS_MAX_SEPARATION = (1 << 2), 00356 00364 CRUMBLE_SMALLEST_CHUNKS = (1 << 3), 00365 00372 ACCURATE_RAYCASTS = (1 << 4), 00373 00379 USE_VALID_BOUNDS = (1 << 5), 00380 00386 CRUMBLE_VIA_RUNTIME_FRACTURE = (1 << 6), 00387 }; 00388 }; 00389 00390 00394 struct DestructibleParameters 00395 { 00399 PX_INLINE DestructibleParameters(); 00400 00404 PX_INLINE void setToDefault(); 00405 00411 float damageCap; 00412 00419 float forceToDamage; 00420 00427 float impactVelocityThreshold; 00428 00432 uint32_t minimumFractureDepth; 00433 00439 int32_t impactDamageDefaultDepth; 00440 00447 int32_t debrisDepth; 00448 00455 uint32_t essentialDepth; 00456 00465 float debrisLifetimeMin; 00466 00468 float debrisLifetimeMax; 00469 00478 float debrisMaxSeparationMin; 00479 00481 float debrisMaxSeparationMax; 00482 00488 float debrisDestructionProbability; 00489 00495 PxBounds3 validBounds; 00496 00501 float maxChunkSpeed; 00502 00506 uint32_t flags; 00507 00512 float fractureImpulseScale; 00513 00518 uint16_t damageDepthLimit; 00519 00523 uint8_t dynamicChunksDominanceGroup; 00524 00529 bool useDynamicChunksGroupsMask; 00530 00531 #if PX_PHYSICS_VERSION_MAJOR == 3 00532 00535 physx::PxFilterData dynamicChunksFilterData; 00536 #endif 00537 00541 float supportStrength; 00542 00548 int8_t legacyChunkBoundsTestSetting; 00549 00555 int8_t legacyDamageRadiusSpreadSetting; 00556 00560 enum { kDepthParametersCountMax = 16 }; 00561 00566 uint32_t depthParametersCount; 00567 00574 DestructibleDepthParameters depthParameters[kDepthParametersCountMax]; 00575 00579 DestructibleRTFractureParameters rtFractureParameters; 00580 00585 bool alwaysDrawScatterMesh; 00586 }; 00587 00588 // DestructibleParameters inline functions 00589 00590 PX_INLINE DestructibleParameters::DestructibleParameters() 00591 { 00592 setToDefault(); 00593 } 00594 00595 PX_INLINE void DestructibleParameters::setToDefault() 00596 { 00597 damageCap = 0; 00598 forceToDamage = 0; 00599 impactVelocityThreshold = 0.0f; 00600 minimumFractureDepth = 0; 00601 impactDamageDefaultDepth = -1; 00602 debrisDepth = -1; 00603 essentialDepth = 0; 00604 debrisLifetimeMin = 1.0f; 00605 debrisLifetimeMax = 10.0f; 00606 debrisMaxSeparationMin = 1.0f; 00607 debrisMaxSeparationMax = 10.0f; 00608 debrisDestructionProbability = 0.0f; 00609 validBounds = PxBounds3(PxVec3(-10000.0f), PxVec3(10000.0f)); 00610 maxChunkSpeed = 0.0f; 00611 fractureImpulseScale = 0.0f; 00612 damageDepthLimit = UINT16_MAX; 00613 useDynamicChunksGroupsMask = false; 00614 #if PX_PHYSICS_VERSION_MAJOR == 3 00615 dynamicChunksFilterData.word0 = dynamicChunksFilterData.word1 = dynamicChunksFilterData.word2 = dynamicChunksFilterData.word3 = 0; 00616 #endif 00617 supportStrength = -1.0; 00618 legacyChunkBoundsTestSetting = -1; 00619 legacyDamageRadiusSpreadSetting = -1; 00620 dynamicChunksDominanceGroup = 0xFF; // Out of range, so it won't be used. 00621 flags = DestructibleParametersFlag::ACCUMULATE_DAMAGE; 00622 depthParametersCount = 0; 00623 rtFractureParameters.setToDefault(); 00624 alwaysDrawScatterMesh = false; 00625 } 00626 00630 struct DestructibleInitParametersFlag 00631 { 00635 enum Enum 00636 { 00643 ASSET_DEFINED_SUPPORT = (1 << 0), 00644 00651 WORLD_SUPPORT = (1 << 1), 00652 00657 FORM_EXTENDED_STRUCTURES = (1 << 2) 00658 }; 00659 }; 00660 00664 struct DestructibleInitParameters 00665 { 00669 PX_INLINE DestructibleInitParameters(); 00670 00674 PX_INLINE void setToDefault(); 00675 00680 uint32_t supportDepth; 00681 00685 uint32_t flags; 00686 }; 00687 00688 00689 // DestructibleInitParameters inline functions 00690 00691 PX_INLINE DestructibleInitParameters::DestructibleInitParameters() 00692 { 00693 setToDefault(); 00694 } 00695 00696 PX_INLINE void DestructibleInitParameters::setToDefault() 00697 { 00698 supportDepth = 0; 00699 flags = 0; 00700 } 00701 00705 struct DamageSpreadFunction 00706 { 00707 PX_INLINE DamageSpreadFunction() 00708 { 00709 setToDefault(); 00710 } 00711 00715 PX_INLINE void setToDefault() 00716 { 00717 minimumRadius = 0.0f; 00718 radiusMultiplier = 1.0f; 00719 falloffExponent = 1.0f; 00720 } 00721 00725 PX_INLINE bool isValid() const 00726 { 00727 return 00728 minimumRadius >= 0.0f && 00729 radiusMultiplier >= 0.0f && 00730 falloffExponent >= 0.0f; 00731 } 00732 00733 float minimumRadius; 00734 float radiusMultiplier; 00735 float falloffExponent; 00736 }; 00737 00743 class DestructibleBehaviorGroupDesc : public ApexDesc 00744 { 00745 public: 00749 PX_INLINE DestructibleBehaviorGroupDesc(); 00750 00754 PX_INLINE void setToDefault(); 00755 00759 PX_INLINE bool isValid() const; 00760 00765 const char* name; 00766 float damageThreshold; 00767 float damageToRadius; 00768 DamageSpreadFunction damageSpread; 00769 DamageSpreadFunction damageColorSpread; 00770 PxVec4 damageColorChange; 00771 float materialStrength; 00772 float density; 00773 float fadeOut; 00774 float maxDepenetrationVelocity; 00775 uint64_t userData; 00776 }; 00777 00778 // DestructibleChunkDesc inline functions 00779 00780 PX_INLINE DestructibleBehaviorGroupDesc::DestructibleBehaviorGroupDesc() 00781 { 00782 setToDefault(); 00783 } 00784 00785 PX_INLINE void DestructibleBehaviorGroupDesc::setToDefault() 00786 { 00787 ApexDesc::setToDefault(); 00788 00789 // TC_TODO: suitable default values? 00790 name = NULL; 00791 damageThreshold = 1.0f; 00792 damageToRadius = 0.1f; 00793 damageSpread.setToDefault(); 00794 damageColorSpread.setToDefault(); 00795 damageColorChange.setZero(); 00796 materialStrength = 0.0f; 00797 density = 0; 00798 fadeOut = 1; 00799 maxDepenetrationVelocity = PX_MAX_F32; 00800 userData = (uint64_t)0; 00801 } 00802 00803 PX_INLINE bool DestructibleBehaviorGroupDesc::isValid() const 00804 { 00805 // TC_TODO: this good enough? 00806 if (damageThreshold < 0 || 00807 damageToRadius < 0 || 00808 !damageSpread.isValid() || 00809 !damageColorSpread.isValid() || 00810 materialStrength < 0 || 00811 density < 0 || 00812 fadeOut < 0 || 00813 !(maxDepenetrationVelocity > 0.f)) 00814 { 00815 return false; 00816 } 00817 00818 return ApexDesc::isValid(); 00819 } 00825 class DestructibleChunkDesc : public ApexDesc 00826 { 00827 public: 00831 PX_INLINE DestructibleChunkDesc(); 00832 00836 PX_INLINE void setToDefault(); 00837 00841 PX_INLINE bool isValid() const; 00842 00847 bool isSupportChunk; 00848 00852 bool doNotFracture; 00853 00857 bool doNotDamage; 00858 00868 bool doNotCrumble; 00869 00870 #if APEX_RUNTIME_FRACTURE 00871 00875 bool runtimeFracture; 00876 #endif 00877 00885 bool useInstancedRendering; 00886 00892 PxVec3 instancePositionOffset; 00893 00899 PxVec2 instanceUVOffset; 00900 00907 uint16_t meshIndex; 00908 00913 int32_t parentIndex; 00914 00918 PxVec3 surfaceNormal; 00919 00923 int8_t behaviorGroupIndex; 00924 00929 uint32_t scatterMeshCount; 00930 00936 const uint8_t* scatterMeshIndices; 00937 00944 const PxMat44* scatterMeshTransforms; 00945 }; 00946 00947 // DestructibleChunkDesc inline functions 00948 00949 PX_INLINE DestructibleChunkDesc::DestructibleChunkDesc() 00950 { 00951 setToDefault(); 00952 } 00953 00954 PX_INLINE void DestructibleChunkDesc::setToDefault() 00955 { 00956 ApexDesc::setToDefault(); 00957 isSupportChunk = false; 00958 doNotFracture = false; 00959 doNotDamage = false; 00960 doNotCrumble = false; 00961 #if APEX_RUNTIME_FRACTURE 00962 runtimeFracture = false; 00963 #endif 00964 useInstancedRendering = false; 00965 instancePositionOffset = PxVec3(0.0f); 00966 instanceUVOffset = PxVec2(0.0f); 00967 meshIndex = 0xFFFF; 00968 parentIndex = -1; 00969 surfaceNormal = PxVec3(0.0f); 00970 behaviorGroupIndex = -1; 00971 scatterMeshCount = 0; 00972 scatterMeshIndices = NULL; 00973 scatterMeshTransforms = NULL; 00974 } 00975 00976 PX_INLINE bool DestructibleChunkDesc::isValid() const 00977 { 00978 if (meshIndex == 0xFFFF) 00979 { 00980 return false; 00981 } 00982 00983 return ApexDesc::isValid(); 00984 } 00985 00986 00992 class DestructibleGeometryDesc : public ApexDesc 00993 { 00994 public: 00998 PX_INLINE DestructibleGeometryDesc(); 00999 01003 PX_INLINE void setToDefault(); 01004 01008 PX_INLINE bool isValid() const; 01009 01014 const nvidia::ExplicitHierarchicalMesh::ConvexHull** convexHulls; 01015 01021 uint32_t convexHullCount; 01022 01027 const CollisionVolumeDesc* collisionVolumeDesc; 01028 }; 01029 01030 // DestructibleGeometryDesc inline functions 01031 01032 PX_INLINE DestructibleGeometryDesc::DestructibleGeometryDesc() 01033 { 01034 setToDefault(); 01035 } 01036 01037 PX_INLINE void DestructibleGeometryDesc::setToDefault() 01038 { 01039 ApexDesc::setToDefault(); 01040 convexHulls = NULL; 01041 convexHullCount = 0; 01042 collisionVolumeDesc = NULL; 01043 } 01044 01045 PX_INLINE bool DestructibleGeometryDesc::isValid() const 01046 { 01047 if (convexHullCount == 0 && collisionVolumeDesc == NULL) 01048 { 01049 return false; 01050 } 01051 01052 if (convexHullCount > 0 && convexHulls == NULL) 01053 { 01054 return false; 01055 } 01056 01057 return ApexDesc::isValid(); 01058 } 01059 01060 01066 class DestructibleAssetCookingDesc : public ApexDesc 01067 { 01068 public: 01072 PX_INLINE DestructibleAssetCookingDesc(); 01073 01077 PX_INLINE void setToDefault(); 01078 01082 PX_INLINE bool isValid() const; 01083 01087 DestructibleChunkDesc* chunkDescs; 01088 01092 uint32_t chunkDescCount; 01093 01097 DestructibleBehaviorGroupDesc defaultBehaviorGroupDesc; 01098 01102 DestructibleBehaviorGroupDesc* behaviorGroupDescs; 01103 01107 uint32_t behaviorGroupDescCount; 01108 01112 int8_t RTFractureBehaviorGroup; 01113 01117 DestructibleGeometryDesc* geometryDescs; 01118 01122 uint32_t geometryDescCount; 01123 01129 nvidia::IntPair* supportGraphEdges; 01130 01134 uint32_t supportGraphEdgeCount; 01135 }; 01136 01137 // DestructibleAssetCookingDesc inline functions 01138 01139 PX_INLINE DestructibleAssetCookingDesc::DestructibleAssetCookingDesc() 01140 { 01141 setToDefault(); 01142 } 01143 01144 PX_INLINE void DestructibleAssetCookingDesc::setToDefault() 01145 { 01146 ApexDesc::setToDefault(); 01147 chunkDescs = NULL; 01148 chunkDescCount = 0; 01149 geometryDescs = NULL; 01150 geometryDescCount = 0; 01151 behaviorGroupDescs = 0; 01152 behaviorGroupDescCount = 0; 01153 supportGraphEdges = 0; 01154 supportGraphEdgeCount = 0; 01155 } 01156 01157 PX_INLINE bool DestructibleAssetCookingDesc::isValid() const 01158 { 01159 if (chunkDescCount == 0 || chunkDescs == NULL) 01160 { 01161 return false; 01162 } 01163 01164 for (uint32_t i = 0; i < chunkDescCount; ++i ) 01165 { 01166 if (!chunkDescs[i].isValid()) 01167 { 01168 return false; 01169 } 01170 } 01171 01172 if (chunkDescCount >= 65535) 01173 { 01174 return false; 01175 } 01176 01177 if (geometryDescCount == 0 || geometryDescs == NULL) 01178 { 01179 return false; 01180 } 01181 01182 for (uint32_t i = 0; i < geometryDescCount; ++i ) 01183 { 01184 if (!geometryDescs[i].isValid()) 01185 { 01186 return false; 01187 } 01188 } 01189 01190 if (behaviorGroupDescCount > 127) 01191 { 01192 return false; 01193 } 01194 01195 for (uint32_t i = 0; i < behaviorGroupDescCount; ++i ) 01196 { 01197 if (!behaviorGroupDescs[i].isValid()) 01198 { 01199 return false; 01200 } 01201 } 01202 01203 return ApexDesc::isValid(); 01204 } 01205 01206 01210 struct DestructibleAssetStats 01211 { 01212 uint32_t totalBytes; 01213 uint32_t chunkCount; 01214 uint32_t chunkBytes; 01215 uint32_t chunkHullDataBytes; 01216 uint32_t collisionCookedHullDataBytes; 01217 uint32_t collisionMeshCount; 01218 uint32_t maxHullVertexCount; 01219 uint32_t maxHullFaceCount; 01220 uint32_t chunkWithMaxEdgeCount; 01221 uint32_t runtimeCookedConvexCount; 01222 RenderMeshAssetStats renderMeshAssetStats; 01223 }; 01224 01228 class DestructibleAssetAuthoring : public AssetAuthoring 01229 { 01230 public: 01231 01241 virtual ExplicitHierarchicalMesh& getExplicitHierarchicalMesh() = 0; 01242 01248 virtual ExplicitHierarchicalMesh& getCoreExplicitHierarchicalMesh() = 0; 01249 01255 virtual FractureTools::CutoutSet& getCutoutSet() = 0; 01256 01268 virtual uint32_t partitionMeshByIslands 01269 ( 01270 nvidia::ExplicitRenderTriangle* mesh, 01271 uint32_t meshTriangleCount, 01272 uint32_t* meshPartition, 01273 uint32_t meshPartitionMaxCount, 01274 float padding = 0.0001f 01275 ) = 0; 01276 01298 virtual bool setRootMesh 01299 ( 01300 const ExplicitRenderTriangle* meshTriangles, 01301 uint32_t meshTriangleCount, 01302 const ExplicitSubmeshData* submeshData, 01303 uint32_t submeshCount, 01304 uint32_t* meshPartition = NULL, 01305 uint32_t meshPartitionCount = 0, 01306 int32_t* parentIndices = NULL, 01307 uint32_t parentIndexCount = 0 01308 ) = 0; 01309 01317 virtual bool importRenderMeshAssetToRootMesh(const nvidia::RenderMeshAsset& renderMeshAsset, uint32_t maxRootDepth = UINT32_MAX) = 0; 01318 01327 virtual bool importDestructibleAssetToRootMesh(const nvidia::DestructibleAsset& destructibleAsset, uint32_t maxRootDepth = UINT32_MAX) = 0; 01328 01341 virtual bool setCoreMesh 01342 ( 01343 const ExplicitRenderTriangle* mesh, 01344 uint32_t meshTriangleCount, 01345 const ExplicitSubmeshData* submeshData, 01346 uint32_t submeshCount, 01347 uint32_t* meshPartition = NULL, 01348 uint32_t meshPartitionCount = 0 01349 ) = 0; 01350 01375 virtual bool buildExplicitHierarchicalMesh 01376 ( 01377 ExplicitHierarchicalMesh& hMesh, 01378 const ExplicitRenderTriangle* meshTriangles, 01379 uint32_t meshTriangleCount, 01380 const ExplicitSubmeshData* submeshData, 01381 uint32_t submeshCount, 01382 uint32_t* meshPartition = NULL, 01383 uint32_t meshPartitionCount = 0, 01384 int32_t* parentIndices = NULL, 01385 uint32_t parentIndexCount = 0 01386 ) = 0; 01387 01403 virtual bool createHierarchicallySplitMesh 01404 ( 01405 const FractureTools::MeshProcessingParameters& meshProcessingParams, 01406 const FractureTools::FractureSliceDesc& desc, 01407 const CollisionDesc& collisionDesc, 01408 bool exportCoreMesh, 01409 int32_t coreMeshImprintSubmeshIndex, 01410 uint32_t randomSeed, 01411 IProgressListener& progressListener, 01412 volatile bool* cancel = NULL 01413 ) = 0; 01414 01431 virtual bool createChippedMesh 01432 ( 01433 const FractureTools::MeshProcessingParameters& meshProcessingParams, 01434 const FractureTools::FractureCutoutDesc& desc, 01435 const FractureTools::CutoutSet& cutoutSet, 01436 const FractureTools::FractureSliceDesc& sliceDesc, 01437 const FractureTools::FractureVoronoiDesc& voronoiDesc, 01438 const CollisionDesc& collisionDesc, 01439 uint32_t randomSeed, 01440 IProgressListener& progressListener, 01441 volatile bool* cancel = NULL 01442 ) = 0; 01443 01453 virtual void buildCutoutSet 01454 ( 01455 const uint8_t* pixelBuffer, 01456 uint32_t bufferWidth, 01457 uint32_t bufferHeight, 01458 float snapThreshold, 01459 bool periodic 01460 ) = 0; 01461 01470 virtual bool calculateCutoutUVMapping 01471 ( 01472 PxMat33& mapping, 01473 const nvidia::ExplicitRenderTriangle& triangle 01474 ) = 0; 01475 01487 virtual bool calculateCutoutUVMapping 01488 ( 01489 PxMat33& mapping, 01490 const PxVec3& targetDirection 01491 ) = 0; 01492 01508 virtual bool createVoronoiSplitMesh 01509 ( 01510 const FractureTools::MeshProcessingParameters& meshProcessingParams, 01511 const FractureTools::FractureVoronoiDesc& desc, 01512 const CollisionDesc& collisionDesc, 01513 bool exportCoreMesh, 01514 int32_t coreMeshImprintSubmeshIndex, 01515 uint32_t randomSeed, 01516 IProgressListener& progressListener, 01517 volatile bool* cancel = NULL 01518 ) = 0; 01519 01539 virtual uint32_t createVoronoiSitesInsideMesh 01540 ( 01541 PxVec3* siteBuffer, 01542 uint32_t* siteChunkIndices, 01543 uint32_t siteCount, 01544 uint32_t* randomSeed, 01545 uint32_t* microgridSize, 01546 BSPOpenMode::Enum meshMode, 01547 IProgressListener& progressListener, 01548 uint32_t chunkIndex = 0xFFFFFFFF 01549 ) = 0; 01550 01573 virtual uint32_t createScatterMeshSites 01574 ( 01575 uint8_t* meshIndices, 01576 PxMat44* relativeTransforms, 01577 uint32_t* chunkMeshStarts, 01578 uint32_t scatterMeshInstancesBufferSize, 01579 uint32_t targetChunkCount, 01580 const uint16_t* targetChunkIndices, 01581 uint32_t* randomSeed, 01582 uint32_t scatterMeshAssetCount, 01583 nvidia::RenderMeshAsset** scatterMeshAssets, 01584 const uint32_t* minCount, 01585 const uint32_t* maxCount, 01586 const float* minScales, 01587 const float* maxScales, 01588 const float* maxAngles 01589 ) = 0; 01590 01604 virtual void visualizeVoronoiCells 01605 ( 01606 nvidia::RenderDebugInterface& debugRender, 01607 const PxVec3* sites, 01608 uint32_t siteCount, 01609 const uint32_t* cellColors, 01610 uint32_t cellColorCount, 01611 const PxBounds3& bounds, 01612 uint32_t cellIndex = 0xFFFFFFFF 01613 ) = 0; 01614 01629 virtual bool hierarchicallySplitChunk 01630 ( 01631 uint32_t chunkIndex, 01632 const FractureTools::MeshProcessingParameters& meshProcessingParams, 01633 const FractureTools::FractureSliceDesc& desc, 01634 const CollisionDesc& collisionDesc, 01635 uint32_t* randomSeed, 01636 IProgressListener& progressListener, 01637 volatile bool* cancel = NULL 01638 ) = 0; 01639 01654 virtual bool voronoiSplitChunk 01655 ( 01656 uint32_t chunkIndex, 01657 const FractureTools::MeshProcessingParameters& meshProcessingParams, 01658 const FractureTools::FractureVoronoiDesc& desc, 01659 const CollisionDesc& collisionDesc, 01660 uint32_t* randomSeed, 01661 IProgressListener& progressListener, 01662 volatile bool* cancel = NULL 01663 ) = 0; 01664 01674 virtual void setBSPTolerances 01675 ( 01676 float linearTolerance, 01677 float angularTolerance, 01678 float baseTolerance, 01679 float clipTolerance, 01680 float cleaningTolerance 01681 ) = 0; 01682 01701 virtual void setBSPBuildParameters 01702 ( 01703 float logAreaSigmaThreshold, 01704 uint32_t testSetSize, 01705 float splitWeight, 01706 float imbalanceWeight 01707 ) = 0; 01708 01709 01718 virtual ExplicitHierarchicalMesh::ConvexHull* createExplicitHierarchicalMeshConvexHull() = 0; 01719 01726 virtual uint32_t buildSliceMesh(const ExplicitRenderTriangle*& mesh, const FractureTools::NoiseParameters& noiseParameters, const PxPlane& slicePlane, uint32_t randomSeed) = 0; 01727 01732 virtual void serializeFractureToolState(PxFileBuf& stream, nvidia::ExplicitHierarchicalMesh::Embedding& embedding) const = 0; 01733 01738 virtual void deserializeFractureToolState(PxFileBuf& stream, nvidia::ExplicitHierarchicalMesh::Embedding& embedding) = 0; 01739 01743 virtual void setChunkOverlapsCacheDepth(int32_t depth = -1) = 0; 01744 01748 virtual const RenderMeshAsset* getRenderMeshAsset() const = 0; 01749 01757 virtual bool setRenderMeshAsset(RenderMeshAsset*) = 0; 01758 01766 virtual bool setScatterMeshAssets(RenderMeshAsset** scatterMeshAssetArray, uint32_t scatterMeshAssetArraySize) = 0; 01767 01769 virtual uint32_t getScatterMeshAssetCount() const = 0; 01770 01772 virtual RenderMeshAsset* const * getScatterMeshAssets() const = 0; 01773 01777 virtual uint32_t getInstancedChunkMeshCount() const = 0; 01778 01782 virtual void setDestructibleParameters(const DestructibleParameters&) = 0; 01783 01788 virtual DestructibleParameters getDestructibleParameters() const = 0; 01789 01793 virtual void setDestructibleInitParameters(const DestructibleInitParameters&) = 0; 01794 01798 virtual DestructibleInitParameters getDestructibleInitParameters() const = 0; 01799 01803 virtual void setCrumbleEmitterName(const char*) = 0; 01804 01808 virtual void setDustEmitterName(const char*) = 0; 01809 01813 virtual void setFracturePatternName(const char*) = 0; 01814 01821 virtual void setNeighborPadding(float neighborPadding) = 0; 01822 01826 virtual float getNeighborPadding() const = 0; 01827 01842 virtual void cookChunks( const DestructibleAssetCookingDesc& cookingDesc, bool cacheOverlaps = true, 01843 uint32_t* chunkIndexMapUser2Apex = NULL, uint32_t* chunkIndexMapApex2User = NULL, uint32_t chunkIndexMapCount = 0) = 0; 01844 01849 virtual float getFractureImpulseScale() const = 0; 01850 01856 virtual float getImpactVelocityThreshold() const = 0; 01857 01861 virtual uint32_t getChunkCount() const = 0; 01862 01866 virtual uint32_t getDepthCount() const = 0; 01867 01872 virtual uint32_t getChunkChildCount(uint32_t chunkIndex) const = 0; 01873 01879 virtual int32_t getChunkChild(uint32_t chunkIndex, uint32_t childIndex) const = 0; 01880 01885 virtual PxVec3 getChunkPositionOffset(uint32_t chunkIndex) const = 0; 01886 01891 virtual PxVec2 getChunkUVOffset(uint32_t chunkIndex) const = 0; 01892 01896 virtual uint32_t getPartIndex(uint32_t chunkIndex) const = 0; 01897 01904 virtual void trimCollisionGeometry(const uint32_t* partIndices, uint32_t partIndexCount, float maxTrimFraction = 0.2f) = 0; 01905 01909 virtual void getStats(DestructibleAssetStats& stats) const = 0; 01910 01917 virtual void cacheChunkOverlapsUpToDepth(int32_t depth = -1) = 0; 01918 01925 virtual void clearChunkOverlaps(int32_t depth = -1, bool keepCachedFlag = false) = 0; 01926 01931 virtual void addChunkOverlaps(IntPair* supportGraphEdges, uint32_t numSupportGraphEdges) = 0; 01932 01941 virtual void removeChunkOverlaps(IntPair* supportGraphEdges, uint32_t numSupportGraphEdges, bool keepCachedFlagIfEmpty) = 0; 01942 01948 virtual uint32_t getCachedOverlapCountAtDepth(uint32_t depth) = 0; 01949 01956 virtual const IntPair* getCachedOverlapsAtDepth(uint32_t depth) = 0; 01957 01967 virtual void applyTransformation(const PxMat44& transformation, float scale) = 0; 01968 01977 virtual void applyTransformation(const PxMat44& transformation) = 0; 01978 01984 virtual bool setPlatformMaxDepth(PlatformTag platform, uint32_t maxDepth) = 0; 01985 01991 virtual bool removePlatformMaxDepth(PlatformTag platform) = 0; 01992 01996 virtual uint32_t getActorTransformCount() const = 0; 01997 02002 virtual const PxMat44* getActorTransforms() const = 0; 02003 02010 virtual void appendActorTransforms(const PxMat44* transforms, uint32_t transformCount) = 0; 02011 02015 virtual void clearActorTransforms() = 0; 02016 }; 02017 02021 class DestructibleAsset : public Asset 02022 { 02023 public: 02027 enum ChunkFlags 02028 { 02029 ChunkEnvironmentallySupported = (1 << 0), 02030 ChunkAndDescendentsDoNotFracture = (1 << 1), 02031 ChunkDoesNotFracture = (1 << 2), 02032 ChunkDoesNotCrumble = (1 << 3), 02033 #if APEX_RUNTIME_FRACTURE 02034 ChunkRuntimeFracture = (1 << 4), 02035 #endif 02036 ChunkIsInstanced = (1 << 16) 02037 }; 02038 02047 virtual void releaseDestructibleActor(DestructibleActor& actor) = 0; 02048 02049 02058 virtual DestructibleActor* createDestructibleActorFromDeserializedState(::NvParameterized::Interface* actorParams, Scene& apexScene) = 0; 02059 02064 virtual DestructibleParameters getDestructibleParameters() const = 0; 02065 02069 virtual DestructibleInitParameters getDestructibleInitParameters() const = 0; 02070 02075 virtual const char* getCrumbleEmitterName() const = 0; 02076 02081 virtual const char* getDustEmitterName() const = 0; 02082 02086 virtual uint32_t getChunkCount() const = 0; 02087 02091 virtual uint32_t getDepthCount() const = 0; 02092 02096 virtual const RenderMeshAsset* getRenderMeshAsset() const = 0; 02097 02104 virtual bool setRenderMeshAsset(RenderMeshAsset*) = 0; 02105 02107 virtual uint32_t getScatterMeshAssetCount() const = 0; 02108 02110 virtual RenderMeshAsset* const * getScatterMeshAssets() const = 0; 02111 02115 virtual uint32_t getInstancedChunkMeshCount() const = 0; 02116 02120 virtual void getStats(DestructibleAssetStats& stats) const = 0; 02121 02128 virtual void cacheChunkOverlapsUpToDepth(int32_t depth = -1) = 0; 02129 02137 virtual void clearChunkOverlaps(int32_t depth = -1, bool keepCachedFlag = false) = 0; 02138 02146 virtual void addChunkOverlaps(IntPair* supportGraphEdges, uint32_t numSupportGraphEdges) = 0; 02147 02156 virtual void removeChunkOverlaps(IntPair* supportGraphEdges, uint32_t numSupportGraphEdges, bool keepCachedFlagIfEmpty) = 0; 02157 02162 virtual uint32_t getCachedOverlapCountAtDepth(uint32_t depth) const = 0; 02163 02170 virtual const IntPair* getCachedOverlapsAtDepth(uint32_t depth) const = 0; 02171 02176 virtual PxVec3 getChunkPositionOffset(uint32_t chunkIndex) const = 0; 02177 02182 virtual PxVec2 getChunkUVOffset(uint32_t chunkIndex) const = 0; 02183 02187 virtual uint32_t getChunkFlags(uint32_t chunkIndex) const = 0; 02188 02192 virtual uint16_t getChunkDepth(uint32_t chunkIndex) const = 0; 02193 02198 virtual int32_t getChunkParentIndex(uint32_t chunkIndex) const = 0; 02199 02203 virtual PxBounds3 getChunkActorLocalBounds(uint32_t chunkIndex) const = 0; 02204 02208 virtual uint32_t getPartIndex(uint32_t chunkIndex) const = 0; 02209 02213 virtual uint32_t getPartConvexHullCount(const uint32_t partIndex) const = 0; 02214 02218 virtual NvParameterized::Interface** getPartConvexHullArray(const uint32_t partIndex) const = 0; 02219 02223 virtual uint32_t getActorTransformCount() const = 0; 02224 02229 virtual const PxMat44* getActorTransforms() const = 0; 02230 02240 virtual void applyTransformation(const PxMat44& transformation, float scale) = 0; 02241 02250 virtual void applyTransformation(const PxMat44& transformation) = 0; 02251 02256 virtual bool rebuildCollisionGeometry(uint32_t partIndex, const DestructibleGeometryDesc& geometryDesc) = 0; 02257 02258 protected: 02260 virtual ~DestructibleAsset() {} 02261 }; 02262 02263 02264 #if !PX_PS4 02265 #pragma warning(pop) 02266 #endif //!PX_PS4 02267 02268 PX_POP_PACK 02269 02270 } 02271 } // end namespace nvidia 02272 02273 #endif // DESTRUCTIBLE_ASSET_H
Generated on Fri Dec 15 2017 13:58:35 Copyright © 2012-2017 NVIDIA Corporation, 2701 San Tomas Expressway, Santa Clara, CA 95050 U.S.A. All rights reserved.