diff --git a/blast/VERSION.md b/blast/VERSION.md index 6b244dcd6..a1ef0cae1 100644 --- a/blast/VERSION.md +++ b/blast/VERSION.md @@ -1 +1 @@ -5.0.1 +5.0.2 diff --git a/blast/docs/CHANGELOG.md b/blast/docs/CHANGELOG.md index f1d028246..c40156693 100644 --- a/blast/docs/CHANGELOG.md +++ b/blast/docs/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## [5.0.2] - 25-July-2023 + +### Bugfixes +- Fixed slice fracturing bug which set the local chunk transform to the identity in some cases + + ## [5.0.1] - 22-June-2023 ### Bugfixes diff --git a/blast/include/extensions/authoring/NvBlastExtAuthoringFractureTool.h b/blast/include/extensions/authoring/NvBlastExtAuthoringFractureTool.h index d79006d9c..aecca6e12 100644 --- a/blast/include/extensions/authoring/NvBlastExtAuthoringFractureTool.h +++ b/blast/include/extensions/authoring/NvBlastExtAuthoringFractureTool.h @@ -398,9 +398,9 @@ class FractureTool \param[in] chunkId Chunk to fracture \param[in] conf Slicing parameters, see SlicingConfiguration. \param[in] replaceChunk if 'true', newly generated chunks will replace source chunk, if 'false', newly - generated chunks will be at next depth level, source chunk will be parent for them. Case replaceChunk == true && - chunkId == 0 considered as wrong input parameters \param[in] rnd User supplied random number - generator + generated chunks will be at next depth level, source chunk will be parent for + them. Case replaceChunk == true && chunkId == 0 considered as wrong input parameters + \param[in] rnd User supplied random number generator \return If 0, fracturing is successful. */ @@ -414,9 +414,9 @@ class FractureTool \param[in] position Point on plane \param[in] noise Noise configuration for plane-chunk intersection, see NoiseConfiguration. \param[in] replaceChunk if 'true', newly generated chunks will replace source chunk, if 'false', newly - generated chunks will be at next depth level, source chunk will be parent for them. Case replaceChunk == true && - chunkId == 0 considered as wrong input parameters \param[in] rnd User supplied random number - generator + generated chunks will be at next depth level, source chunk will be parent for + them. Case replaceChunk == true && chunkId == 0 considered as wrong input parameters + \param[in] rnd User supplied random number generator \return If 0, fracturing is successful. */ @@ -428,9 +428,10 @@ class FractureTool \param[in] chunkId Chunk to fracture \param[in] conf Cutout parameters, see CutoutConfiguration. \param[in] replaceChunk if 'true', newly generated chunks will replace source chunk, if 'false', newly - generated chunks will be at next depth level, source chunk will be parent for them. Case replaceChunk == true && - chunkId == 0 considered as wrong input parameters \param[in] rnd User supplied random number - generator + \param[in] replaceChunk if 'true', newly generated chunks will replace source chunk, if 'false', newly + generated chunks will be at next depth level, source chunk will be parent for + them. Case replaceChunk == true && chunkId == 0 considered as wrong input parameters + \param[in] rnd User supplied random number generator \return If 0, fracturing is successful. */ diff --git a/blast/source/sdk/extensions/authoring/NvBlastExtAuthoringFractureToolImpl.cpp b/blast/source/sdk/extensions/authoring/NvBlastExtAuthoringFractureToolImpl.cpp index 5d09211e4..0cc363a7e 100644 --- a/blast/source/sdk/extensions/authoring/NvBlastExtAuthoringFractureToolImpl.cpp +++ b/blast/source/sdk/extensions/authoring/NvBlastExtAuthoringFractureToolImpl.cpp @@ -851,8 +851,8 @@ int32_t FractureToolImpl::slicing(uint32_t chunkId, const SlicingConfiguration& ch.isChanged = true; ch.flags = ChunkInfo::NO_FLAGS; ch.parentChunkId = replaceChunk ? mChunkData[chunkInfoIndex].parentChunkId : chunkId; - std::vector xSlicedChunks; - std::vector ySlicedChunks; + std::vector xSlicedChunks; + std::vector ySlicedChunks; std::vector newlyCreatedChunksIds; /** Slice along x direction @@ -865,12 +865,12 @@ int32_t FractureToolImpl::slicing(uint32_t chunkId, const SlicingConfiguration& setCuttingBox(center, -lDir, slBox, 20, mPlaneIndexerOffset); bTool.performFastCutting(mesh, slBox, BooleanConfigurations::BOOLEAN_INTERSECTION()); - setChunkInfoMesh(ch, bTool.createNewMesh()); - - if (ch.getMesh() != 0) + Mesh* xSlice = bTool.createNewMesh(); + if (xSlice != nullptr) { - xSlicedChunks.push_back(ch); + xSlicedChunks.push_back(xSlice); } + inverseNormalAndIndices(slBox); ++mPlaneIndexerOffset; bTool.performFastCutting(mesh, slBox, BooleanConfigurations::BOOLEAN_DIFFERENCE()); @@ -883,19 +883,17 @@ int32_t FractureToolImpl::slicing(uint32_t chunkId, const SlicingConfiguration& } center.x += x_offset + (rnd->getRandomValue()) * conf.offset_variations * x_offset; } - if (mesh != 0) + if (mesh != nullptr) { - setChunkInfoMesh(ch, mesh); - xSlicedChunks.push_back(ch); + xSlicedChunks.push_back(mesh); } - for (uint32_t chunk = 0; chunk < xSlicedChunks.size(); ++chunk) { center = NvVec3(0, sourceBBox.minimum.y, 0); center.y += y_offset; dir = NvVec3(0, 1, 0); - mesh = xSlicedChunks[chunk].getMesh(); + mesh = xSlicedChunks[chunk]; for (int32_t slice = 0; slice < y_slices; ++slice) { @@ -903,14 +901,14 @@ int32_t FractureToolImpl::slicing(uint32_t chunkId, const SlicingConfiguration& NvVec3(2 * rnd->getRandomValue() - 1, 2 * rnd->getRandomValue() - 1, 2 * rnd->getRandomValue() - 1); NvVec3 lDir = dir + randVect * conf.angle_variations; - setCuttingBox(center, -lDir, slBox, 20, mPlaneIndexerOffset); bTool.performFastCutting(mesh, slBox, BooleanConfigurations::BOOLEAN_INTERSECTION()); - setChunkInfoMesh(ch, bTool.createNewMesh()); - if (ch.getMesh() != 0) + Mesh* ySlice = bTool.createNewMesh(); + if (ySlice != nullptr) { - ySlicedChunks.push_back(ch); + ySlicedChunks.push_back(ySlice); } + inverseNormalAndIndices(slBox); ++mPlaneIndexerOffset; bTool.performFastCutting(mesh, slBox, BooleanConfigurations::BOOLEAN_DIFFERENCE()); @@ -923,35 +921,36 @@ int32_t FractureToolImpl::slicing(uint32_t chunkId, const SlicingConfiguration& } center.y += y_offset + (rnd->getRandomValue()) * conf.offset_variations * y_offset; } - if (mesh != 0) + if (mesh != nullptr) { - setChunkInfoMesh(ch, mesh); - ySlicedChunks.push_back(ch); + ySlicedChunks.push_back(mesh); } } - for (uint32_t chunk = 0; chunk < ySlicedChunks.size(); ++chunk) { center = NvVec3(0, 0, sourceBBox.minimum.z); center.z += z_offset; dir = NvVec3(0, 0, 1); - mesh = ySlicedChunks[chunk].getMesh(); + mesh = ySlicedChunks[chunk]; for (int32_t slice = 0; slice < z_slices; ++slice) { NvVec3 randVect = NvVec3(2 * rnd->getRandomValue() - 1, 2 * rnd->getRandomValue() - 1, 2 * rnd->getRandomValue() - 1); NvVec3 lDir = dir + randVect * conf.angle_variations; + setCuttingBox(center, -lDir, slBox, 20, mPlaneIndexerOffset); bTool.performFastCutting(mesh, slBox, BooleanConfigurations::BOOLEAN_INTERSECTION()); - setChunkInfoMesh(ch, bTool.createNewMesh()); - if (ch.getMesh() != 0) + Mesh* ySlice = bTool.createNewMesh(); + if (ySlice != nullptr) { + setChunkInfoMesh(ch, ySlice); ch.chunkId = createId(); newlyCreatedChunksIds.push_back(ch.chunkId); mChunkData.push_back(ch); } + inverseNormalAndIndices(slBox); ++mPlaneIndexerOffset; bTool.performFastCutting(mesh, slBox, BooleanConfigurations::BOOLEAN_DIFFERENCE()); @@ -964,16 +963,15 @@ int32_t FractureToolImpl::slicing(uint32_t chunkId, const SlicingConfiguration& } center.z += z_offset + (rnd->getRandomValue()) * conf.offset_variations * z_offset; } - if (mesh != 0) + if (mesh != nullptr) { - ch.chunkId = createId(); setChunkInfoMesh(ch, mesh); - mChunkData.push_back(ch); + ch.chunkId = createId(); newlyCreatedChunksIds.push_back(ch.chunkId); + mChunkData.push_back(ch); } } - delete slBox; mChunkData[chunkInfoIndex].isLeaf = false; @@ -1047,8 +1045,8 @@ int32_t FractureToolImpl::slicingNoisy(uint32_t chunkId, const SlicingConfigurat ch.isChanged = true; ch.flags = ChunkInfo::NO_FLAGS; ch.parentChunkId = replaceChunk ? mChunkData[chunkInfoIndex].parentChunkId : chunkId; - std::vector xSlicedChunks; - std::vector ySlicedChunks; + std::vector xSlicedChunks; + std::vector ySlicedChunks; std::vector newlyCreatedChunksIds; float noisyPartSize = 1.2f; // int32_t acceleratorRes = 8; @@ -1068,11 +1066,12 @@ int32_t FractureToolImpl::slicingNoisy(uint32_t chunkId, const SlicingConfigurat SweepingAccelerator accel(mesh); SweepingAccelerator dummy(slBox); bTool.performBoolean(mesh, slBox, &accel, &dummy, BooleanConfigurations::BOOLEAN_DIFFERENCE()); - setChunkInfoMesh(ch, bTool.createNewMesh()); - if (ch.getMesh() != 0) + Mesh* xSlice = bTool.createNewMesh(); + if (xSlice != nullptr) { - xSlicedChunks.push_back(ch); + xSlicedChunks.push_back(xSlice); } + inverseNormalAndIndices(slBox); ++mPlaneIndexerOffset; bTool.performBoolean(mesh, slBox, &accel, &dummy, BooleanConfigurations::BOOLEAN_INTERSECTION()); @@ -1086,11 +1085,11 @@ int32_t FractureToolImpl::slicingNoisy(uint32_t chunkId, const SlicingConfigurat } center.x += x_offset + (rnd->getRandomValue()) * conf.offset_variations * x_offset; } - if (mesh != 0) + if (mesh != nullptr) { - setChunkInfoMesh(ch, mesh); - xSlicedChunks.push_back(ch); + xSlicedChunks.push_back(mesh); } + slBox = getCuttingBox(center, dir, 20, 0, mInteriorMaterialId); uint32_t slicedChunkSize = xSlicedChunks.size(); for (uint32_t chunk = 0; chunk < slicedChunkSize; ++chunk) @@ -1098,7 +1097,7 @@ int32_t FractureToolImpl::slicingNoisy(uint32_t chunkId, const SlicingConfigurat center = NvVec3(0, sourceBBox.minimum.y, 0); center.y += y_offset; dir = NvVec3(0, 1, 0); - mesh = xSlicedChunks[chunk].getMesh(); + mesh = xSlicedChunks[chunk]; for (int32_t slice = 0; slice < y_slices; ++slice) { @@ -1114,11 +1113,12 @@ int32_t FractureToolImpl::slicingNoisy(uint32_t chunkId, const SlicingConfigurat SweepingAccelerator accel(mesh); SweepingAccelerator dummy(slBox); bTool.performBoolean(mesh, slBox, &accel, &dummy, BooleanConfigurations::BOOLEAN_DIFFERENCE()); - setChunkInfoMesh(ch, bTool.createNewMesh()); - if (ch.getMesh() != 0) + Mesh* ySlice = bTool.createNewMesh(); + if (ySlice != nullptr) { - ySlicedChunks.push_back(ch); + ySlicedChunks.push_back(ySlice); } + inverseNormalAndIndices(slBox); ++mPlaneIndexerOffset; bTool.performBoolean(mesh, slBox, &accel, &dummy, BooleanConfigurations::BOOLEAN_INTERSECTION()); @@ -1132,10 +1132,9 @@ int32_t FractureToolImpl::slicingNoisy(uint32_t chunkId, const SlicingConfigurat } center.y += y_offset + (rnd->getRandomValue()) * conf.offset_variations * y_offset; } - if (mesh != 0) + if (mesh != nullptr) { - setChunkInfoMesh(ch, mesh); - ySlicedChunks.push_back(ch); + ySlicedChunks.push_back(mesh); } } @@ -1144,7 +1143,7 @@ int32_t FractureToolImpl::slicingNoisy(uint32_t chunkId, const SlicingConfigurat center = NvVec3(0, 0, sourceBBox.minimum.z); center.z += z_offset; dir = NvVec3(0, 0, 1); - mesh = ySlicedChunks[chunk].getMesh(); + mesh = ySlicedChunks[chunk]; for (int32_t slice = 0; slice < z_slices; ++slice) { @@ -1159,13 +1158,15 @@ int32_t FractureToolImpl::slicingNoisy(uint32_t chunkId, const SlicingConfigurat SweepingAccelerator accel(mesh); SweepingAccelerator dummy(slBox); bTool.performBoolean(mesh, slBox, &accel, &dummy, BooleanConfigurations::BOOLEAN_DIFFERENCE()); - setChunkInfoMesh(ch, bTool.createNewMesh()); - if (ch.getMesh() != 0) + Mesh* ySlice = bTool.createNewMesh(); + if (ySlice != nullptr) { + setChunkInfoMesh(ch, ySlice); ch.chunkId = createId(); mChunkData.push_back(ch); newlyCreatedChunksIds.push_back(ch.chunkId); } + inverseNormalAndIndices(slBox); ++mPlaneIndexerOffset; bTool.performBoolean(mesh, slBox, &accel, &dummy, BooleanConfigurations::BOOLEAN_INTERSECTION()); @@ -1179,12 +1180,12 @@ int32_t FractureToolImpl::slicingNoisy(uint32_t chunkId, const SlicingConfigurat } center.z += z_offset + (rnd->getRandomValue()) * conf.offset_variations * z_offset; } - if (mesh != 0) + if (mesh != nullptr) { - ch.chunkId = createId(); setChunkInfoMesh(ch, mesh); - mChunkData.push_back(ch); + ch.chunkId = createId(); newlyCreatedChunksIds.push_back(ch.chunkId); + mChunkData.push_back(ch); } } @@ -1206,6 +1207,7 @@ int32_t FractureToolImpl::slicingNoisy(uint32_t chunkId, const SlicingConfigurat return 0; } + int32_t FractureToolImpl::cut(uint32_t chunkId, const NvcVec3& normal, const NvcVec3& point, const NoiseConfiguration& noise, bool replaceChunk, RandomGeneratorBase* rnd) {