diff options
| author | Bryan Galdrikian <[email protected]> | 2017-08-28 13:55:34 -0700 |
|---|---|---|
| committer | Bryan Galdrikian <[email protected]> | 2017-08-28 13:55:34 -0700 |
| commit | 1e887d827e65a084a0ad0ba933c61a8330aeee07 (patch) | |
| tree | 1e2aab418dadd37f5dc0aae4d8b00e81d909fd24 /sdk/extensions/authoring | |
| parent | Removing ArtistTools and CurveEditor projects (diff) | |
| download | blast-1e887d827e65a084a0ad0ba933c61a8330aeee07.tar.xz blast-1e887d827e65a084a0ad0ba933c61a8330aeee07.zip | |
Candidate 1.1 release.
* SampleAssetViewer now unconditionally loads the commandline-defined asset.
* Better error handling in AuthoringTool (stderr and user error handler).
* More consistent commandline switches in AuthoringTool and ApexImporter (--ll, --tx, --px flags).
* NvBlastExtAuthoring
** Mesh cleaner, tries to remove self intersections and open edges in the interior of a mesh.
** Ability to set interior material to existing (external) material, or a new material id.
** Material ID remapping API.
** Rotation of voronoi cells used for fracturing.
* Fixed smoothing groups in FBX exporter code.
* Impulse passing from parent to child chunks fixed.
* Reading unskinned fbx meshes correctly.
* Collision hull generation from fbx meshes fixed.
* Win32/64 PerfTest crash fix.
Diffstat (limited to 'sdk/extensions/authoring')
8 files changed, 131 insertions, 62 deletions
diff --git a/sdk/extensions/authoring/include/NvBlastExtAuthoringFractureTool.h b/sdk/extensions/authoring/include/NvBlastExtAuthoringFractureTool.h index e6a6d41..9cdb6c2 100644 --- a/sdk/extensions/authoring/include/NvBlastExtAuthoringFractureTool.h +++ b/sdk/extensions/authoring/include/NvBlastExtAuthoringFractureTool.h @@ -199,11 +199,26 @@ public: /** - Set input mesh wich will be fractured, FractureTool will be reseted. + Set input mesh which will be fractured, FractureTool will be reseted. */ virtual void setSourceMesh(const Mesh* mesh) = 0; /** + Set the material id to use for new interior faces. Defaults to MATERIAL_INTERIOR + */ + virtual void setInteriorMaterialId(int32_t materialId) = 0; + + /** + Gets the material id to use for new interior faces + */ + virtual int32_t getInteriorMaterialId() const = 0; + + /** + Replaces an material id on faces with a new one + */ + virtual void replaceMaterialId(int32_t oldMaterialId, int32_t newMaterialId) = 0; + + /** Get chunk mesh in polygonal representation. User's code should release it after usage. */ virtual Mesh* createChunkMesh(int32_t chunkId) = 0; diff --git a/sdk/extensions/authoring/include/NvBlastExtAuthoringMesh.h b/sdk/extensions/authoring/include/NvBlastExtAuthoringMesh.h index 039da52..3e65a48 100644 --- a/sdk/extensions/authoring/include/NvBlastExtAuthoringMesh.h +++ b/sdk/extensions/authoring/include/NvBlastExtAuthoringMesh.h @@ -123,12 +123,17 @@ public: /** Set per-facet material id. */ - virtual void setMaterialId(int32_t* materialIds) = 0; + virtual void setMaterialId(const int32_t* materialIds) = 0; + + /** + Replaces an material id on faces with a new one + */ + virtual void replaceMaterialId(int32_t oldMaterialId, int32_t newMaterialId) = 0; /** Set per-facet smoothing group. */ - virtual void setSmoothingGroup(int32_t* smoothingGroup) = 0; + virtual void setSmoothingGroup(const int32_t* smoothingGroups) = 0; /** Recalculate bounding box diff --git a/sdk/extensions/authoring/include/NvBlastExtAuthoringTypes.h b/sdk/extensions/authoring/include/NvBlastExtAuthoringTypes.h index 3c0675c..833798a 100644 --- a/sdk/extensions/authoring/include/NvBlastExtAuthoringTypes.h +++ b/sdk/extensions/authoring/include/NvBlastExtAuthoringTypes.h @@ -250,7 +250,7 @@ struct AuthoringResult /** Array of material names. */ - char** materialNames; + const char** materialNames; /** Size of array of material names. */ diff --git a/sdk/extensions/authoring/source/NvBlastExtAuthoringCollisionBuilderImpl.cpp b/sdk/extensions/authoring/source/NvBlastExtAuthoringCollisionBuilderImpl.cpp index 39c7586..ddfa668 100644 --- a/sdk/extensions/authoring/source/NvBlastExtAuthoringCollisionBuilderImpl.cpp +++ b/sdk/extensions/authoring/source/NvBlastExtAuthoringCollisionBuilderImpl.cpp @@ -239,7 +239,8 @@ void ConvexMeshBuilderImpl::trimCollisionGeometry(uint32_t chunksCount, Collisio } Mesh* hullMesh = new MeshImpl(vertices.data(), edges.data(), facets.data(), vertices.size(), edges.size(), facets.size()); BooleanEvaluator evl; - Mesh* cuttingMesh = getCuttingBox(PxVec3(0, 0, 0), PxVec3(0, 0, 1), 40, 0); + //I think the material ID is unused for collision meshes so harcoding MATERIAL_INTERIOR is ok + Mesh* cuttingMesh = getCuttingBox(PxVec3(0, 0, 0), PxVec3(0, 0, 1), 40, 0, MATERIAL_INTERIOR); for (uint32_t p = 0; p < chunkMidplanes[i].size(); ++p) { PxPlane& pl = chunkMidplanes[i][p]; @@ -277,27 +278,19 @@ void ConvexMeshBuilderImpl::trimCollisionGeometry(uint32_t chunksCount, Collisio PxConvexMesh* ConvexMeshBuilderImpl::buildConvexMesh(uint32_t verticesCount, const physx::PxVec3* vertexData) { CollisionHull* hull = buildCollisionGeometry(verticesCount, vertexData); - - PxConvexMeshDesc convexMeshDescr; - convexMeshDescr.indices.data = hull->indices; - convexMeshDescr.indices.count = (uint32_t)hull->indicesCount; - convexMeshDescr.indices.stride = sizeof(uint32_t); - - convexMeshDescr.points.data = hull->points; - convexMeshDescr.points.count = (uint32_t)hull->pointsCount; - convexMeshDescr.points.stride = sizeof(PxVec3); - - convexMeshDescr.polygons.data = hull->polygonData; - convexMeshDescr.polygons.count = (uint32_t)hull->polygonDataCount; - convexMeshDescr.polygons.stride = sizeof(PxHullPolygon); - - PxConvexMesh* convexMesh = mCooking->createConvexMesh(convexMeshDescr, *mInsertionCallback); + PxConvexMesh* convexMesh = buildConvexMesh(*hull); hull->release(); return convexMesh; } PxConvexMesh* ConvexMeshBuilderImpl::buildConvexMesh(const CollisionHull& hull) { + /* PxCooking::createConvexMesh expects PxHullPolygon input, which matches CollisionHull::HullPolygon */ + static_assert(sizeof(PxHullPolygon) == sizeof(CollisionHull::HullPolygon), "CollisionHull::HullPolygon size mismatch"); + static_assert(offsetof(PxHullPolygon, mPlane) == offsetof(CollisionHull::HullPolygon, mPlane), "CollisionHull::HullPolygon layout mismatch"); + static_assert(offsetof(PxHullPolygon, mNbVerts) == offsetof(CollisionHull::HullPolygon, mNbVerts), "CollisionHull::HullPolygon layout mismatch"); + static_assert(offsetof(PxHullPolygon, mIndexBase) == offsetof(CollisionHull::HullPolygon, mIndexBase), "CollisionHull::HullPolygon layout mismatch"); + PxConvexMeshDesc convexMeshDescr; convexMeshDescr.indices.data = hull.indices; convexMeshDescr.indices.count = (uint32_t)hull.indicesCount; diff --git a/sdk/extensions/authoring/source/NvBlastExtAuthoringFractureToolImpl.cpp b/sdk/extensions/authoring/source/NvBlastExtAuthoringFractureToolImpl.cpp index 8378ef0..666361c 100644 --- a/sdk/extensions/authoring/source/NvBlastExtAuthoringFractureToolImpl.cpp +++ b/sdk/extensions/authoring/source/NvBlastExtAuthoringFractureToolImpl.cpp @@ -100,10 +100,10 @@ void findCellBasePlanes(const std::vector<PxVec3>& sites, std::vector<std::vecto #define SITE_BOX_SIZE 4 #define CUTTING_BOX_SIZE 40 -Mesh* getCellMesh(BooleanEvaluator& eval, int32_t planeIndexerOffset, int32_t cellId, const std::vector<PxVec3>& sites, std::vector < std::vector<int32_t> >& neighboors) +Mesh* getCellMesh(BooleanEvaluator& eval, int32_t planeIndexerOffset, int32_t cellId, const std::vector<PxVec3>& sites, std::vector < std::vector<int32_t> >& neighboors, int32_t interiorMaterialId) { - Mesh* cell = getBigBox(sites[cellId], SITE_BOX_SIZE); - Mesh* cuttingMesh = getCuttingBox(PxVec3(0, 0, 0), PxVec3(1, 1, 1), CUTTING_BOX_SIZE, 0); + Mesh* cell = getBigBox(sites[cellId], SITE_BOX_SIZE, interiorMaterialId); + Mesh* cuttingMesh = getCuttingBox(PxVec3(0, 0, 0), PxVec3(1, 1, 1), CUTTING_BOX_SIZE, 0, interiorMaterialId); for (uint32_t i = 0; i < neighboors[cellId].size(); ++i) { @@ -406,7 +406,7 @@ int32_t FractureToolImpl::voronoiFracturing(uint32_t chunkId, uint32_t cellCount std::vector<uint32_t> newlyCreatedChunksIds; for (uint32_t i = 0; i < cellPoints.size(); ++i) { - Mesh* cell = getCellMesh(eval, mPlaneIndexerOffset, i, cellPoints, neighboors); + Mesh* cell = getCellMesh(eval, mPlaneIndexerOffset, i, cellPoints, neighboors, mInteriorMaterialId); if (cell == nullptr) { @@ -576,7 +576,7 @@ int32_t FractureToolImpl::voronoiFracturing(uint32_t chunkId, uint32_t cellCount for (uint32_t i = 0; i < cellPoints.size(); ++i) { - Mesh* cell = getCellMesh(eval, mPlaneIndexerOffset, i, cellPoints, neighboors); + Mesh* cell = getCellMesh(eval, mPlaneIndexerOffset, i, cellPoints, neighboors, mInteriorMaterialId); if (cell == nullptr) { @@ -670,7 +670,7 @@ int32_t FractureToolImpl::slicing(uint32_t chunkId, SlicingConfiguration conf, b PxVec3 dir(1, 0, 0); - Mesh* slBox = getCuttingBox(center, dir, 20, 0); + Mesh* slBox = getCuttingBox(center, dir, 20, 0, mInteriorMaterialId); ChunkInfo ch; ch.isLeaf = true; @@ -871,7 +871,7 @@ int32_t FractureToolImpl::slicingNoisy(uint32_t chunkId, SlicingConfiguration co { PxVec3 randVect = PxVec3(2 * rnd->getRandomValue() - 1, 2 * rnd->getRandomValue() - 1, 2 * rnd->getRandomValue() - 1); PxVec3 lDir = dir + randVect * conf.angle_variations; - slBox = getNoisyCuttingBoxPair(center, lDir, 40, noisyPartSize, conf.surfaceResolution, mPlaneIndexerOffset, conf.noiseAmplitude, conf.noiseFrequency, conf.noiseOctaveNumber, rnd->getRandomValue()); + slBox = getNoisyCuttingBoxPair(center, lDir, 40, noisyPartSize, conf.surfaceResolution, mPlaneIndexerOffset, conf.noiseAmplitude, conf.noiseFrequency, conf.noiseOctaveNumber, rnd->getRandomValue(), mInteriorMaterialId); // DummyAccelerator accel(mesh->getFacetCount()); IntersectionTestingAccelerator accel(mesh, acceleratorRes); DummyAccelerator dummy(slBox->getFacetCount()); @@ -899,7 +899,7 @@ int32_t FractureToolImpl::slicingNoisy(uint32_t chunkId, SlicingConfiguration co ch.meshData = mesh; xSlicedChunks.push_back(ch); } - slBox = getCuttingBox(center, dir, 20, 0); + slBox = getCuttingBox(center, dir, 20, 0, mInteriorMaterialId); uint32_t slicedChunkSize = xSlicedChunks.size(); for (uint32_t chunk = 0; chunk < slicedChunkSize; ++chunk) { @@ -913,7 +913,7 @@ int32_t FractureToolImpl::slicingNoisy(uint32_t chunkId, SlicingConfiguration co PxVec3 randVect = PxVec3(2 * rnd->getRandomValue() - 1, 2 * rnd->getRandomValue() - 1, 2 * rnd->getRandomValue() - 1); PxVec3 lDir = dir + randVect * conf.angle_variations; - slBox = getNoisyCuttingBoxPair(center, lDir, 40, noisyPartSize, conf.surfaceResolution, mPlaneIndexerOffset, conf.noiseAmplitude, conf.noiseFrequency, conf.noiseOctaveNumber, rnd->getRandomValue()); + slBox = getNoisyCuttingBoxPair(center, lDir, 40, noisyPartSize, conf.surfaceResolution, mPlaneIndexerOffset, conf.noiseAmplitude, conf.noiseFrequency, conf.noiseOctaveNumber, rnd->getRandomValue(), mInteriorMaterialId); // DummyAccelerator accel(mesh->getFacetCount()); IntersectionTestingAccelerator accel(mesh, acceleratorRes); DummyAccelerator dummy(slBox->getFacetCount()); @@ -954,7 +954,7 @@ int32_t FractureToolImpl::slicingNoisy(uint32_t chunkId, SlicingConfiguration co { PxVec3 randVect = PxVec3(2 * rnd->getRandomValue() - 1, 2 * rnd->getRandomValue() - 1, 2 * rnd->getRandomValue() - 1); PxVec3 lDir = dir + randVect * conf.angle_variations; - slBox = getNoisyCuttingBoxPair(center, lDir, 40, noisyPartSize, conf.surfaceResolution, mPlaneIndexerOffset, conf.noiseAmplitude, conf.noiseFrequency, conf.noiseOctaveNumber, rnd->getRandomValue()); + slBox = getNoisyCuttingBoxPair(center, lDir, 40, noisyPartSize, conf.surfaceResolution, mPlaneIndexerOffset, conf.noiseAmplitude, conf.noiseFrequency, conf.noiseOctaveNumber, rnd->getRandomValue(), mInteriorMaterialId); // DummyAccelerator accel(mesh->getFacetCount()); IntersectionTestingAccelerator accel(mesh, acceleratorRes); DummyAccelerator dummy(slBox->getFacetCount()); @@ -1126,9 +1126,15 @@ void FractureToolImpl::reset() mChunkData.clear(); mPlaneIndexerOffset = 1; mChunkIdCounter = 0; + mInteriorMaterialId = MATERIAL_INTERIOR; } +void FractureToolImpl::setInteriorMaterialId(int32_t materialId) +{ + mInteriorMaterialId = materialId; +} + bool FractureToolImpl::isAncestorForChunk(int32_t ancestorId, int32_t chunkId) { if (ancestorId == chunkId) @@ -1539,5 +1545,22 @@ int32_t FractureToolImpl::getChunkId(int32_t chunkIndex) return mChunkData[chunkIndex].chunkId; } +int32_t FractureToolImpl::getInteriorMaterialId() const +{ + return mInteriorMaterialId; +} + + +void FractureToolImpl::replaceMaterialId(int32_t oldMaterialId, int32_t newMaterialId) +{ + for (auto& chunkData : mChunkData) + { + if (chunkData.meshData) + { + chunkData.meshData->replaceMaterialId(oldMaterialId, newMaterialId); + } + } +} + } // namespace Blast } // namespace Nv diff --git a/sdk/extensions/authoring/source/NvBlastExtAuthoringFractureToolImpl.h b/sdk/extensions/authoring/source/NvBlastExtAuthoringFractureToolImpl.h index 612c0e7..d3eed09 100644 --- a/sdk/extensions/authoring/source/NvBlastExtAuthoringFractureToolImpl.h +++ b/sdk/extensions/authoring/source/NvBlastExtAuthoringFractureToolImpl.h @@ -138,6 +138,7 @@ public: mPlaneIndexerOffset = 1; mChunkIdCounter = 0; mRemoveIslands = false; + mInteriorMaterialId = MATERIAL_INTERIOR; } ~FractureToolImpl() @@ -152,8 +153,22 @@ public: */ void reset() override; + /** + Set the material id to use for new interior faces. Defaults to MATERIAL_INTERIOR + */ + void setInteriorMaterialId(int32_t materialId) override; + + /** + Gets the material id to use for new interior faces + */ + int32_t getInteriorMaterialId() const override; /** + Replaces an material id on faces with a new one + */ + void replaceMaterialId(int32_t oldMaterialId, int32_t newMaterialId) override; + + /** Set input mesh wich will be fractured, FractureTool will be reseted. */ void setSourceMesh(const Mesh* mesh) override; @@ -322,6 +337,7 @@ protected: std::vector<ChunkInfo> mChunkData; bool mRemoveIslands; + int32_t mInteriorMaterialId; }; } // namespace Blast diff --git a/sdk/extensions/authoring/source/NvBlastExtAuthoringMeshImpl.cpp b/sdk/extensions/authoring/source/NvBlastExtAuthoringMeshImpl.cpp index 4b0c3ba..7330598 100644 --- a/sdk/extensions/authoring/source/NvBlastExtAuthoringMeshImpl.cpp +++ b/sdk/extensions/authoring/source/NvBlastExtAuthoringMeshImpl.cpp @@ -226,7 +226,7 @@ void getTangents(PxVec3& normal, PxVec3& t1, PxVec3& t2) t2 = t1.cross(normal); } -Mesh* getCuttingBox(const PxVec3& point, const PxVec3& normal, float size, int32_t id) +Mesh* getCuttingBox(const PxVec3& point, const PxVec3& normal, float size, int32_t id, int32_t interiorMaterialId) { PxVec3 lNormal = normal.getNormalized(); PxVec3 t1, t2; @@ -280,38 +280,38 @@ Mesh* getCuttingBox(const PxVec3& point, const PxVec3& normal, float size, int32 edges.push_back(Edge(1, 2)); edges.push_back(Edge(2, 3)); edges.push_back(Edge(3, 0)); - facets.push_back(Facet(0, 4, MATERIAL_INTERIOR, id, -1)); + facets.push_back(Facet(0, 4, interiorMaterialId, id, -1)); edges.push_back(Edge(0, 3)); edges.push_back(Edge(3, 7)); edges.push_back(Edge(7, 4)); edges.push_back(Edge(4, 0)); - facets.push_back(Facet(4, 4, MATERIAL_INTERIOR, id, -1)); + facets.push_back(Facet(4, 4, interiorMaterialId, id, -1)); edges.push_back(Edge(3, 2)); edges.push_back(Edge(2, 6)); edges.push_back(Edge(6, 7)); edges.push_back(Edge(7, 3)); - facets.push_back(Facet(8, 4, MATERIAL_INTERIOR, id, -1)); + facets.push_back(Facet(8, 4, interiorMaterialId, id, -1)); edges.push_back(Edge(5, 6)); edges.push_back(Edge(6, 2)); edges.push_back(Edge(2, 1)); edges.push_back(Edge(1, 5)); - facets.push_back(Facet(12, 4, MATERIAL_INTERIOR, id, -1)); + facets.push_back(Facet(12, 4, interiorMaterialId, id, -1)); edges.push_back(Edge(4, 5)); edges.push_back(Edge(5, 1)); edges.push_back(Edge(1, 0)); edges.push_back(Edge(0, 4)); - facets.push_back(Facet(16, 4, MATERIAL_INTERIOR, id, -1)); + facets.push_back(Facet(16, 4, interiorMaterialId, id, -1)); edges.push_back(Edge(4, 7)); edges.push_back(Edge(7, 6)); edges.push_back(Edge(6, 5)); edges.push_back(Edge(5, 4)); - facets.push_back(Facet(20, 4, MATERIAL_INTERIOR, id, -1)); + facets.push_back(Facet(20, 4, interiorMaterialId, id, -1)); return new MeshImpl(positions.data(), edges.data(), facets.data(), static_cast<uint32_t>(positions.size()), static_cast<uint32_t>(edges.size()), static_cast<uint32_t>(facets.size())); } @@ -327,7 +327,7 @@ void inverseNormalAndSetIndices(Mesh* mesh, int32_t id) } } -void MeshImpl::setMaterialId(int32_t* materialId) +void MeshImpl::setMaterialId(const int32_t* materialId) { if (materialId != nullptr) { @@ -339,14 +339,26 @@ void MeshImpl::setMaterialId(int32_t* materialId) } } -void MeshImpl::setSmoothingGroup(int32_t* smoothingGroup) + +void MeshImpl::replaceMaterialId(int32_t oldMaterialId, int32_t newMaterialId) +{ + for (uint32_t i = 0; i < mFacets.size(); ++i) + { + if (mFacets[i].materialId == oldMaterialId) + { + mFacets[i].materialId = newMaterialId; + } + } +} + +void MeshImpl::setSmoothingGroup(const int32_t* smoothingGroups) { - if (smoothingGroup != nullptr) + if (smoothingGroups != nullptr) { for (uint32_t i = 0; i < mFacets.size(); ++i) { - mFacets[i].smoothingGroup = *smoothingGroup; - ++smoothingGroup; + mFacets[i].smoothingGroup = *smoothingGroups; + ++smoothingGroups; } } } @@ -397,7 +409,7 @@ bool MeshImpl::isValid() const return mVertices.size() > 0 && mEdges.size() > 0 && mFacets.size() > 0; } -Mesh* getNoisyCuttingBoxPair(const physx::PxVec3& point, const physx::PxVec3& normal, float size, float jaggedPlaneSize, uint32_t resolution, int32_t id, float amplitude, float frequency, int32_t octaves, int32_t seed) +Mesh* getNoisyCuttingBoxPair(const physx::PxVec3& point, const physx::PxVec3& normal, float size, float jaggedPlaneSize, uint32_t resolution, int32_t id, float amplitude, float frequency, int32_t octaves, int32_t seed, int32_t interiorMaterialId) { SimplexNoise nEval(amplitude, frequency, octaves, seed); PxVec3 t1, t2; @@ -443,7 +455,7 @@ Mesh* getNoisyCuttingBoxPair(const physx::PxVec3& point, const physx::PxVec3& no edges.push_back(Edge(i * (resolution + 1) + j + 1, (i + 1) * (resolution + 1) + j + 1)); edges.push_back(Edge((i + 1) * (resolution + 1) + j + 1, (i + 1) * (resolution + 1) + j)); edges.push_back(Edge((i + 1) * (resolution + 1) + j, i * (resolution + 1) + j)); - facets.push_back(Facet(start, 4, MATERIAL_INTERIOR, id, -1)); + facets.push_back(Facet(start, 4, interiorMaterialId, id, -1)); } } uint32_t offset = (resolution + 1) * (resolution + 1); @@ -492,7 +504,7 @@ Mesh* getNoisyCuttingBoxPair(const physx::PxVec3& point, const physx::PxVec3& no edges.push_back(Edge(9 + offset, 8 + offset)); edges.push_back(Edge(8 + offset, 11 + offset)); - facets.push_back(Facet(edgeOffset, 8, MATERIAL_INTERIOR, id, -1)); + facets.push_back(Facet(edgeOffset, 8, interiorMaterialId, id, -1)); @@ -500,37 +512,37 @@ Mesh* getNoisyCuttingBoxPair(const physx::PxVec3& point, const physx::PxVec3& no edges.push_back(Edge(3 + offset, 7 + offset)); edges.push_back(Edge(7 + offset, 4 + offset)); edges.push_back(Edge(4 + offset, 0 + offset)); - facets.push_back(Facet(8 + edgeOffset, 4, MATERIAL_INTERIOR, id, -1)); + facets.push_back(Facet(8 + edgeOffset, 4, interiorMaterialId, id, -1)); edges.push_back(Edge(3 + offset, 2 + offset)); edges.push_back(Edge(2 + offset, 6 + offset)); edges.push_back(Edge(6 + offset, 7 + offset)); edges.push_back(Edge(7 + offset, 3 + offset)); - facets.push_back(Facet(12 + edgeOffset, 4, MATERIAL_INTERIOR, id, -1)); + facets.push_back(Facet(12 + edgeOffset, 4, interiorMaterialId, id, -1)); edges.push_back(Edge(5 + offset, 6 + offset)); edges.push_back(Edge(6 + offset, 2 + offset)); edges.push_back(Edge(2 + offset, 1 + offset)); edges.push_back(Edge(1 + offset, 5 + offset)); - facets.push_back(Facet(16 + edgeOffset, 4, MATERIAL_INTERIOR, id, -1)); + facets.push_back(Facet(16 + edgeOffset, 4, interiorMaterialId, id, -1)); edges.push_back(Edge(4 + offset, 5 + offset)); edges.push_back(Edge(5 + offset, 1 + offset)); edges.push_back(Edge(1 + offset, 0 + offset)); edges.push_back(Edge(0 + offset, 4 + offset)); - facets.push_back(Facet(20 + edgeOffset, 4, MATERIAL_INTERIOR, id, -1)); + facets.push_back(Facet(20 + edgeOffset, 4, interiorMaterialId, id, -1)); edges.push_back(Edge(4 + offset, 7 + offset)); edges.push_back(Edge(7 + offset, 6 + offset)); edges.push_back(Edge(6 + offset, 5 + offset)); edges.push_back(Edge(5 + offset, 4 + offset)); - facets.push_back(Facet(24 + edgeOffset, 4, MATERIAL_INTERIOR, id, -1)); + facets.push_back(Facet(24 + edgeOffset, 4, interiorMaterialId, id, -1)); // return new MeshImpl(vertices.data(), edges.data(), facets.data(), vertices.size(), edges.size(), facets.size()); } -Mesh* getBigBox(const PxVec3& point, float size) +Mesh* getBigBox(const PxVec3& point, float size, int32_t interiorMaterialId) { PxVec3 normal(0, 0, 1); normal.normalize(); @@ -572,38 +584,38 @@ Mesh* getBigBox(const PxVec3& point, float size) edges.push_back(Edge(1, 2)); edges.push_back(Edge(2, 3)); edges.push_back(Edge(3, 0)); - facets.push_back(Facet(0, 4, MATERIAL_INTERIOR, 0, -1)); + facets.push_back(Facet(0, 4, interiorMaterialId, 0, -1)); edges.push_back(Edge(0, 3)); edges.push_back(Edge(3, 7)); edges.push_back(Edge(7, 4)); edges.push_back(Edge(4, 0)); - facets.push_back(Facet(4, 4, MATERIAL_INTERIOR, 0, -1)); + facets.push_back(Facet(4, 4, interiorMaterialId, 0, -1)); edges.push_back(Edge(3, 2)); edges.push_back(Edge(2, 6)); edges.push_back(Edge(6, 7)); edges.push_back(Edge(7, 3)); - facets.push_back(Facet(8, 4, MATERIAL_INTERIOR, 0, -1)); + facets.push_back(Facet(8, 4, interiorMaterialId, 0, -1)); edges.push_back(Edge(5, 6)); edges.push_back(Edge(6, 2)); edges.push_back(Edge(2, 1)); edges.push_back(Edge(1, 5)); - facets.push_back(Facet(12, 4, MATERIAL_INTERIOR, 0, -1)); + facets.push_back(Facet(12, 4, interiorMaterialId, 0, -1)); edges.push_back(Edge(4, 5)); edges.push_back(Edge(5, 1)); edges.push_back(Edge(1, 0)); edges.push_back(Edge(0, 4)); - facets.push_back(Facet(16, 4, MATERIAL_INTERIOR, 0, -1)); + facets.push_back(Facet(16, 4, interiorMaterialId, 0, -1)); edges.push_back(Edge(4, 7)); edges.push_back(Edge(7, 6)); edges.push_back(Edge(6, 5)); edges.push_back(Edge(5, 4)); - facets.push_back(Facet(20, 4, MATERIAL_INTERIOR, 0, -1)); + facets.push_back(Facet(20, 4, interiorMaterialId, 0, -1)); for (int i = 0; i < 8; ++i) positions[i].n = PxVec3(0, 0, 0); return new MeshImpl(positions.data(), edges.data(), facets.data(), static_cast<uint32_t>(positions.size()), static_cast<uint32_t>(edges.size()), static_cast<uint32_t>(facets.size())); diff --git a/sdk/extensions/authoring/source/NvBlastExtAuthoringMeshImpl.h b/sdk/extensions/authoring/source/NvBlastExtAuthoringMeshImpl.h index ee36f9c..5b7b245 100644 --- a/sdk/extensions/authoring/source/NvBlastExtAuthoringMeshImpl.h +++ b/sdk/extensions/authoring/source/NvBlastExtAuthoringMeshImpl.h @@ -138,12 +138,17 @@ public: /** Set per-facet material id. */ - void setMaterialId(int32_t* materialIds) override; + void setMaterialId(const int32_t* materialIds) override; + + /** + Replaces an material id on faces with a new one + */ + void replaceMaterialId(int32_t oldMaterialId, int32_t newMaterialId) override; /** Set per-facet smoothing group. */ - void setSmoothingGroup(int32_t* smoothingGroup) override; + void setSmoothingGroup(const int32_t* smoothingGroups) override; private: std::vector<Vertex> mVertices; @@ -173,14 +178,14 @@ void setCuttingBox(const physx::PxVec3& point, const physx::PxVec3& normal, Mesh \param[in] size Cutting box size \param[in] id Cutting box ID */ -Mesh* getCuttingBox(const physx::PxVec3& point, const physx::PxVec3& normal, float size, int32_t id); +Mesh* getCuttingBox(const physx::PxVec3& point, const physx::PxVec3& normal, float size, int32_t id, int32_t interiorMaterialId); /** Create box at some particular position. \param[in] point Cutting face center \param[in] size Cutting box size */ -Mesh* getBigBox(const physx::PxVec3& point, float size); +Mesh* getBigBox(const physx::PxVec3& point, float size, int32_t interiorMaterialId); /** Create slicing box with noisy cutting surface. @@ -195,7 +200,7 @@ Mesh* getBigBox(const physx::PxVec3& point, float size); \param[in] octaves Noise octaves \param[in] seed Random generator seed, used for noise generation. */ -Mesh* getNoisyCuttingBoxPair(const physx::PxVec3& point, const physx::PxVec3& normal, float size, float jaggedPlaneSize, uint32_t resolution, int32_t id, float amplitude, float frequency, int32_t octaves, int32_t seed); +Mesh* getNoisyCuttingBoxPair(const physx::PxVec3& point, const physx::PxVec3& normal, float size, float jaggedPlaneSize, uint32_t resolution, int32_t id, float amplitude, float frequency, int32_t octaves, int32_t seed, int32_t interiorMaterialId); /** |