diff options
author | Mattias Fredriksson <Osares> | 2022-09-18 06:12:02 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2022-09-18 06:12:02 +0300 |
commit | ce54f4855674059ef9124a27bff0741f97c75eec (patch) | |
tree | aa81be7e4a224d1e06e687d414007a534a6a87c8 /source/blender/geometry | |
parent | 095516403c48ad1586d732ba2fc8d641827f7572 (diff) |
BLI: Add generic utlity for gathering values with indices
Add new functions to `array_utils` namespace called `gather(..)`.
Versions of `GVArray::materialize_compressed_to_uninitialized(..)` with
threading have been reimplemented locally in multiple geometry node
contexts. The purpose of this patch is therefore to:
* Assemble these implementations in a single file.
* Provide a naming convention that is easier to recognize.
Differential Revision: https://developer.blender.org/D15786
Diffstat (limited to 'source/blender/geometry')
-rw-r--r-- | source/blender/geometry/intern/mesh_to_curve_convert.cc | 16 |
1 files changed, 2 insertions, 14 deletions
diff --git a/source/blender/geometry/intern/mesh_to_curve_convert.cc b/source/blender/geometry/intern/mesh_to_curve_convert.cc index 22961504015..c2a9b16c8b6 100644 --- a/source/blender/geometry/intern/mesh_to_curve_convert.cc +++ b/source/blender/geometry/intern/mesh_to_curve_convert.cc @@ -1,6 +1,7 @@ /* SPDX-License-Identifier: GPL-2.0-or-later */ #include "BLI_array.hh" +#include "BLI_array_utils.hh" #include "BLI_devirtualize_parameters.hh" #include "BLI_set.hh" #include "BLI_task.hh" @@ -18,19 +19,6 @@ namespace blender::geometry { -template<typename T> -static void copy_with_map(const VArray<T> &src, Span<int> map, MutableSpan<T> dst) -{ - devirtualize_varray(src, [&](const auto &src) { - threading::parallel_for(map.index_range(), 1024, [&](const IndexRange range) { - for (const int i : range) { - const int vert_index = map[i]; - dst[i] = src[vert_index]; - } - }); - }); -} - bke::CurvesGeometry create_curve_from_vert_indices(const Mesh &mesh, const Span<int> vert_indices, const Span<int> curve_offsets, @@ -71,7 +59,7 @@ bke::CurvesGeometry create_curve_from_vert_indices(const Mesh &mesh, using T = decltype(dummy); bke::SpanAttributeWriter<T> attribute = curves_attributes.lookup_or_add_for_write_only_span<T>(attribute_id, ATTR_DOMAIN_POINT); - copy_with_map<T>(mesh_attribute.typed<T>(), vert_indices, attribute.span); + array_utils::gather<T>(mesh_attribute.typed<T>(), vert_indices, attribute.span); attribute.finish(); }); } |