From 1e887d827e65a084a0ad0ba933c61a8330aeee07 Mon Sep 17 00:00:00 2001 From: Bryan Galdrikian Date: Mon, 28 Aug 2017 13:55:34 -0700 Subject: 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. --- .../source/NvBlastExtAuthoringMeshImpl.cpp | 66 +++++++++++++--------- 1 file changed, 39 insertions(+), 27 deletions(-) (limited to 'sdk/extensions/authoring/source/NvBlastExtAuthoringMeshImpl.cpp') 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(positions.size()), static_cast(edges.size()), static_cast(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(positions.size()), static_cast(edges.size()), static_cast(facets.size())); -- cgit v1.2.3