Skip to content

Commit

Permalink
Fix displacement
Browse files Browse the repository at this point in the history
  • Loading branch information
kingiler committed Jul 5, 2023
1 parent f94d39f commit 6150152
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/pbrt/util/mesh.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,15 @@ struct TriQuadMesh {
outputMesh.ConvertToOnlyTriangles();
if (outputMesh.n.empty())
outputMesh.ComputeNormals();
std::vector<int> oldTriIndices(outputMesh.triIndices);
outputMesh.triIndices.clear();

// Refine
HashMap<std::pair<int, int>, 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(),
Expand Down

0 comments on commit 6150152

Please sign in to comment.