Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/blenkernel/intern/attribute_access.cc')
-rw-r--r--source/blender/blenkernel/intern/attribute_access.cc20
1 files changed, 20 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/attribute_access.cc b/source/blender/blenkernel/intern/attribute_access.cc
index aeb66dc5a33..cd394a4ca42 100644
--- a/source/blender/blenkernel/intern/attribute_access.cc
+++ b/source/blender/blenkernel/intern/attribute_access.cc
@@ -835,6 +835,26 @@ bool CustomDataAttributes::foreach_attribute(const AttributeForeachCallback call
return true;
}
+void CustomDataAttributes::reorder(Span<AttributeIDRef> new_order)
+{
+ BLI_assert(new_order.size() == data.totlayer);
+
+ Map<AttributeIDRef, int> old_order;
+ old_order.reserve(data.totlayer);
+ Array<CustomDataLayer> old_layers(Span(data.layers, data.totlayer));
+ for (const int i : old_layers.index_range()) {
+ old_order.add_new(attribute_id_from_custom_data_layer(old_layers[i]), i);
+ }
+
+ MutableSpan layers(data.layers, data.totlayer);
+ for (const int i : layers.index_range()) {
+ const int old_index = old_order.lookup(new_order[i]);
+ layers[i] = old_layers[old_index];
+ }
+
+ CustomData_update_typemap(&data);
+}
+
} // namespace blender::bke
/* -------------------------------------------------------------------- */