From 9f4fc41dc5d857e3c7c3500fc71953e54d780a39 Mon Sep 17 00:00:00 2001 From: Bryan Galdrikian Date: Tue, 17 Sep 2019 09:16:55 -0700 Subject: * NvBlastAsset::testForValidChunkOrder (used when creating an NvBlastAsset) is now more strict, requiring parent chunk descriptors to come before their children. It is still less strict than the order created by NvBlastBuildAssetDescChunkReorderMap. * Added FractureTool::setApproximateBonding function. Signals the tool to create bonds by proximity instead of just using cut plane data. * Chunks which have been merged using the uniteChunks function may be merged again * Restored chunk volume calculation * NvBlastBuildAssetDescChunkReorderMap failure cases fixed. --- sdk/lowlevel/source/NvBlastAsset.cpp | 78 +++++++++++++++++++----------------- 1 file changed, 42 insertions(+), 36 deletions(-) (limited to 'sdk/lowlevel/source/NvBlastAsset.cpp') diff --git a/sdk/lowlevel/source/NvBlastAsset.cpp b/sdk/lowlevel/source/NvBlastAsset.cpp index c82fa29..553599d 100755 --- a/sdk/lowlevel/source/NvBlastAsset.cpp +++ b/sdk/lowlevel/source/NvBlastAsset.cpp @@ -777,42 +777,48 @@ bool Asset::ensureExactSupportCoverage(uint32_t& supportChunkCount, uint32_t& le bool Asset::testForValidChunkOrder(uint32_t chunkCount, const NvBlastChunkDesc* chunkDescs, const char* chunkAnnotation, void* scratch) { - char* chunkMarks = static_cast(memset(scratch, 0, chunkCount)); - - uint32_t currentParentChunkIndex = invalidIndex(); - for (uint32_t i = 0; i < chunkCount; ++i) - { - const uint32_t parentChunkIndex = chunkDescs[i].parentChunkIndex; - if (parentChunkIndex != currentParentChunkIndex) - { - if (!isInvalidIndex(currentParentChunkIndex)) - { - chunkMarks[currentParentChunkIndex] = 1; - } - currentParentChunkIndex = parentChunkIndex; - if (isInvalidIndex(currentParentChunkIndex)) - { - return false; - } - else if (chunkMarks[currentParentChunkIndex] != 0) - { - return false; - } - } - - if (i < chunkCount - 1) - { - const bool upperSupport0 = (chunkAnnotation[i] & ChunkAnnotation::UpperSupport) != 0; - const bool upperSupport1 = (chunkAnnotation[i + 1] & ChunkAnnotation::UpperSupport) != 0; - - if (!upperSupport0 && upperSupport1) - { - return false; - } - } - } - - return true; + char* chunkMarks = static_cast(memset(scratch, 0, chunkCount)); + + uint32_t currentParentChunkIndex = invalidIndex(); + for (uint32_t i = 0; i < chunkCount; ++i) + { + const uint32_t parentChunkIndex = chunkDescs[i].parentChunkIndex; + + if (!isInvalidIndex(parentChunkIndex) && parentChunkIndex >= i) // 'chunks should come after their parents' + { + return false; + } + + if (parentChunkIndex != currentParentChunkIndex) + { + if (!isInvalidIndex(currentParentChunkIndex)) + { + chunkMarks[currentParentChunkIndex] = 1; + } + currentParentChunkIndex = parentChunkIndex; + if (isInvalidIndex(currentParentChunkIndex)) // 'root chunks should go first' + { + return false; + } + else if (chunkMarks[currentParentChunkIndex] != 0) // 'all chunks with same parent index should go in a row' + { + return false; + } + } + + if (i < chunkCount - 1) + { + const bool upperSupport0 = (chunkAnnotation[i] & ChunkAnnotation::UpperSupport) != 0; + const bool upperSupport1 = (chunkAnnotation[i + 1] & ChunkAnnotation::UpperSupport) != 0; + + if (!upperSupport0 && upperSupport1) // 'upper-support chunks should come before subsupport chunks' + { + return false; + } + } + } + + return true; } } // namespace Blast -- cgit v1.2.3