Skip to content

Commit 426cb2d

Browse files
authored
Merge pull request #1042 from zeux/optrot
meshletutils: Tweak optimizeMeshletLevel rotation for compressibility
2 parents e2b3613 + 43dedc3 commit 426cb2d

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

src/meshletutils.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@ void meshopt_optimizeMeshletLevel(unsigned int* meshlet_vertices, size_t vertex_
491491
// if subsequent triangles don't share edges ca or bc, we can rotate the triangle to fix this
492492
bool needab = false, needbc = false, needca = false;
493493

494-
for (size_t j = i + 1; j < triangle_count && j <= i + 3; ++j)
494+
for (size_t j = i + 1; j < triangle_count && j <= i + cache_cutoff; ++j)
495495
{
496496
unsigned char oa = indices[j * 3 + 0], ob = indices[j * 3 + 1], oc = indices[j * 3 + 2];
497497

@@ -513,6 +513,12 @@ void meshopt_optimizeMeshletLevel(unsigned int* meshlet_vertices, size_t vertex_
513513
unsigned char t = c;
514514
c = b, b = a, a = t;
515515
}
516+
else if (!needab && needbc && !needca)
517+
{
518+
// abc -> cab: put bc at most recent FIFO position
519+
unsigned char t = c;
520+
c = b, b = a, a = t;
521+
}
516522
}
517523

518524
indices[i * 3 + 0] = a, indices[i * 3 + 1] = b, indices[i * 3 + 2] = c;

0 commit comments

Comments
 (0)