diff options
| author | Anton Novoselov <[email protected]> | 2017-08-08 20:14:22 +0300 |
|---|---|---|
| committer | Anton Novoselov <[email protected]> | 2017-08-08 20:14:22 +0300 |
| commit | d41654b469fa51870b5952c836c04d9da17f32d3 (patch) | |
| tree | 64f8f437eef394630355f281d35ca1d53e5c4d6c /sdk | |
| parent | add +x for packman script (diff) | |
| download | blast-d41654b469fa51870b5952c836c04d9da17f32d3.tar.xz blast-d41654b469fa51870b5952c836c04d9da17f32d3.zip | |
Updated to CL 22627414:
* docs updates
* authoring fixes
* stress solver crash fixes
Diffstat (limited to 'sdk')
11 files changed, 111 insertions, 62 deletions
diff --git a/sdk/extensions/authoring/include/NvBlastExtAuthoringFractureTool.h b/sdk/extensions/authoring/include/NvBlastExtAuthoringFractureTool.h index 82959ac..e6a6d41 100644 --- a/sdk/extensions/authoring/include/NvBlastExtAuthoringFractureTool.h +++ b/sdk/extensions/authoring/include/NvBlastExtAuthoringFractureTool.h @@ -231,11 +231,12 @@ public: \param[in] cellPoints Array of voronoi sites \param[in] cellPoints Array of voronoi sites \param[in] scale Voronoi cells scaling factor + \param[in] rotation Voronoi cells rotation. Has no effect without cells scale factor \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 \return If 0, fracturing is successful. */ - virtual int32_t voronoiFracturing(uint32_t chunkId, uint32_t cellCount, const physx::PxVec3* cellPoints, const physx::PxVec3& scale, bool replaceChunk) = 0; + virtual int32_t voronoiFracturing(uint32_t chunkId, uint32_t cellCount, const physx::PxVec3* cellPoints, const physx::PxVec3& scale, const physx::PxQuat& rotation, bool replaceChunk) = 0; /** diff --git a/sdk/extensions/authoring/include/NvBlastExtAuthoringTypes.h b/sdk/extensions/authoring/include/NvBlastExtAuthoringTypes.h index 13865f7..0986cf4 100644 --- a/sdk/extensions/authoring/include/NvBlastExtAuthoringTypes.h +++ b/sdk/extensions/authoring/include/NvBlastExtAuthoringTypes.h @@ -85,7 +85,7 @@ struct Triangle Vertex a, b, c; int32_t userData; int32_t materialId; - int32_t smoothingGroup; // NOT SUPPORTED ATM. + int32_t smoothingGroup; physx::PxVec3 getNormal() { return ((b.p - a.p).cross(c.p - a.p)); diff --git a/sdk/extensions/authoring/source/NvBlastExtAuthoringBooleanTool.cpp b/sdk/extensions/authoring/source/NvBlastExtAuthoringBooleanTool.cpp index 7705173..359b077 100644 --- a/sdk/extensions/authoring/source/NvBlastExtAuthoringBooleanTool.cpp +++ b/sdk/extensions/authoring/source/NvBlastExtAuthoringBooleanTool.cpp @@ -91,12 +91,33 @@ NV_FORCE_INLINE int32_t veStatus10(const PxVec3& sEdge, const PxVec3& eEdge, con return -vertexShadowing(eEdge, p) + vertexShadowing(sEdge, p); } +bool shouldSwap(const PxVec3& a, const PxVec3& b) +{ + if (a.x < b.x) return false; + if (a.x > b.x) return true; + + if (a.y < b.y) return false; + if (a.y > b.y) return true; + + if (a.z < b.z) return false; + if (a.z > b.z) return true; + return false; +} + + /** Vertex-edge shadowing functions */ -int32_t shadowing01(const Vertex& sEdge, const Vertex& eEdge, const PxVec3& p, Vertex& onEdgePoint, bool& hasOnEdge) +int32_t shadowing01(Vertex sEdge, Vertex eEdge, const PxVec3& p, Vertex& onEdgePoint, bool& hasOnEdge) { + int32_t winding = veStatus01(sEdge.p, eEdge.p, p); + + if (sEdge.p.x > eEdge.p.x) + { + std::swap(sEdge, eEdge); + } + if (winding != 0) { float t = (p.x - sEdge.p.x) / (eEdge.p.x - sEdge.p.x); @@ -458,7 +479,14 @@ int32_t edgeFacetIntersection12(const Vertex& edSt, const Vertex& edEnd, const V for (int32_t ed = 0; ed < edgesCount; ++ed) { - shadowingType = edgeEdgeShadowing(edSt, edEnd, points[edges[ed].s], points[edges[ed].e], p1, p2, hasPoint); + if (shouldSwap(points[edges[ed].s].p, points[edges[ed].e].p)) + { + shadowingType = -edgeEdgeShadowing(edSt, edEnd, points[edges[ed].e], points[edges[ed].s], p1, p2, hasPoint); + } + else + { + shadowingType = edgeEdgeShadowing(edSt, edEnd, points[edges[ed].s], points[edges[ed].e], p1, p2, hasPoint); + } status -= shadowingType; if (shadowingType == 0 && !aShadowing && hasPoint) { @@ -600,8 +628,7 @@ int32_t BooleanEvaluator::vertexMeshStatus03(const PxVec3& p, const Mesh* mesh) //{ // Edge* ed = mesh->getEdges() + mesh->getFacet(facet)->firstEdgeNumber; // status += shadowing02(p, mesh->getVertices(), ed, mesh->getFacet(facet)->edgesCount, hasPoint, pnt); - //} - + //}; return status; } @@ -685,19 +712,7 @@ int32_t BooleanEvaluator::isPointContainedInMesh(const Mesh* msh, SpatialAcceler } -bool shouldSwap(const PxVec3& a, const PxVec3& b) -{ - if (a.x < b.x) return false; - if (a.x > b.x) return true; - - if (a.y < b.y) return false; - if (a.y > b.y) return true; - - if (a.z < b.z) return false; - if (a.z > b.z) return true; - return false; -} void BooleanEvaluator::buildFaceFaceIntersections(BooleanConf mode) { @@ -1288,6 +1303,8 @@ Mesh* BooleanEvaluator::createNewMesh() uint32_t collected = 0; int32_t userData = 0; int32_t materialId = 0; + int32_t smoothingGroup = 0; + for (uint32_t i = 0; i < mEdgeAggregate.size(); ++i) { if (mEdgeAggregate[i].parent != lastParent) @@ -1296,13 +1313,16 @@ Mesh* BooleanEvaluator::createNewMesh() { userData = mMeshA->getFacet(lastParent)->userData; materialId = mMeshA->getFacet(lastParent)->materialId; + smoothingGroup = mMeshA->getFacet(lastParent)->smoothingGroup; + } else { userData = mMeshB->getFacet(lastParent - mMeshA->getFacetCount())->userData; materialId = mMeshB->getFacet(lastParent - mMeshA->getFacetCount())->materialId; + smoothingGroup = mMeshB->getFacet(lastParent - mMeshA->getFacetCount())->smoothingGroup; } - newFacets.push_back(Facet(lastPos, collected, materialId, userData)); + newFacets.push_back(Facet(lastPos, collected, materialId, userData, smoothingGroup)); lastPos = i; lastParent = mEdgeAggregate[i].parent; collected = 0; @@ -1316,14 +1336,15 @@ Mesh* BooleanEvaluator::createNewMesh() { userData = mMeshA->getFacet(lastParent)->userData; materialId = mMeshA->getFacet(lastParent)->materialId; - + smoothingGroup = mMeshA->getFacet(lastParent)->smoothingGroup; } else { userData = mMeshB->getFacet(pr)->userData; materialId = mMeshB->getFacet(pr)->materialId; + smoothingGroup = mMeshB->getFacet(pr)->smoothingGroup; } - newFacets.push_back(Facet(lastPos, collected, materialId, userData)); + newFacets.push_back(Facet(lastPos, collected, materialId, userData, smoothingGroup)); return new MeshImpl(mVerticesAggregate.data(), newEdges.data(), newFacets.data(), static_cast<uint32_t>(mVerticesAggregate.size()), static_cast<uint32_t>(mEdgeAggregate.size()), static_cast<uint32_t>(newFacets.size())); } diff --git a/sdk/extensions/authoring/source/NvBlastExtAuthoringFractureToolImpl.cpp b/sdk/extensions/authoring/source/NvBlastExtAuthoringFractureToolImpl.cpp index 91c81bc..8378ef0 100644 --- a/sdk/extensions/authoring/source/NvBlastExtAuthoringFractureToolImpl.cpp +++ b/sdk/extensions/authoring/source/NvBlastExtAuthoringFractureToolImpl.cpp @@ -524,7 +524,7 @@ bool FractureToolImpl::isMeshContainOpenEdges(const Mesh* input) return collected & 1; } -int32_t FractureToolImpl::voronoiFracturing(uint32_t chunkId, uint32_t cellCount, const physx::PxVec3* cellPointsIn, const physx::PxVec3& scale, bool replaceChunk) +int32_t FractureToolImpl::voronoiFracturing(uint32_t chunkId, uint32_t cellCount, const physx::PxVec3* cellPointsIn, const physx::PxVec3& scale, const physx::PxQuat& rotation, bool replaceChunk) { if (chunkId == 0 && replaceChunk) { @@ -549,9 +549,12 @@ int32_t FractureToolImpl::voronoiFracturing(uint32_t chunkId, uint32_t cellCount { cellPoints[i] = (cellPointsIn[i] - mOffset) * (1.0f / mScaleFactor); + cellPoints[i] = rotation.rotateInv(cellPoints[i]); + cellPoints[i].x *= (1.0f / scale.x); cellPoints[i].y *= (1.0f / scale.y); cellPoints[i].z *= (1.0f / scale.z); + } /** @@ -585,6 +588,7 @@ int32_t FractureToolImpl::voronoiFracturing(uint32_t chunkId, uint32_t cellCount cell->getVerticesWritable()[v].p.x *= scale.x; cell->getVerticesWritable()[v].p.y *= scale.y; cell->getVerticesWritable()[v].p.z *= scale.z; + cell->getVerticesWritable()[v].p = rotation.rotate(cell->getVerticesWritable()[v].p); } cell->recalculateBoundingBox(); DummyAccelerator dmAccel(cell->getFacetCount()); @@ -1069,7 +1073,7 @@ void FractureToolImpl::setSourceMesh(const Mesh* meshInput) if (isMeshContainOpenEdges(meshInput)) { - NVBLAST_LOG_WARNING("WARNING! Input mesh contains open edges, it may lead to wrong fractruing results!. \n"); + NVBLAST_LOG_WARNING("Input mesh contains open edges, it may lead to wrong fractruing results!. \n"); } diff --git a/sdk/extensions/authoring/source/NvBlastExtAuthoringFractureToolImpl.h b/sdk/extensions/authoring/source/NvBlastExtAuthoringFractureToolImpl.h index 9b656e3..612c0e7 100644 --- a/sdk/extensions/authoring/source/NvBlastExtAuthoringFractureToolImpl.h +++ b/sdk/extensions/authoring/source/NvBlastExtAuthoringFractureToolImpl.h @@ -186,11 +186,12 @@ public: \param[in] cellPoints Array of voronoi sites \param[in] cellPoints Array of voronoi sites \param[in] scale Voronoi cells scaling factor + \param[in] rotation Voronoi cells rotation. Has no effect without cells scale factor \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 \return If 0, fracturing is successful. */ - int32_t voronoiFracturing(uint32_t chunkId, uint32_t cellCount, const physx::PxVec3* cellPoints, const physx::PxVec3& scale, bool replaceChunk) override; + int32_t voronoiFracturing(uint32_t chunkId, uint32_t cellCount, const physx::PxVec3* cellPoints, const physx::PxVec3& scale, const physx::PxQuat& rotation, bool replaceChunk) override; /** diff --git a/sdk/extensions/authoring/source/NvBlastExtAuthoringMeshImpl.cpp b/sdk/extensions/authoring/source/NvBlastExtAuthoringMeshImpl.cpp index 3497fda..4b0c3ba 100644 --- a/sdk/extensions/authoring/source/NvBlastExtAuthoringMeshImpl.cpp +++ b/sdk/extensions/authoring/source/NvBlastExtAuthoringMeshImpl.cpp @@ -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)); + facets.push_back(Facet(0, 4, MATERIAL_INTERIOR, 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)); + facets.push_back(Facet(4, 4, MATERIAL_INTERIOR, 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)); + facets.push_back(Facet(8, 4, MATERIAL_INTERIOR, 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)); + facets.push_back(Facet(12, 4, MATERIAL_INTERIOR, 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)); + facets.push_back(Facet(16, 4, MATERIAL_INTERIOR, 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)); + facets.push_back(Facet(20, 4, MATERIAL_INTERIOR, 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())); } @@ -443,7 +443,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)); + facets.push_back(Facet(start, 4, MATERIAL_INTERIOR, id, -1)); } } uint32_t offset = (resolution + 1) * (resolution + 1); @@ -492,7 +492,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)); + facets.push_back(Facet(edgeOffset, 8, MATERIAL_INTERIOR, id, -1)); @@ -500,31 +500,31 @@ 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)); + facets.push_back(Facet(8 + edgeOffset, 4, MATERIAL_INTERIOR, 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)); + facets.push_back(Facet(12 + edgeOffset, 4, MATERIAL_INTERIOR, 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)); + facets.push_back(Facet(16 + edgeOffset, 4, MATERIAL_INTERIOR, 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)); + facets.push_back(Facet(20 + edgeOffset, 4, MATERIAL_INTERIOR, 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)); + facets.push_back(Facet(24 + edgeOffset, 4, MATERIAL_INTERIOR, id, -1)); // return new MeshImpl(vertices.data(), edges.data(), facets.data(), vertices.size(), edges.size(), facets.size()); @@ -572,38 +572,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)); + facets.push_back(Facet(0, 4, MATERIAL_INTERIOR, 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)); + facets.push_back(Facet(4, 4, MATERIAL_INTERIOR, 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)); + facets.push_back(Facet(8, 4, MATERIAL_INTERIOR, 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)); + facets.push_back(Facet(12, 4, MATERIAL_INTERIOR, 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)); + facets.push_back(Facet(16, 4, MATERIAL_INTERIOR, 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)); + facets.push_back(Facet(20, 4, MATERIAL_INTERIOR, 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/NvBlastExtAuthoringMeshNoiser.cpp b/sdk/extensions/authoring/source/NvBlastExtAuthoringMeshNoiser.cpp index 72e9413..0cd6ddd 100644 --- a/sdk/extensions/authoring/source/NvBlastExtAuthoringMeshNoiser.cpp +++ b/sdk/extensions/authoring/source/NvBlastExtAuthoringMeshNoiser.cpp @@ -757,15 +757,20 @@ void MeshNoiser::divideEdge(int32_t id) mTrMeshEdToTr[ind1].add(mTrMeshEdToTr[id].tr[t]); int32_t userInfo = mTriangles[mTrMeshEdToTr[id].tr[t]].userData; int32_t matId = mTriangles[mTrMeshEdToTr[id].tr[t]].materialId; + int32_t smId = mTriangles[mTrMeshEdToTr[id].tr[t]].smoothingGroup; mTriangles[mTrMeshEdToTr[id].tr[t]] = TriangleIndexed(pbf[p], nv, pbf[opp]); mTriangles[mTrMeshEdToTr[id].tr[t]].userData = userInfo; mTriangles[mTrMeshEdToTr[id].tr[t]].materialId = matId; + mTriangles[mTrMeshEdToTr[id].tr[t]].smoothingGroup = smId; + mTrMeshEdToTr[ind2].add((int32_t)mTriangles.size()); mTrMeshEdToTr[ind3].add((int32_t)mTrMeshEdToTr[id].tr[t]); mTrMeshEdToTr[ind3].add((int32_t)mTriangles.size()); mTriangles.push_back(TriangleIndexed(nv,pbf[pnx], pbf[opp])); mTriangles.back().userData = userInfo; mTriangles.back().materialId = matId; + mTriangles.back().smoothingGroup = smId; + int32_t ed1 = findEdge(Edge(pbf[pnx], pbf[opp])); mTrMeshEdToTr[ed1].replace(oldTriangleIndex, (int32_t)mTriangles.size() - 1); break; diff --git a/sdk/extensions/exporter/source/NvBlastExtExporterFbxReader.cpp b/sdk/extensions/exporter/source/NvBlastExtExporterFbxReader.cpp index df0500e..c376701 100644 --- a/sdk/extensions/exporter/source/NvBlastExtExporterFbxReader.cpp +++ b/sdk/extensions/exporter/source/NvBlastExtExporterFbxReader.cpp @@ -218,7 +218,8 @@ void FbxFileReader::loadFromFile(const char* filename) std::cerr << "Mesh has more than 1 material mappings, first one will be used. " << std::endl; } auto matLayer = mesh->GetElementMaterial(0); - + auto smLayer = mesh->GetElementSmoothing(); + for (int i = 0; i < polyCount; i++) { @@ -245,6 +246,10 @@ void FbxFileReader::loadFromFile(const char* filename) { mMaterialIds.push_back(matLayer->GetIndexArray().GetAt(i)); } + if (smLayer != nullptr) + { + mSmoothingGroups.push_back(smLayer->GetDirectArray().GetAt(i)); + } } mVertexPositions = positions; @@ -255,6 +260,18 @@ void FbxFileReader::loadFromFile(const char* filename) getBoneInfluencesInternal(mesh); } +int32_t* FbxFileReader::getSmoothingGroups() +{ + if (!mSmoothingGroups.empty()) + { + return mSmoothingGroups.data(); + } + else + { + return nullptr; + } +} + int32_t FbxFileReader::getMaterialCount() { return mMaterialNames.size(); diff --git a/sdk/extensions/exporter/source/NvBlastExtExporterFbxReader.h b/sdk/extensions/exporter/source/NvBlastExtExporterFbxReader.h index 4155b25..b7c81aa 100644 --- a/sdk/extensions/exporter/source/NvBlastExtExporterFbxReader.h +++ b/sdk/extensions/exporter/source/NvBlastExtExporterFbxReader.h @@ -104,7 +104,7 @@ public: /** Get loaded per triangle smoothing groups. Currently not supported. */ - int32_t* getSmoothingGroups() override { return nullptr; }; + int32_t* getSmoothingGroups() override; /** Get material name. diff --git a/sdk/extensions/exporter/source/NvBlastExtExporterFbxWriter.cpp b/sdk/extensions/exporter/source/NvBlastExtExporterFbxWriter.cpp index b5fd04b..161ec5f 100644 --- a/sdk/extensions/exporter/source/NvBlastExtExporterFbxWriter.cpp +++ b/sdk/extensions/exporter/source/NvBlastExtExporterFbxWriter.cpp @@ -148,7 +148,7 @@ bool FbxFileWriter::appendMesh(const AuthoringResult& aResult, const char* asset //Found a valid smoothing group smElement = mesh->CreateElementSmoothing(); smElement->SetMappingMode(FbxGeometryElement::eByPolygon); - smElement->SetReferenceMode(FbxGeometryElement::eIndexToDirect); + smElement->SetReferenceMode(FbxGeometryElement::eDirect); break; } } @@ -423,11 +423,11 @@ uint32_t FbxFileWriter::createChunkRecursive(uint32_t currentCpIdx, uint32_t chu { if (tri.userData == 0) { - smElement->GetIndexArray().SetAt(polyCount, tri.smoothingGroup); + smElement->GetDirectArray().Add(tri.smoothingGroup); } else { - smElement->GetIndexArray().SetAt(polyCount, SMOOTHING_GROUP_INTERIOR); + smElement->GetDirectArray().Add(SMOOTHING_GROUP_INTERIOR); } } @@ -611,7 +611,7 @@ void FbxFileWriter::createChunkRecursiveNonSkinned(const std::string& meshName, //Found a valid smoothing group smElement = mesh->CreateElementSmoothing(); smElement->SetMappingMode(FbxGeometryElement::eByPolygon); - smElement->SetReferenceMode(FbxGeometryElement::eIndexToDirect); + smElement->SetReferenceMode(FbxGeometryElement::eDirect); break; } } @@ -658,11 +658,11 @@ void FbxFileWriter::createChunkRecursiveNonSkinned(const std::string& meshName, { if (geo.userData == 0) { - smElement->GetIndexArray().SetAt(polyCount, geo.smoothingGroup); + smElement->GetDirectArray().Add(geo.smoothingGroup); } else { - smElement->GetIndexArray().SetAt(polyCount, SMOOTHING_GROUP_INTERIOR); + smElement->GetDirectArray().Add(SMOOTHING_GROUP_INTERIOR); } } diff --git a/sdk/extensions/stress/source/NvBlastExtStressSolver.cpp b/sdk/extensions/stress/source/NvBlastExtStressSolver.cpp index 335aacb..878165b 100644 --- a/sdk/extensions/stress/source/NvBlastExtStressSolver.cpp +++ b/sdk/extensions/stress/source/NvBlastExtStressSolver.cpp @@ -1191,10 +1191,10 @@ bool ExtStressSolverImpl::notifyActorCreated(const NvBlastActor& actor) // update neighbors { uint32_t* graphNodeIndices = getScratchArray<uint32_t>(graphNodeCount); - NvBlastActorGetGraphNodeIndices(graphNodeIndices, graphNodeCount, &actor, logLL); - for (uint32_t i = 0; i < graphNodeCount; ++i) + const uint32_t nodeCount = NvBlastActorGetGraphNodeIndices(graphNodeIndices, graphNodeCount, &actor, logLL); + for (uint32_t i = 0; i < nodeCount; ++i) { - m_graphProcessor->setNodeNeighborsCount(graphNodeIndices[i], graphNodeCount); + m_graphProcessor->setNodeNeighborsCount(graphNodeIndices[i], nodeCount); } } @@ -1263,9 +1263,9 @@ bool ExtStressSolverImpl::addForce(const NvBlastActor& actor, physx::PxVec3 loca if (graphNodeCount > 1) { uint32_t* graphNodeIndices = getScratchArray<uint32_t>(graphNodeCount); - NvBlastActorGetGraphNodeIndices(graphNodeIndices, graphNodeCount, &actor, logLL); + const uint32_t nodeCount = NvBlastActorGetGraphNodeIndices(graphNodeIndices, graphNodeCount, &actor, logLL); - for (uint32_t i = 0; i < graphNodeCount; ++i) + for (uint32_t i = 0; i < nodeCount; ++i) { const uint32_t node = graphNodeIndices[i]; const float sqrDist = (localPosition - m_graphProcessor->getNodeData(node).localPos).magnitudeSquared(); @@ -1296,9 +1296,9 @@ bool ExtStressSolverImpl::addGravityForce(const NvBlastActor& actor, physx::PxVe if (graphNodeCount > 1) { uint32_t* graphNodeIndices = getScratchArray<uint32_t>(graphNodeCount); - NvBlastActorGetGraphNodeIndices(graphNodeIndices, graphNodeCount, &actor, logLL); + const uint32_t nodeCount = NvBlastActorGetGraphNodeIndices(graphNodeIndices, graphNodeCount, &actor, logLL); - for (uint32_t i = 0; i < graphNodeCount; ++i) + for (uint32_t i = 0; i < nodeCount; ++i) { const uint32_t node = graphNodeIndices[i]; m_graphProcessor->addNodeVelocity(node, localGravity); @@ -1314,10 +1314,10 @@ bool ExtStressSolverImpl::addAngularVelocity(const NvBlastActor& actor, PxVec3 l if (graphNodeCount > 1) { uint32_t* graphNodeIndices = getScratchArray<uint32_t>(graphNodeCount); - NvBlastActorGetGraphNodeIndices(graphNodeIndices, graphNodeCount, &actor, logLL); + const uint32_t nodeCount = NvBlastActorGetGraphNodeIndices(graphNodeIndices, graphNodeCount, &actor, logLL); // Apply centrifugal force - for (uint32_t i = 0; i < graphNodeCount; ++i) + for (uint32_t i = 0; i < nodeCount; ++i) { const uint32_t node = graphNodeIndices[i]; const auto& localPos = m_graphProcessor->getNodeData(node).localPos; @@ -1367,9 +1367,9 @@ void ExtStressSolverImpl::fillFractureCommands(const NvBlastActor& actor, NvBlas if (graphNodeCount > 1 && m_graphProcessor->getOverstressedBondCount() > 0) { uint32_t* graphNodeIndices = getScratchArray<uint32_t>(graphNodeCount); - NvBlastActorGetGraphNodeIndices(graphNodeIndices, graphNodeCount, &actor, logLL); + const uint32_t nodeCount = NvBlastActorGetGraphNodeIndices(graphNodeIndices, graphNodeCount, &actor, logLL); - for (uint32_t i = 0; i < graphNodeCount; ++i) + for (uint32_t i = 0; i < nodeCount; ++i) { const uint32_t node0 = graphNodeIndices[i]; for (uint32_t adjacencyIndex = m_graph.adjacencyPartition[node0]; adjacencyIndex < m_graph.adjacencyPartition[node0 + 1]; adjacencyIndex++) |