Skip to content

Commit 574b211

Browse files
committed
partition: Reduce partition size range
With our existing heuristics, we would on average produce partitions with size ~15% over the target. This is not entirely desirable and skews the comparison metrics somewhat; it's especially problematic when the target partition size is a power of two, since it creates an easy path to get to the max partition size by incrementally doubling until the target, and then merging partitions with target and target/2 together. For now just reducing the extra size allowance a little to 3/8 of target maintains reasonable partitioning properties with closer-to-target average size.
1 parent aa1af2a commit 574b211

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/partition.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,8 @@ size_t meshopt_partitionClusters(unsigned int* destination, const unsigned int*
307307

308308
assert(target_partition_size > 0);
309309

310+
size_t max_partition_size = target_partition_size + target_partition_size * 3 / 8;
311+
310312
meshopt_Allocator allocator;
311313

312314
unsigned char* used = allocator.allocate<unsigned char>(vertex_count);
@@ -318,6 +320,8 @@ size_t meshopt_partitionClusters(unsigned int* destination, const unsigned int*
318320

319321
for (size_t i = 0; i < cluster_count; ++i)
320322
{
323+
assert(cluster_index_counts[i] > 0);
324+
321325
cluster_offsets[i] = cluster_nextoffset;
322326
cluster_nextoffset += cluster_index_counts[i];
323327
}
@@ -369,7 +373,7 @@ size_t meshopt_partitionClusters(unsigned int* destination, const unsigned int*
369373
if (groups[top.id].size >= target_partition_size)
370374
continue;
371375

372-
int best_group = pickGroupToMerge(groups, top.id, adjacency, target_partition_size + target_partition_size / 2);
376+
int best_group = pickGroupToMerge(groups, top.id, adjacency, max_partition_size);
373377

374378
// we can't grow the group any more, emit as is
375379
if (best_group == -1)

0 commit comments

Comments
 (0)