Skip to content

Commit 1eec9bd

Browse files
committed
demo: Add meshletsDense test with the same data as meshletsSparse
These are functionally identical but should hit two different adjacency build paths; the order of triangles should be the same in this case because the first triangle is selected based on spatial lookup.
1 parent 079e7c6 commit 1eec9bd

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

demo/tests.cpp

+24
Original file line numberDiff line numberDiff line change
@@ -1040,6 +1040,28 @@ static void clusterBoundsDegenerate()
10401040
assert(bounds2.center[2] - bounds2.radius <= 0 && bounds2.center[2] + bounds2.radius >= 1);
10411041
}
10421042

1043+
static void meshletsDense()
1044+
{
1045+
const float vbd[4 * 3] = {};
1046+
const unsigned int ibd[6] = {0, 2, 1, 1, 2, 3};
1047+
1048+
meshopt_Meshlet ml[1];
1049+
unsigned int mv[4];
1050+
unsigned char mt[8];
1051+
size_t mc = meshopt_buildMeshlets(ml, mv, mt, ibd, 6, vbd, 4, sizeof(float) * 3, 64, 64, 0.f);
1052+
1053+
assert(mc == 1);
1054+
assert(ml[0].triangle_count == 2);
1055+
assert(ml[0].vertex_count == 4);
1056+
1057+
unsigned int tri0[3] = {mv[mt[0]], mv[mt[1]], mv[mt[2]]};
1058+
unsigned int tri1[3] = {mv[mt[3]], mv[mt[4]], mv[mt[5]]};
1059+
1060+
// technically triangles could also be flipped in the meshlet but for now just assume they aren't
1061+
assert(memcmp(tri0, ibd + 0, 3 * sizeof(unsigned int)) == 0);
1062+
assert(memcmp(tri1, ibd + 3, 3 * sizeof(unsigned int)) == 0);
1063+
}
1064+
10431065
static void meshletsSparse()
10441066
{
10451067
const float vbd[16 * 3] = {};
@@ -2116,6 +2138,8 @@ void runTests()
21162138
encodeFilterExpClamp();
21172139

21182140
clusterBoundsDegenerate();
2141+
2142+
meshletsDense();
21192143
meshletsSparse();
21202144

21212145
customAllocator();

0 commit comments

Comments
 (0)