mirror of
https://github.com/openharmony/third_party_meshoptimizer.git
synced 2026-07-19 12:03:07 -04:00
indexgenerator: Clean up provoking remapping pass
When all three vertices are used we don't really care which one we take to be the provoking one, as neither can be reused by future triangles anyway. This makes it possible to streamline the logic following the triangle rotation, as we *must* map the provoking vertex to the new index regardless of the case. Hopefully the comments make the flow reasonably clear to the future reader.
This commit is contained in:
+9
-17
@@ -631,27 +631,19 @@ size_t meshopt_generateProvokingIndexBuffer(unsigned int* destination, unsigned
|
||||
|
||||
unsigned int newidx = reorder_offset;
|
||||
|
||||
// now remap[a] = ~0u or all three verts are old
|
||||
// now remap[a] = ~0u or all three vertices are old
|
||||
// recording remap[a] makes it possible to remap future references to the same index, conserving space
|
||||
if (remap[a] == ~0u)
|
||||
{
|
||||
remap[a] = newidx;
|
||||
reorder[reorder_offset++] = a;
|
||||
|
||||
destination[i + 0] = newidx;
|
||||
destination[i + 1] = b;
|
||||
destination[i + 2] = c;
|
||||
}
|
||||
else
|
||||
{
|
||||
// all three verts are old; we need to clone one of them
|
||||
// for now clone a
|
||||
// TODO: predict based on valence if above isn't enough
|
||||
reorder[reorder_offset++] = a;
|
||||
// we need to clone the provoking vertex to get a unique index
|
||||
// if all three are used the choice is arbitrary since no future triangle will be able to reuse any of these
|
||||
reorder[reorder_offset++] = a;
|
||||
|
||||
destination[i + 0] = newidx;
|
||||
destination[i + 1] = b;
|
||||
destination[i + 2] = c;
|
||||
}
|
||||
// note: first vertex is final, the other two will be fixed up in next pass
|
||||
destination[i + 0] = newidx;
|
||||
destination[i + 1] = b;
|
||||
destination[i + 2] = c;
|
||||
|
||||
// update vertex valences for corner heuristic
|
||||
valence[a]--;
|
||||
|
||||
Reference in New Issue
Block a user