mirror of
https://github.com/openharmony/third_party_meshoptimizer.git
synced 2026-07-18 17:44:31 -04:00
clusterizer: Prioritize triangles with valence 2 edges
When a triangle has two vertices with valence 2, it's typically advantageous to prioritize it above others even if that may require an extra vertex; after removing this triangle, we'll have between one and two isolated triangles with valence=1 vertex which we'll pick up immediately. Avoiding this triangle risks leaving the small triangle cluster alone and going in a different direction only to collect it later. This significantly reduces the number of disconnected clusters due to a better global flow; note that it's important to check for the edge, not just a single valence=2 vertex, as that results in a worse local decision that doesn't sufficiently improve global traversal.
This commit is contained in:
+5
-1
@@ -312,8 +312,12 @@ static unsigned int getNeighborTriangle(const meshopt_Meshlet& meshlet, const Co
|
||||
// artificially increase the priority of dangling triangles as they're expensive to add to new meshlets
|
||||
else if (live_triangles[a] == 1 || live_triangles[b] == 1 || live_triangles[c] == 1)
|
||||
priority = 1;
|
||||
// if two vertices have live count of 2, removing this triangle will make another triangle dangling which is good for overall flow
|
||||
else if ((live_triangles[a] == 2) + (live_triangles[b] == 2) + (live_triangles[c] == 2) >= 2)
|
||||
priority = 2;
|
||||
// otherwise adjust priority to be after the above cases, 3 or 4 based on used[] count
|
||||
else
|
||||
priority = 1 + extra;
|
||||
priority = 2 + extra;
|
||||
|
||||
// since topology-based priority is always more important than the score, we can skip scoring in some cases
|
||||
if (priority > best_priority)
|
||||
|
||||
Reference in New Issue
Block a user