Skip to content

Commit 45be35f

Browse files
authored
Merge pull request #836 from zeux/nanite-metrics
demo: Implement various metrics for hierarchical simplification
2 parents 21ca56c + a88785b commit 45be35f

File tree

2 files changed

+180
-214
lines changed

2 files changed

+180
-214
lines changed

demo/main.cpp

+6-15
Original file line numberDiff line numberDiff line change
@@ -976,8 +976,8 @@ void meshlets(const Mesh& mesh, bool scan = false, bool uniform = false)
976976
double avg_vertices = 0;
977977
double avg_triangles = 0;
978978
double avg_boundary = 0;
979+
double avg_connected = 0;
979980
size_t not_full = 0;
980-
size_t not_connected = 0;
981981

982982
std::vector<int> boundary(mesh.vertices.size());
983983

@@ -1022,16 +1022,17 @@ void meshlets(const Mesh& mesh, bool scan = false, bool uniform = false)
10221022
roots += follow(parents, j) == int(j);
10231023

10241024
assert(roots != 0);
1025-
not_connected += roots > 1;
1025+
avg_connected += roots;
10261026
}
10271027

10281028
avg_vertices /= double(meshlets.size());
10291029
avg_triangles /= double(meshlets.size());
10301030
avg_boundary /= double(meshlets.size());
1031+
avg_connected /= double(meshlets.size());
10311032

1032-
printf("Meshlets%c: %d meshlets (avg vertices %.1f, avg triangles %.1f, avg boundary %.1f, not full %d, not connected %d) in %.2f msec\n",
1033+
printf("Meshlets%c: %d meshlets (avg vertices %.1f, avg triangles %.1f, avg boundary %.1f, avg connected %.2f, not full %d) in %.2f msec\n",
10331034
scan ? 'S' : (uniform ? 'U' : ' '),
1034-
int(meshlets.size()), avg_vertices, avg_triangles, avg_boundary, int(not_full), int(not_connected), (end - start) * 1000);
1035+
int(meshlets.size()), avg_vertices, avg_triangles, avg_boundary, avg_connected, int(not_full), (end - start) * 1000);
10351036

10361037
float camera[3] = {100, 100, 100};
10371038

@@ -1401,17 +1402,7 @@ void processDev(const char* path)
14011402
if (!loadMesh(mesh, path))
14021403
return;
14031404

1404-
Mesh copy = mesh;
1405-
meshopt_optimizeVertexCache(&copy.indices[0], &copy.indices[0], copy.indices.size(), copy.vertices.size());
1406-
meshopt_optimizeVertexFetch(&copy.vertices[0], &copy.indices[0], copy.indices.size(), &copy.vertices[0], copy.vertices.size(), sizeof(Vertex));
1407-
1408-
meshopt_encodeVertexVersion(0);
1409-
encodeVertex<PackedVertex>(copy, "L");
1410-
meshopt_encodeVertexVersion(1);
1411-
encodeVertex<PackedVertex>(copy, "0", 0);
1412-
encodeVertex<PackedVertex>(copy, "1", 1);
1413-
encodeVertex<PackedVertex>(copy, "2", 2);
1414-
encodeVertex<PackedVertex>(copy, "3", 3);
1405+
meshlets(mesh);
14151406
}
14161407

14171408
void processNanite(const char* path)

0 commit comments

Comments
 (0)