00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifndef DESTRUCTIBLE_ASSET_H
00031 #define DESTRUCTIBLE_ASSET_H
00032
00033 #define DESTRUCTIBLE_AUTHORING_TYPE_NAME "DestructibleAsset"
00034
00035 #include "foundation/Px.h"
00036 #include "FractureToolsAPI.h"
00037
00038 #include "ModuleDestructible.h"
00039
00040 #if PX_PHYSICS_VERSION_MAJOR == 3
00041 #include "PxFiltering.h"
00042 #endif
00043
00044 namespace nvidia
00045 {
00046 namespace apex
00047 {
00048
00049 struct IntPair;
00050 class DestructibleActor;
00051 class DestructiblePreview;
00052
00053 PX_PUSH_PACK_DEFAULT
00054 #if !PX_PS4
00055 #pragma warning(push)
00056 #pragma warning(disable:4121)
00057 #endif //!PX_PS4
00058
00062 struct DestructibleDepthParametersFlag
00063 {
00067 enum Enum
00068 {
00074 OVERRIDE_IMPACT_DAMAGE = (1 << 0),
00075
00079 OVERRIDE_IMPACT_DAMAGE_VALUE = (1 << 1),
00080
00084 IGNORE_POSE_UPDATES = (1 << 2),
00085
00089 IGNORE_RAYCAST_CALLBACKS = (1 << 3),
00090
00094 IGNORE_CONTACT_CALLBACKS = (1 << 4),
00095
00099 USER_FLAG_0 = (1 << 24),
00100 USER_FLAG_1 = (1 << 25),
00101 USER_FLAG_2 = (1 << 26),
00102 USER_FLAG_3 = (1 << 27)
00103 };
00104 };
00105
00106
00110 struct DestructibleDepthParameters
00111 {
00115 PX_INLINE DestructibleDepthParameters();
00116
00120 PX_INLINE void setToDefault();
00121
00125 PX_INLINE void setToMostExpensive();
00126
00130 PX_INLINE bool overrideImpactDamage() const;
00131
00135 PX_INLINE bool overrideImpactDamageValue() const;
00136
00140 PX_INLINE bool ignoresPoseUpdates() const;
00141
00145 PX_INLINE bool ignoresRaycastCallbacks() const;
00146
00150 PX_INLINE bool ignoresContactCallbacks() const;
00151
00155 PX_INLINE bool hasUserFlagSet(uint32_t flagIndex) const;
00156
00160 uint32_t flags;
00161 };
00162
00163
00164
00165 PX_INLINE DestructibleDepthParameters::DestructibleDepthParameters()
00166 {
00167 setToDefault();
00168 }
00169
00170 PX_INLINE void DestructibleDepthParameters::setToDefault()
00171 {
00172 flags = 0;
00173 }
00174
00175 PX_INLINE bool DestructibleDepthParameters::overrideImpactDamage() const
00176 {
00177 return (flags & DestructibleDepthParametersFlag::OVERRIDE_IMPACT_DAMAGE) != 0;
00178 }
00179
00180 PX_INLINE bool DestructibleDepthParameters::overrideImpactDamageValue() const
00181 {
00182 return (flags & DestructibleDepthParametersFlag::OVERRIDE_IMPACT_DAMAGE_VALUE) != 0;
00183 }
00184
00185 PX_INLINE bool DestructibleDepthParameters::ignoresPoseUpdates() const
00186 {
00187 return (flags & DestructibleDepthParametersFlag::IGNORE_POSE_UPDATES) != 0;
00188 }
00189
00190 PX_INLINE bool DestructibleDepthParameters::ignoresRaycastCallbacks() const
00191 {
00192 return (flags & DestructibleDepthParametersFlag::IGNORE_RAYCAST_CALLBACKS) != 0;
00193 }
00194
00195 PX_INLINE bool DestructibleDepthParameters::ignoresContactCallbacks() const
00196 {
00197 return (flags & DestructibleDepthParametersFlag::IGNORE_CONTACT_CALLBACKS) != 0;
00198 }
00199
00200 PX_INLINE bool DestructibleDepthParameters::hasUserFlagSet(uint32_t flagIndex) const
00201 {
00202 switch (flagIndex)
00203 {
00204 case 0:
00205 return (flags & DestructibleDepthParametersFlag::USER_FLAG_0) != 0;
00206 case 1:
00207 return (flags & DestructibleDepthParametersFlag::USER_FLAG_1) != 0;
00208 case 2:
00209 return (flags & DestructibleDepthParametersFlag::USER_FLAG_2) != 0;
00210 case 3:
00211 return (flags & DestructibleDepthParametersFlag::USER_FLAG_3) != 0;
00212 default:
00213 return false;
00214 }
00215 }
00216
00220 struct DestructibleRTFractureParameters
00221 {
00226 bool sheetFracture;
00227
00232 uint32_t depthLimit;
00233
00238 bool destroyIfAtDepthLimit;
00239
00243 float minConvexSize;
00244
00248 float impulseScale;
00249
00253 struct FractureGlass
00254 {
00258 uint32_t numSectors;
00259
00263 float sectorRand;
00264
00268 float firstSegmentSize;
00269
00273 float segmentScale;
00274
00278 float segmentRand;
00279 }glass;
00280
00284 struct FractureAttachment
00285 {
00289 bool posX;
00290
00294 bool negX;
00295
00299 bool posY;
00300
00304 bool negY;
00305
00309 bool posZ;
00310
00314 bool negZ;
00315 }attachment;
00316
00320 PX_INLINE void setToDefault();
00321 };
00322
00323 PX_INLINE void DestructibleRTFractureParameters::setToDefault()
00324 {
00325 sheetFracture = true;
00326 depthLimit = 2;
00327 destroyIfAtDepthLimit = false;
00328 minConvexSize = 0.02f;
00329 impulseScale = 1.0f;
00330 glass.numSectors = 10;
00331 glass.sectorRand = 0.3f;
00332 glass.firstSegmentSize = 0.06f;
00333 glass.segmentScale = 1.4f;
00334 glass.segmentRand = 0.3f;
00335 attachment.posX = false;
00336 attachment.negX = false;
00337 attachment.posY = false;
00338 attachment.negY = false;
00339 attachment.posZ = false;
00340 attachment.negZ = false;
00341 }
00342
00346 struct DestructibleParametersFlag
00347 {
00351 enum Enum
00352 {
00358 ACCUMULATE_DAMAGE = (1 << 0),
00359
00365 DEBRIS_TIMEOUT = (1 << 1),
00366
00373 DEBRIS_MAX_SEPARATION = (1 << 2),
00374
00382 CRUMBLE_SMALLEST_CHUNKS = (1 << 3),
00383
00390 ACCURATE_RAYCASTS = (1 << 4),
00391
00397 USE_VALID_BOUNDS = (1 << 5),
00398
00404 CRUMBLE_VIA_RUNTIME_FRACTURE = (1 << 6),
00405 };
00406 };
00407
00408
00412 struct DestructibleParameters
00413 {
00417 PX_INLINE DestructibleParameters();
00418
00422 PX_INLINE void setToDefault();
00423
00429 float damageCap;
00430
00437 float forceToDamage;
00438
00445 float impactVelocityThreshold;
00446
00450 uint32_t minimumFractureDepth;
00451
00457 int32_t impactDamageDefaultDepth;
00458
00465 int32_t debrisDepth;
00466
00473 uint32_t essentialDepth;
00474
00483 float debrisLifetimeMin;
00484
00486 float debrisLifetimeMax;
00487
00496 float debrisMaxSeparationMin;
00497
00499 float debrisMaxSeparationMax;
00500
00506 float debrisDestructionProbability;
00507
00513 PxBounds3 validBounds;
00514
00519 float maxChunkSpeed;
00520
00524 uint32_t flags;
00525
00530 float fractureImpulseScale;
00531
00536 uint16_t damageDepthLimit;
00537
00541 uint8_t dynamicChunksDominanceGroup;
00542
00547 bool useDynamicChunksGroupsMask;
00548
00549 #if PX_PHYSICS_VERSION_MAJOR == 3
00550
00553 physx::PxFilterData dynamicChunksFilterData;
00554 #endif
00555
00559 float supportStrength;
00560
00566 int8_t legacyChunkBoundsTestSetting;
00567
00573 int8_t legacyDamageRadiusSpreadSetting;
00574
00578 enum { kDepthParametersCountMax = 16 };
00579
00584 uint32_t depthParametersCount;
00585
00592 DestructibleDepthParameters depthParameters[kDepthParametersCountMax];
00593
00597 DestructibleRTFractureParameters rtFractureParameters;
00598
00603 bool alwaysDrawScatterMesh;
00604 };
00605
00606
00607
00608 PX_INLINE DestructibleParameters::DestructibleParameters()
00609 {
00610 setToDefault();
00611 }
00612
00613 PX_INLINE void DestructibleParameters::setToDefault()
00614 {
00615 damageCap = 0;
00616 forceToDamage = 0;
00617 impactVelocityThreshold = 0.0f;
00618 minimumFractureDepth = 0;
00619 impactDamageDefaultDepth = -1;
00620 debrisDepth = -1;
00621 essentialDepth = 0;
00622 debrisLifetimeMin = 1.0f;
00623 debrisLifetimeMax = 10.0f;
00624 debrisMaxSeparationMin = 1.0f;
00625 debrisMaxSeparationMax = 10.0f;
00626 debrisDestructionProbability = 0.0f;
00627 validBounds = PxBounds3(PxVec3(-10000.0f), PxVec3(10000.0f));
00628 maxChunkSpeed = 0.0f;
00629 fractureImpulseScale = 0.0f;
00630 damageDepthLimit = UINT16_MAX;
00631 useDynamicChunksGroupsMask = false;
00632 #if PX_PHYSICS_VERSION_MAJOR == 3
00633 dynamicChunksFilterData.word0 = dynamicChunksFilterData.word1 = dynamicChunksFilterData.word2 = dynamicChunksFilterData.word3 = 0;
00634 #endif
00635 supportStrength = -1.0;
00636 legacyChunkBoundsTestSetting = -1;
00637 legacyDamageRadiusSpreadSetting = -1;
00638 dynamicChunksDominanceGroup = 0xFF;
00639 flags = DestructibleParametersFlag::ACCUMULATE_DAMAGE;
00640 depthParametersCount = 0;
00641 rtFractureParameters.setToDefault();
00642 alwaysDrawScatterMesh = false;
00643 }
00644
00648 struct DestructibleInitParametersFlag
00649 {
00653 enum Enum
00654 {
00661 ASSET_DEFINED_SUPPORT = (1 << 0),
00662
00669 WORLD_SUPPORT = (1 << 1),
00670
00675 FORM_EXTENDED_STRUCTURES = (1 << 2)
00676 };
00677 };
00678
00682 struct DestructibleInitParameters
00683 {
00687 PX_INLINE DestructibleInitParameters();
00688
00692 PX_INLINE void setToDefault();
00693
00698 uint32_t supportDepth;
00699
00703 uint32_t flags;
00704 };
00705
00706
00707
00708
00709 PX_INLINE DestructibleInitParameters::DestructibleInitParameters()
00710 {
00711 setToDefault();
00712 }
00713
00714 PX_INLINE void DestructibleInitParameters::setToDefault()
00715 {
00716 supportDepth = 0;
00717 flags = 0;
00718 }
00719
00723 struct DamageSpreadFunction
00724 {
00725 PX_INLINE DamageSpreadFunction()
00726 {
00727 setToDefault();
00728 }
00729
00733 PX_INLINE void setToDefault()
00734 {
00735 minimumRadius = 0.0f;
00736 radiusMultiplier = 1.0f;
00737 falloffExponent = 1.0f;
00738 }
00739
00743 PX_INLINE bool isValid() const
00744 {
00745 return
00746 minimumRadius >= 0.0f &&
00747 radiusMultiplier >= 0.0f &&
00748 falloffExponent >= 0.0f;
00749 }
00750
00751 float minimumRadius;
00752 float radiusMultiplier;
00753 float falloffExponent;
00754 };
00755
00761 class DestructibleBehaviorGroupDesc : public ApexDesc
00762 {
00763 public:
00767 PX_INLINE DestructibleBehaviorGroupDesc();
00768
00772 PX_INLINE void setToDefault();
00773
00777 PX_INLINE bool isValid() const;
00778
00783 const char* name;
00784 float damageThreshold;
00785 float damageToRadius;
00786 DamageSpreadFunction damageSpread;
00787 DamageSpreadFunction damageColorSpread;
00788 PxVec4 damageColorChange;
00789 float materialStrength;
00790 float density;
00791 float fadeOut;
00792 float maxDepenetrationVelocity;
00793 uint64_t userData;
00794 };
00795
00796
00797
00798 PX_INLINE DestructibleBehaviorGroupDesc::DestructibleBehaviorGroupDesc()
00799 {
00800 setToDefault();
00801 }
00802
00803 PX_INLINE void DestructibleBehaviorGroupDesc::setToDefault()
00804 {
00805 ApexDesc::setToDefault();
00806
00807
00808 name = NULL;
00809 damageThreshold = 1.0f;
00810 damageToRadius = 0.1f;
00811 damageSpread.setToDefault();
00812 damageColorSpread.setToDefault();
00813 damageColorChange.setZero();
00814 materialStrength = 0.0f;
00815 density = 0;
00816 fadeOut = 1;
00817 maxDepenetrationVelocity = PX_MAX_F32;
00818 userData = (uint64_t)0;
00819 }
00820
00821 PX_INLINE bool DestructibleBehaviorGroupDesc::isValid() const
00822 {
00823
00824 if (damageThreshold < 0 ||
00825 damageToRadius < 0 ||
00826 !damageSpread.isValid() ||
00827 !damageColorSpread.isValid() ||
00828 materialStrength < 0 ||
00829 density < 0 ||
00830 fadeOut < 0 ||
00831 !(maxDepenetrationVelocity > 0.f))
00832 {
00833 return false;
00834 }
00835
00836 return ApexDesc::isValid();
00837 }
00843 class DestructibleChunkDesc : public ApexDesc
00844 {
00845 public:
00849 PX_INLINE DestructibleChunkDesc();
00850
00854 PX_INLINE void setToDefault();
00855
00859 PX_INLINE bool isValid() const;
00860
00865 bool isSupportChunk;
00866
00870 bool doNotFracture;
00871
00875 bool doNotDamage;
00876
00886 bool doNotCrumble;
00887
00888 #if APEX_RUNTIME_FRACTURE
00889
00893 bool runtimeFracture;
00894 #endif
00895
00903 bool useInstancedRendering;
00904
00910 PxVec3 instancePositionOffset;
00911
00917 PxVec2 instanceUVOffset;
00918
00925 uint16_t meshIndex;
00926
00931 int32_t parentIndex;
00932
00936 PxVec3 surfaceNormal;
00937
00941 int8_t behaviorGroupIndex;
00942
00947 uint32_t scatterMeshCount;
00948
00954 const uint8_t* scatterMeshIndices;
00955
00962 const PxMat44* scatterMeshTransforms;
00963 };
00964
00965
00966
00967 PX_INLINE DestructibleChunkDesc::DestructibleChunkDesc()
00968 {
00969 setToDefault();
00970 }
00971
00972 PX_INLINE void DestructibleChunkDesc::setToDefault()
00973 {
00974 ApexDesc::setToDefault();
00975 isSupportChunk = false;
00976 doNotFracture = false;
00977 doNotDamage = false;
00978 doNotCrumble = false;
00979 #if APEX_RUNTIME_FRACTURE
00980 runtimeFracture = false;
00981 #endif
00982 useInstancedRendering = false;
00983 instancePositionOffset = PxVec3(0.0f);
00984 instanceUVOffset = PxVec2(0.0f);
00985 meshIndex = 0xFFFF;
00986 parentIndex = -1;
00987 surfaceNormal = PxVec3(0.0f);
00988 behaviorGroupIndex = -1;
00989 scatterMeshCount = 0;
00990 scatterMeshIndices = NULL;
00991 scatterMeshTransforms = NULL;
00992 }
00993
00994 PX_INLINE bool DestructibleChunkDesc::isValid() const
00995 {
00996 if (meshIndex == 0xFFFF)
00997 {
00998 return false;
00999 }
01000
01001 return ApexDesc::isValid();
01002 }
01003
01004
01010 class DestructibleGeometryDesc : public ApexDesc
01011 {
01012 public:
01016 PX_INLINE DestructibleGeometryDesc();
01017
01021 PX_INLINE void setToDefault();
01022
01026 PX_INLINE bool isValid() const;
01027
01032 const nvidia::ExplicitHierarchicalMesh::ConvexHull** convexHulls;
01033
01039 uint32_t convexHullCount;
01040
01045 const CollisionVolumeDesc* collisionVolumeDesc;
01046 };
01047
01048
01049
01050 PX_INLINE DestructibleGeometryDesc::DestructibleGeometryDesc()
01051 {
01052 setToDefault();
01053 }
01054
01055 PX_INLINE void DestructibleGeometryDesc::setToDefault()
01056 {
01057 ApexDesc::setToDefault();
01058 convexHulls = NULL;
01059 convexHullCount = 0;
01060 collisionVolumeDesc = NULL;
01061 }
01062
01063 PX_INLINE bool DestructibleGeometryDesc::isValid() const
01064 {
01065 if (convexHullCount == 0 && collisionVolumeDesc == NULL)
01066 {
01067 return false;
01068 }
01069
01070 if (convexHullCount > 0 && convexHulls == NULL)
01071 {
01072 return false;
01073 }
01074
01075 return ApexDesc::isValid();
01076 }
01077
01078
01084 class DestructibleAssetCookingDesc : public ApexDesc
01085 {
01086 public:
01090 PX_INLINE DestructibleAssetCookingDesc();
01091
01095 PX_INLINE void setToDefault();
01096
01100 PX_INLINE bool isValid() const;
01101
01105 DestructibleChunkDesc* chunkDescs;
01106
01110 uint32_t chunkDescCount;
01111
01115 DestructibleBehaviorGroupDesc defaultBehaviorGroupDesc;
01116
01120 DestructibleBehaviorGroupDesc* behaviorGroupDescs;
01121
01125 uint32_t behaviorGroupDescCount;
01126
01130 int8_t RTFractureBehaviorGroup;
01131
01135 DestructibleGeometryDesc* geometryDescs;
01136
01140 uint32_t geometryDescCount;
01141
01147 nvidia::IntPair* supportGraphEdges;
01148
01152 uint32_t supportGraphEdgeCount;
01153 };
01154
01155
01156
01157 PX_INLINE DestructibleAssetCookingDesc::DestructibleAssetCookingDesc()
01158 {
01159 setToDefault();
01160 }
01161
01162 PX_INLINE void DestructibleAssetCookingDesc::setToDefault()
01163 {
01164 ApexDesc::setToDefault();
01165 chunkDescs = NULL;
01166 chunkDescCount = 0;
01167 geometryDescs = NULL;
01168 geometryDescCount = 0;
01169 behaviorGroupDescs = 0;
01170 behaviorGroupDescCount = 0;
01171 supportGraphEdges = 0;
01172 supportGraphEdgeCount = 0;
01173 }
01174
01175 PX_INLINE bool DestructibleAssetCookingDesc::isValid() const
01176 {
01177 if (chunkDescCount == 0 || chunkDescs == NULL)
01178 {
01179 return false;
01180 }
01181
01182 for (uint32_t i = 0; i < chunkDescCount; ++i )
01183 {
01184 if (!chunkDescs[i].isValid())
01185 {
01186 return false;
01187 }
01188 }
01189
01190 if (chunkDescCount >= 65535)
01191 {
01192 return false;
01193 }
01194
01195 if (geometryDescCount == 0 || geometryDescs == NULL)
01196 {
01197 return false;
01198 }
01199
01200 for (uint32_t i = 0; i < geometryDescCount; ++i )
01201 {
01202 if (!geometryDescs[i].isValid())
01203 {
01204 return false;
01205 }
01206 }
01207
01208 if (behaviorGroupDescCount > 127)
01209 {
01210 return false;
01211 }
01212
01213 for (uint32_t i = 0; i < behaviorGroupDescCount; ++i )
01214 {
01215 if (!behaviorGroupDescs[i].isValid())
01216 {
01217 return false;
01218 }
01219 }
01220
01221 return ApexDesc::isValid();
01222 }
01223
01224
01228 struct DestructibleAssetStats
01229 {
01230 uint32_t totalBytes;
01231 uint32_t chunkCount;
01232 uint32_t chunkBytes;
01233 uint32_t chunkHullDataBytes;
01234 uint32_t collisionCookedHullDataBytes;
01235 uint32_t collisionMeshCount;
01236 uint32_t maxHullVertexCount;
01237 uint32_t maxHullFaceCount;
01238 uint32_t chunkWithMaxEdgeCount;
01239 uint32_t runtimeCookedConvexCount;
01240 RenderMeshAssetStats renderMeshAssetStats;
01241 };
01242
01246 class DestructibleAssetAuthoring : public AssetAuthoring
01247 {
01248 public:
01249
01259 virtual ExplicitHierarchicalMesh& getExplicitHierarchicalMesh() = 0;
01260
01266 virtual ExplicitHierarchicalMesh& getCoreExplicitHierarchicalMesh() = 0;
01267
01273 virtual FractureTools::CutoutSet& getCutoutSet() = 0;
01274
01286 virtual uint32_t partitionMeshByIslands
01287 (
01288 nvidia::ExplicitRenderTriangle* mesh,
01289 uint32_t meshTriangleCount,
01290 uint32_t* meshPartition,
01291 uint32_t meshPartitionMaxCount,
01292 float padding = 0.0001f
01293 ) = 0;
01294
01316 virtual bool setRootMesh
01317 (
01318 const ExplicitRenderTriangle* meshTriangles,
01319 uint32_t meshTriangleCount,
01320 const ExplicitSubmeshData* submeshData,
01321 uint32_t submeshCount,
01322 uint32_t* meshPartition = NULL,
01323 uint32_t meshPartitionCount = 0,
01324 int32_t* parentIndices = NULL,
01325 uint32_t parentIndexCount = 0
01326 ) = 0;
01327
01335 virtual bool importRenderMeshAssetToRootMesh(const nvidia::RenderMeshAsset& renderMeshAsset, uint32_t maxRootDepth = UINT32_MAX) = 0;
01336
01345 virtual bool importDestructibleAssetToRootMesh(const nvidia::DestructibleAsset& destructibleAsset, uint32_t maxRootDepth = UINT32_MAX) = 0;
01346
01359 virtual bool setCoreMesh
01360 (
01361 const ExplicitRenderTriangle* mesh,
01362 uint32_t meshTriangleCount,
01363 const ExplicitSubmeshData* submeshData,
01364 uint32_t submeshCount,
01365 uint32_t* meshPartition = NULL,
01366 uint32_t meshPartitionCount = 0
01367 ) = 0;
01368
01393 virtual bool buildExplicitHierarchicalMesh
01394 (
01395 ExplicitHierarchicalMesh& hMesh,
01396 const ExplicitRenderTriangle* meshTriangles,
01397 uint32_t meshTriangleCount,
01398 const ExplicitSubmeshData* submeshData,
01399 uint32_t submeshCount,
01400 uint32_t* meshPartition = NULL,
01401 uint32_t meshPartitionCount = 0,
01402 int32_t* parentIndices = NULL,
01403 uint32_t parentIndexCount = 0
01404 ) = 0;
01405
01421 virtual bool createHierarchicallySplitMesh
01422 (
01423 const FractureTools::MeshProcessingParameters& meshProcessingParams,
01424 const FractureTools::FractureSliceDesc& desc,
01425 const CollisionDesc& collisionDesc,
01426 bool exportCoreMesh,
01427 int32_t coreMeshImprintSubmeshIndex,
01428 uint32_t randomSeed,
01429 IProgressListener& progressListener,
01430 volatile bool* cancel = NULL
01431 ) = 0;
01432
01449 virtual bool createChippedMesh
01450 (
01451 const FractureTools::MeshProcessingParameters& meshProcessingParams,
01452 const FractureTools::FractureCutoutDesc& desc,
01453 const FractureTools::CutoutSet& cutoutSet,
01454 const FractureTools::FractureSliceDesc& sliceDesc,
01455 const FractureTools::FractureVoronoiDesc& voronoiDesc,
01456 const CollisionDesc& collisionDesc,
01457 uint32_t randomSeed,
01458 IProgressListener& progressListener,
01459 volatile bool* cancel = NULL
01460 ) = 0;
01461
01471 virtual void buildCutoutSet
01472 (
01473 const uint8_t* pixelBuffer,
01474 uint32_t bufferWidth,
01475 uint32_t bufferHeight,
01476 float snapThreshold,
01477 bool periodic
01478 ) = 0;
01479
01488 virtual bool calculateCutoutUVMapping
01489 (
01490 PxMat33& mapping,
01491 const nvidia::ExplicitRenderTriangle& triangle
01492 ) = 0;
01493
01505 virtual bool calculateCutoutUVMapping
01506 (
01507 PxMat33& mapping,
01508 const PxVec3& targetDirection
01509 ) = 0;
01510
01526 virtual bool createVoronoiSplitMesh
01527 (
01528 const FractureTools::MeshProcessingParameters& meshProcessingParams,
01529 const FractureTools::FractureVoronoiDesc& desc,
01530 const CollisionDesc& collisionDesc,
01531 bool exportCoreMesh,
01532 int32_t coreMeshImprintSubmeshIndex,
01533 uint32_t randomSeed,
01534 IProgressListener& progressListener,
01535 volatile bool* cancel = NULL
01536 ) = 0;
01537
01557 virtual uint32_t createVoronoiSitesInsideMesh
01558 (
01559 PxVec3* siteBuffer,
01560 uint32_t* siteChunkIndices,
01561 uint32_t siteCount,
01562 uint32_t* randomSeed,
01563 uint32_t* microgridSize,
01564 BSPOpenMode::Enum meshMode,
01565 IProgressListener& progressListener,
01566 uint32_t chunkIndex = 0xFFFFFFFF
01567 ) = 0;
01568
01591 virtual uint32_t createScatterMeshSites
01592 (
01593 uint8_t* meshIndices,
01594 PxMat44* relativeTransforms,
01595 uint32_t* chunkMeshStarts,
01596 uint32_t scatterMeshInstancesBufferSize,
01597 uint32_t targetChunkCount,
01598 const uint16_t* targetChunkIndices,
01599 uint32_t* randomSeed,
01600 uint32_t scatterMeshAssetCount,
01601 nvidia::RenderMeshAsset** scatterMeshAssets,
01602 const uint32_t* minCount,
01603 const uint32_t* maxCount,
01604 const float* minScales,
01605 const float* maxScales,
01606 const float* maxAngles
01607 ) = 0;
01608
01622 virtual void visualizeVoronoiCells
01623 (
01624 nvidia::RenderDebugInterface& debugRender,
01625 const PxVec3* sites,
01626 uint32_t siteCount,
01627 const uint32_t* cellColors,
01628 uint32_t cellColorCount,
01629 const PxBounds3& bounds,
01630 uint32_t cellIndex = 0xFFFFFFFF
01631 ) = 0;
01632
01647 virtual bool hierarchicallySplitChunk
01648 (
01649 uint32_t chunkIndex,
01650 const FractureTools::MeshProcessingParameters& meshProcessingParams,
01651 const FractureTools::FractureSliceDesc& desc,
01652 const CollisionDesc& collisionDesc,
01653 uint32_t* randomSeed,
01654 IProgressListener& progressListener,
01655 volatile bool* cancel = NULL
01656 ) = 0;
01657
01672 virtual bool voronoiSplitChunk
01673 (
01674 uint32_t chunkIndex,
01675 const FractureTools::MeshProcessingParameters& meshProcessingParams,
01676 const FractureTools::FractureVoronoiDesc& desc,
01677 const CollisionDesc& collisionDesc,
01678 uint32_t* randomSeed,
01679 IProgressListener& progressListener,
01680 volatile bool* cancel = NULL
01681 ) = 0;
01682
01692 virtual void setBSPTolerances
01693 (
01694 float linearTolerance,
01695 float angularTolerance,
01696 float baseTolerance,
01697 float clipTolerance,
01698 float cleaningTolerance
01699 ) = 0;
01700
01719 virtual void setBSPBuildParameters
01720 (
01721 float logAreaSigmaThreshold,
01722 uint32_t testSetSize,
01723 float splitWeight,
01724 float imbalanceWeight
01725 ) = 0;
01726
01727
01736 virtual ExplicitHierarchicalMesh::ConvexHull* createExplicitHierarchicalMeshConvexHull() = 0;
01737
01744 virtual uint32_t buildSliceMesh(const ExplicitRenderTriangle*& mesh, const FractureTools::NoiseParameters& noiseParameters, const PxPlane& slicePlane, uint32_t randomSeed) = 0;
01745
01750 virtual void serializeFractureToolState(PxFileBuf& stream, nvidia::ExplicitHierarchicalMesh::Embedding& embedding) const = 0;
01751
01756 virtual void deserializeFractureToolState(PxFileBuf& stream, nvidia::ExplicitHierarchicalMesh::Embedding& embedding) = 0;
01757
01761 virtual void setChunkOverlapsCacheDepth(int32_t depth = -1) = 0;
01762
01766 virtual const RenderMeshAsset* getRenderMeshAsset() const = 0;
01767
01775 virtual bool setRenderMeshAsset(RenderMeshAsset*) = 0;
01776
01784 virtual bool setScatterMeshAssets(RenderMeshAsset** scatterMeshAssetArray, uint32_t scatterMeshAssetArraySize) = 0;
01785
01787 virtual uint32_t getScatterMeshAssetCount() const = 0;
01788
01790 virtual RenderMeshAsset* const * getScatterMeshAssets() const = 0;
01791
01795 virtual uint32_t getInstancedChunkMeshCount() const = 0;
01796
01800 virtual void setDestructibleParameters(const DestructibleParameters&) = 0;
01801
01806 virtual DestructibleParameters getDestructibleParameters() const = 0;
01807
01811 virtual void setDestructibleInitParameters(const DestructibleInitParameters&) = 0;
01812
01816 virtual DestructibleInitParameters getDestructibleInitParameters() const = 0;
01817
01821 virtual void setCrumbleEmitterName(const char*) = 0;
01822
01826 virtual void setDustEmitterName(const char*) = 0;
01827
01831 virtual void setFracturePatternName(const char*) = 0;
01832
01839 virtual void setNeighborPadding(float neighborPadding) = 0;
01840
01844 virtual float getNeighborPadding() const = 0;
01845
01860 virtual void cookChunks( const DestructibleAssetCookingDesc& cookingDesc, bool cacheOverlaps = true,
01861 uint32_t* chunkIndexMapUser2Apex = NULL, uint32_t* chunkIndexMapApex2User = NULL, uint32_t chunkIndexMapCount = 0) = 0;
01862
01867 virtual float getFractureImpulseScale() const = 0;
01868
01874 virtual float getImpactVelocityThreshold() const = 0;
01875
01879 virtual uint32_t getChunkCount() const = 0;
01880
01884 virtual uint32_t getDepthCount() const = 0;
01885
01890 virtual uint32_t getChunkChildCount(uint32_t chunkIndex) const = 0;
01891
01897 virtual int32_t getChunkChild(uint32_t chunkIndex, uint32_t childIndex) const = 0;
01898
01903 virtual PxVec3 getChunkPositionOffset(uint32_t chunkIndex) const = 0;
01904
01909 virtual PxVec2 getChunkUVOffset(uint32_t chunkIndex) const = 0;
01910
01914 virtual uint32_t getPartIndex(uint32_t chunkIndex) const = 0;
01915
01922 virtual void trimCollisionGeometry(const uint32_t* partIndices, uint32_t partIndexCount, float maxTrimFraction = 0.2f) = 0;
01923
01927 virtual void getStats(DestructibleAssetStats& stats) const = 0;
01928
01935 virtual void cacheChunkOverlapsUpToDepth(int32_t depth = -1) = 0;
01936
01943 virtual void clearChunkOverlaps(int32_t depth = -1, bool keepCachedFlag = false) = 0;
01944
01949 virtual void addChunkOverlaps(IntPair* supportGraphEdges, uint32_t numSupportGraphEdges) = 0;
01950
01959 virtual void removeChunkOverlaps(IntPair* supportGraphEdges, uint32_t numSupportGraphEdges, bool keepCachedFlagIfEmpty) = 0;
01960
01966 virtual uint32_t getCachedOverlapCountAtDepth(uint32_t depth) = 0;
01967
01974 virtual const IntPair* getCachedOverlapsAtDepth(uint32_t depth) = 0;
01975
01985 virtual void applyTransformation(const PxMat44& transformation, float scale) = 0;
01986
01995 virtual void applyTransformation(const PxMat44& transformation) = 0;
01996
02002 virtual bool setPlatformMaxDepth(PlatformTag platform, uint32_t maxDepth) = 0;
02003
02009 virtual bool removePlatformMaxDepth(PlatformTag platform) = 0;
02010
02014 virtual uint32_t getActorTransformCount() const = 0;
02015
02020 virtual const PxMat44* getActorTransforms() const = 0;
02021
02028 virtual void appendActorTransforms(const PxMat44* transforms, uint32_t transformCount) = 0;
02029
02033 virtual void clearActorTransforms() = 0;
02034 };
02035
02039 class DestructibleAsset : public Asset
02040 {
02041 public:
02045 enum ChunkFlags
02046 {
02047 ChunkEnvironmentallySupported = (1 << 0),
02048 ChunkAndDescendentsDoNotFracture = (1 << 1),
02049 ChunkDoesNotFracture = (1 << 2),
02050 ChunkDoesNotCrumble = (1 << 3),
02051 #if APEX_RUNTIME_FRACTURE
02052 ChunkRuntimeFracture = (1 << 4),
02053 #endif
02054 ChunkIsInstanced = (1 << 16)
02055 };
02056
02065 virtual void releaseDestructibleActor(DestructibleActor& actor) = 0;
02066
02067
02076 virtual DestructibleActor* createDestructibleActorFromDeserializedState(::NvParameterized::Interface* actorParams, Scene& apexScene) = 0;
02077
02082 virtual DestructibleParameters getDestructibleParameters() const = 0;
02083
02087 virtual DestructibleInitParameters getDestructibleInitParameters() const = 0;
02088
02093 virtual const char* getCrumbleEmitterName() const = 0;
02094
02099 virtual const char* getDustEmitterName() const = 0;
02100
02104 virtual uint32_t getChunkCount() const = 0;
02105
02109 virtual uint32_t getDepthCount() const = 0;
02110
02114 virtual const RenderMeshAsset* getRenderMeshAsset() const = 0;
02115
02122 virtual bool setRenderMeshAsset(RenderMeshAsset*) = 0;
02123
02125 virtual uint32_t getScatterMeshAssetCount() const = 0;
02126
02128 virtual RenderMeshAsset* const * getScatterMeshAssets() const = 0;
02129
02133 virtual uint32_t getInstancedChunkMeshCount() const = 0;
02134
02138 virtual void getStats(DestructibleAssetStats& stats) const = 0;
02139
02146 virtual void cacheChunkOverlapsUpToDepth(int32_t depth = -1) = 0;
02147
02155 virtual void clearChunkOverlaps(int32_t depth = -1, bool keepCachedFlag = false) = 0;
02156
02164 virtual void addChunkOverlaps(IntPair* supportGraphEdges, uint32_t numSupportGraphEdges) = 0;
02165
02174 virtual void removeChunkOverlaps(IntPair* supportGraphEdges, uint32_t numSupportGraphEdges, bool keepCachedFlagIfEmpty) = 0;
02175
02180 virtual uint32_t getCachedOverlapCountAtDepth(uint32_t depth) const = 0;
02181
02188 virtual const IntPair* getCachedOverlapsAtDepth(uint32_t depth) const = 0;
02189
02194 virtual PxVec3 getChunkPositionOffset(uint32_t chunkIndex) const = 0;
02195
02200 virtual PxVec2 getChunkUVOffset(uint32_t chunkIndex) const = 0;
02201
02205 virtual uint32_t getChunkFlags(uint32_t chunkIndex) const = 0;
02206
02210 virtual uint16_t getChunkDepth(uint32_t chunkIndex) const = 0;
02211
02216 virtual int32_t getChunkParentIndex(uint32_t chunkIndex) const = 0;
02217
02221 virtual PxBounds3 getChunkActorLocalBounds(uint32_t chunkIndex) const = 0;
02222
02226 virtual uint32_t getPartIndex(uint32_t chunkIndex) const = 0;
02227
02231 virtual uint32_t getPartConvexHullCount(const uint32_t partIndex) const = 0;
02232
02236 virtual NvParameterized::Interface** getPartConvexHullArray(const uint32_t partIndex) const = 0;
02237
02241 virtual uint32_t getActorTransformCount() const = 0;
02242
02247 virtual const PxMat44* getActorTransforms() const = 0;
02248
02258 virtual void applyTransformation(const PxMat44& transformation, float scale) = 0;
02259
02268 virtual void applyTransformation(const PxMat44& transformation) = 0;
02269
02274 virtual bool rebuildCollisionGeometry(uint32_t partIndex, const DestructibleGeometryDesc& geometryDesc) = 0;
02275
02276 protected:
02278 virtual ~DestructibleAsset() {}
02279 };
02280
02281
02282 #if !PX_PS4
02283 #pragma warning(pop)
02284 #endif //!PX_PS4
02285
02286 PX_POP_PACK
02287
02288 }
02289 }
02290
02291 #endif // DESTRUCTIBLE_ASSET_H