diff --git a/src/pbrt/util/mesh.h b/src/pbrt/util/mesh.h index db72e8f3f..95d3080fd 100644 --- a/src/pbrt/util/mesh.h +++ b/src/pbrt/util/mesh.h @@ -99,13 +99,15 @@ struct TriQuadMesh { outputMesh.ConvertToOnlyTriangles(); if (outputMesh.n.empty()) outputMesh.ComputeNormals(); + std::vector oldTriIndices(outputMesh.triIndices); outputMesh.triIndices.clear(); // Refine HashMap, int, HashIntPair> edgeSplit({}); - for (int i = 0; i < triIndices.size() / 3; ++i) - outputMesh.Refine(dist, maxDist, triIndices[3 * i], triIndices[3 * i + 1], - triIndices[3 * i + 2], edgeSplit); + for (int i = 0; i < oldTriIndices.size() / 3; ++i) + outputMesh.Refine(dist, maxDist, oldTriIndices[3 * i], + oldTriIndices[3 * i + 1], oldTriIndices[3 * i + 2], + edgeSplit); // Displace displace(outputMesh.p.data(), outputMesh.n.data(), outputMesh.uv.data(),