Skip to content

Commit

Permalink
demo: Add tests for simplification with locked vertices
Browse files Browse the repository at this point in the history
The test data is identical to simplifyLockBorder but allows to specify
the border explicitly instead of inferring it.
  • Loading branch information
zeux committed Apr 2, 2024
1 parent 3c3e56d commit 9591117
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions demo/tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1185,6 +1185,55 @@ static void simplifyAttr()
assert(memcmp(ib, expected, sizeof(expected)) == 0);
}

static void simplifyLockFlags()
{
float vb[] = {
0.000000f, 0.000000f, 0.000000f,
0.000000f, 1.000000f, 0.000000f,
0.000000f, 2.000000f, 0.000000f,
1.000000f, 0.000000f, 0.000000f,
1.000000f, 1.000000f, 0.000000f,
1.000000f, 2.000000f, 0.000000f,
2.000000f, 0.000000f, 0.000000f,
2.000000f, 1.000000f, 0.000000f,
2.000000f, 2.000000f, 0.000000f, // clang-format :-/
};

unsigned char lock[9] = {
1, 1, 1,
1, 0, 1,
1, 1, 1, // clang-format :-/
};

// 0 1 2
// 3 4 5
// 6 7 8

unsigned int ib[] = {
0, 1, 3,
3, 1, 4,
1, 2, 4,
4, 2, 5,
3, 4, 6,
6, 4, 7,
4, 5, 7,
7, 5, 8, // clang-format :-/
};

unsigned int expected[] = {
0, 1, 3,
1, 2, 3,
3, 2, 5,
6, 3, 7,
3, 5, 7,
7, 5, 8, // clang-format :-/
};

assert(meshopt_simplifyWithAttributes(ib, ib, 24, vb, 9, 12, NULL, 0, NULL, 0, lock, 3, 1e-3f, 0) == 18);
assert(memcmp(ib, expected, sizeof(expected)) == 0);
}


static void adjacency()
{
// 0 1/4
Expand Down Expand Up @@ -1399,6 +1448,7 @@ void runTests()
simplifyDegenerate();
simplifyLockBorder();
simplifyAttr();
simplifyLockFlags();

adjacency();
tessellation();
Expand Down

0 comments on commit 9591117

Please sign in to comment.