mirror of
https://github.com/openharmony/third_party_meshoptimizer.git
synced 2026-07-19 12:03:07 -04:00
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.
This commit is contained in:
+7
-1
@@ -1276,13 +1276,19 @@ static void remapEdgeLoops(unsigned int* loop, size_t vertex_count, const unsign
|
||||
{
|
||||
for (size_t i = 0; i < vertex_count; ++i)
|
||||
{
|
||||
// note: this is a no-op for vertices that were remapped
|
||||
// ideally we would clear the loop entries for those for consistency, even though they aren't going to be used
|
||||
// however, the remapping process needs loop information for remapped vertices, so this would require a separate pass
|
||||
if (loop[i] != ~0u)
|
||||
{
|
||||
unsigned int l = loop[i];
|
||||
unsigned int r = collapse_remap[l];
|
||||
|
||||
// i == r is a special case when the seam edge is collapsed in a direction opposite to where loop goes
|
||||
loop[i] = (i == r) ? loop[l] : r;
|
||||
if (i == r)
|
||||
loop[i] = (loop[l] != ~0u) ? collapse_remap[loop[l]] : ~0u;
|
||||
else
|
||||
loop[i] = r;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user