Skip to content

Commit bd102e4

Browse files
Update CSmoothNormalGenerator.cpp
Resolve #941 (comment)
1 parent 4391433 commit bd102e4

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/nbl/asset/utils/CSmoothNormalGenerator.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,10 @@ core::smart_refctd_ptr<ICPUPolygonGeometry> CSmoothNormalGenerator::processConne
9999
{
100100
auto normal = processedVertex.weightedNormal;
101101

102+
// We perform double the work (since `vxcmp` must be commutative but not required to be associative) intentionally,
103+
// because without guaranteed associativity we cannot partition the vertices into disjoint sets (we're not reconstructing OBJ-like
104+
// smooth groups with this), so we can't have all vertices in a set just copy their normal from a "master vertex".
105+
// For an example of why that is good, think of a cone or cylinder and why its good to have non-associative smoothing predicate.
102106
vertexHashMap.forEachBroadphaseNeighborCandidates(processedVertex.getPosition(), [&](const VertexHashMap::vertex_data_t& candidate)
103107
{
104108
if (processedVertex.index != candidate.index && compareVertexPosition(processedVertex.position, candidate.position, epsilon) &&
@@ -120,4 +124,4 @@ core::smart_refctd_ptr<ICPUPolygonGeometry> CSmoothNormalGenerator::processConne
120124
}
121125

122126
}
123-
}
127+
}

0 commit comments

Comments
 (0)