Skip to content

Commit b3b7fba

Browse files
committed
simplify: Fix edge loop remap creating invalid loops in some cases
When the seam edge is collapsed in the opposite direction to the loop flow, we need to follow the previous link to discover the new connection. However, if that link pointed to a remapped vertex, we previously would create an invalid loop edge. This would result in inconsistent loop metadata between loop & loopback, and could prevent future seam collapses around the problematic area. The correct thing to do is to remap the connection, unless the loop stopped after that vertex in which case our vertex becomes terminal.
1 parent 85fcf0d commit b3b7fba

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/simplifier.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1276,13 +1276,19 @@ static void remapEdgeLoops(unsigned int* loop, size_t vertex_count, const unsign
12761276
{
12771277
for (size_t i = 0; i < vertex_count; ++i)
12781278
{
1279+
// note: this is a no-op for vertices that were remapped
1280+
// ideally we would clear the loop entries for those for consistency, even though they aren't going to be used
1281+
// however, the remapping process needs loop information for remapped vertices, so this would require a separate pass
12791282
if (loop[i] != ~0u)
12801283
{
12811284
unsigned int l = loop[i];
12821285
unsigned int r = collapse_remap[l];
12831286

12841287
// i == r is a special case when the seam edge is collapsed in a direction opposite to where loop goes
1285-
loop[i] = (i == r) ? loop[l] : r;
1288+
if (i == r)
1289+
loop[i] = (loop[l] != ~0u) ? collapse_remap[loop[l]] : ~0u;
1290+
else
1291+
loop[i] = r;
12861292
}
12871293
}
12881294
}

0 commit comments

Comments
 (0)