Skip to content

Commit 2d5734b

Browse files
committed
demo: Remove single cluster group special casing
meshopt partitioner currently will not merge completely disconnected clusters, which in some meshes can create a set of early clusters that are not simplified further. METIS will merge these instead, which alters the high level DAG construction flow. It's not clear why single cluster groups should be special: a group with merged disconnected clusters is just effectively synchronizing the LOD transition decisions between different clusters. In the future, meshopt will likely start merging clusters together, but for now it's cleaner to remove this special case.
1 parent 0e5e016 commit 2d5734b

File tree

1 file changed

+2
-19
lines changed

1 file changed

+2
-19
lines changed

demo/nanite.cpp

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,6 @@ void nanite(const std::vector<Vertex>& vertices, const std::vector<unsigned int>
584584

585585
size_t triangles = 0;
586586
size_t stuck_triangles = 0;
587-
int single_clusters = 0;
588587
int stuck_clusters = 0;
589588
int full_clusters = 0;
590589
size_t components_lod = 0;
@@ -603,22 +602,6 @@ void nanite(const std::vector<Vertex>& vertices, const std::vector<unsigned int>
603602
if (groups[i].empty())
604603
continue; // metis shortcut
605604

606-
if (groups[i].size() == 1)
607-
{
608-
#if TRACE
609-
printf("stuck cluster: singleton with %d triangles\n", int(clusters[groups[i][0]].indices.size() / 3));
610-
#endif
611-
612-
if (dump && depth == atoi(dump))
613-
dumpObj("cluster", clusters[groups[i][0]].indices);
614-
615-
single_clusters++;
616-
stuck_clusters++;
617-
stuck_triangles += clusters[groups[i][0]].indices.size() / 3;
618-
retry.push_back(groups[i][0]);
619-
continue;
620-
}
621-
622605
std::vector<unsigned int> merged;
623606
for (size_t j = 0; j < groups[i].size(); ++j)
624607
merged.insert(merged.end(), clusters[groups[i][j]].indices.begin(), clusters[groups[i][j]].indices.end());
@@ -636,7 +619,7 @@ void nanite(const std::vector<Vertex>& vertices, const std::vector<unsigned int>
636619

637620
float error = 0.f;
638621
std::vector<unsigned int> simplified = simplify(vertices, merged, kUseLocks ? &locks : NULL, target_size, &error);
639-
if (simplified.size() > merged.size() * kSimplifyThreshold || simplified.size() / (kClusterSize * 3) >= merged.size() / (kClusterSize * 3))
622+
if (simplified.size() > merged.size() * kSimplifyThreshold)
640623
{
641624
#if TRACE
642625
printf("stuck cluster: simplified %d => %d over threshold\n", int(merged.size() / 3), int(simplified.size() / 3));
@@ -693,7 +676,7 @@ void nanite(const std::vector<Vertex>& vertices, const std::vector<unsigned int>
693676
double(full_clusters) * inv_clusters * 100, double(triangles) * inv_clusters, double(xformed_lod) * inv_clusters, double(components_lod) * inv_clusters, double(boundary_lod) * inv_clusters, avg_group,
694677
int(triangles));
695678
if (stuck_clusters)
696-
printf("; stuck %d clusters (%d single, %d triangles)", stuck_clusters, single_clusters, int(stuck_triangles));
679+
printf("; stuck %d clusters (%d triangles)", stuck_clusters, int(stuck_triangles));
697680
printf("\n");
698681

699682
if (kUseRetry)

0 commit comments

Comments
 (0)