diff options
| author | Bryan Galdrikian <[email protected]> | 2017-10-24 15:25:02 -0700 |
|---|---|---|
| committer | Bryan Galdrikian <[email protected]> | 2017-10-24 15:25:02 -0700 |
| commit | b0c11962f6012430da3bcaa2727288046b33d648 (patch) | |
| tree | cf13338fa4fd7072badf64f751f94abeeb437003 /test/src/utils/TestAssets.cpp | |
| parent | linux build fix - all configs (diff) | |
| download | blast-b0c11962f6012430da3bcaa2727288046b33d648.tar.xz blast-b0c11962f6012430da3bcaa2727288046b33d648.zip | |
Changes for 1.1.1
See README.md
Diffstat (limited to 'test/src/utils/TestAssets.cpp')
| -rw-r--r-- | test/src/utils/TestAssets.cpp | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/test/src/utils/TestAssets.cpp b/test/src/utils/TestAssets.cpp index 34dd5b5..5668d3e 100644 --- a/test/src/utils/TestAssets.cpp +++ b/test/src/utils/TestAssets.cpp @@ -28,6 +28,7 @@ #include "TestAssets.h" #include "AssetGenerator.h" +#include <algorithm> const NvBlastChunkDesc g_cube1ChunkDescs[9] = { @@ -378,3 +379,42 @@ void generateCube(GeneratorAsset& cubeAsset, NvBlastAssetDesc& assetDesc, size_t assetDesc.chunkCount = (uint32_t)cubeAsset.chunks.size(); assetDesc.chunkDescs = cubeAsset.solverChunks.data(); } + +void generateRandomCube(GeneratorAsset& cubeAsset, NvBlastAssetDesc& desc, uint32_t minChunkCount, uint32_t maxChunkCount) +{ + CubeAssetGenerator::Settings settings; + settings.extents = GeneratorAsset::Vec3(1, 1, 1); + CubeAssetGenerator::DepthInfo depthInfo; + depthInfo.slicesPerAxis = GeneratorAsset::Vec3(1, 1, 1); + depthInfo.flag = NvBlastChunkDesc::Flags::NoFlags; + settings.depths.push_back(depthInfo); + uint32_t chunkCount = 1; + while (chunkCount < minChunkCount) + { + uint32_t chunkMul; + do + { + depthInfo.slicesPerAxis = GeneratorAsset::Vec3((float)(1 + rand() % 4), (float)(1 + rand() % 4), (float)(1 + rand() % 4)); + chunkMul = (uint32_t)(depthInfo.slicesPerAxis.x * depthInfo.slicesPerAxis.y * depthInfo.slicesPerAxis.z); + } while (chunkMul == 1); + if (chunkCount*chunkMul > maxChunkCount) + { + break; + } + chunkCount *= chunkMul; + settings.depths.push_back(depthInfo); + settings.extents = settings.extents * depthInfo.slicesPerAxis; + } + settings.depths.back().flag = NvBlastChunkDesc::SupportFlag; // Leaves are support + + // Make largest direction unit size + settings.extents = settings.extents * (1.0f / std::max(settings.extents.x, std::max(settings.extents.y, settings.extents.z))); + + // Create asset + CubeAssetGenerator::generate(cubeAsset, settings); + + desc.chunkDescs = cubeAsset.solverChunks.data(); + desc.chunkCount = (uint32_t)cubeAsset.solverChunks.size(); + desc.bondDescs = cubeAsset.solverBonds.data(); + desc.bondCount = (uint32_t)cubeAsset.solverBonds.size(); +}
\ No newline at end of file |