Skip to content

Commit aa1af2a

Browse files
committed
partition: Add templated overload for meshopt_partitionClusters
This is helpful when cluster indices are 16-bit (or have a signed type).
1 parent 1396ffb commit aa1af2a

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/meshoptimizer.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -738,6 +738,8 @@ inline size_t meshopt_buildMeshletsScan(meshopt_Meshlet* meshlets, unsigned int*
738738
template <typename T>
739739
inline meshopt_Bounds meshopt_computeClusterBounds(const T* indices, size_t index_count, const float* vertex_positions, size_t vertex_count, size_t vertex_positions_stride);
740740
template <typename T>
741+
inline size_t meshopt_partitionClusters(unsigned int* destination, const T* cluster_indices, size_t total_index_count, const unsigned int* cluster_index_counts, size_t cluster_count, size_t vertex_count, size_t target_partition_size);
742+
template <typename T>
741743
inline void meshopt_spatialSortTriangles(T* destination, const T* indices, size_t index_count, const float* vertex_positions, size_t vertex_count, size_t vertex_positions_stride);
742744
#endif
743745

@@ -1124,6 +1126,14 @@ inline meshopt_Bounds meshopt_computeClusterBounds(const T* indices, size_t inde
11241126
return meshopt_computeClusterBounds(in.data, index_count, vertex_positions, vertex_count, vertex_positions_stride);
11251127
}
11261128

1129+
template <typename T>
1130+
inline size_t meshopt_partitionClusters(unsigned int* destination, const T* cluster_indices, size_t total_index_count, const unsigned int* cluster_index_counts, size_t cluster_count, size_t vertex_count, size_t target_partition_size)
1131+
{
1132+
meshopt_IndexAdapter<T> in(NULL, cluster_indices, total_index_count);
1133+
1134+
return meshopt_partitionClusters(destination, in.data, total_index_count, cluster_index_counts, cluster_count, vertex_count, target_partition_size);
1135+
}
1136+
11271137
template <typename T>
11281138
inline void meshopt_spatialSortTriangles(T* destination, const T* indices, size_t index_count, const float* vertex_positions, size_t vertex_count, size_t vertex_positions_stride)
11291139
{

0 commit comments

Comments
 (0)