Files
test2/source/blender/blenlib/intern/offset_indices.cc
Hans Goudey 4b2ea18ec9 Cleanup: Deduplicate OffsetIndices utility for meshes and curves
The "reverse map" of corners to faces and points to curves is the same
for meshes and curves now. Move it to the offset indices header to
reflect this.

This unification can go further in the future, but I'd rather wait
until the design is clearer for now.

Pull Request: https://projects.blender.org/blender/blender/pulls/106570
2023-04-04 22:12:17 +02:00

30 lines
801 B
C++

/* SPDX-License-Identifier: GPL-2.0-or-later */
#include "BLI_offset_indices.hh"
#include "BLI_task.hh"
namespace blender::offset_indices {
void accumulate_counts_to_offsets(MutableSpan<int> counts_to_offsets, const int start_offset)
{
int offset = start_offset;
for (const int i : counts_to_offsets.index_range().drop_back(1)) {
const int count = counts_to_offsets[i];
BLI_assert(count >= 0);
counts_to_offsets[i] = offset;
offset += count;
}
counts_to_offsets.last() = offset;
}
void build_reverse_map(OffsetIndices<int> offsets, MutableSpan<int> r_map)
{
threading::parallel_for(offsets.index_range(), 1024, [&](const IndexRange range) {
for (const int64_t i : range) {
r_map.slice(offsets[i]).fill(i);
}
});
}
} // namespace blender::offset_indices