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:
authorHans Goudey <h.goudey@me.com>2021-11-02 21:43:54 +0300
committerHans Goudey <h.goudey@me.com>2021-11-02 21:43:54 +0300
commit7aa311e5396bca5d65ba9cd00060d61bafbf28e9 (patch)
tree4d183dd0dde054224002ba290889fe1c5670d83d
parent48e2a15160d276c8080cd8d4f6dc0ba752dbb410 (diff)
Cleanup: Add function to get attribute ID from custom data layer
-rw-r--r--source/blender/blenkernel/intern/attribute_access.cc24
1 files changed, 10 insertions, 14 deletions
diff --git a/source/blender/blenkernel/intern/attribute_access.cc b/source/blender/blenkernel/intern/attribute_access.cc
index 01b53baf237..aeb66dc5a33 100644
--- a/source/blender/blenkernel/intern/attribute_access.cc
+++ b/source/blender/blenkernel/intern/attribute_access.cc
@@ -234,6 +234,14 @@ OutputAttribute::~OutputAttribute()
}
}
+static AttributeIDRef attribute_id_from_custom_data_layer(const CustomDataLayer &layer)
+{
+ if (layer.anonymous_id != nullptr) {
+ return layer.anonymous_id;
+ }
+ return layer.name;
+}
+
static bool add_builtin_type_custom_data_layer_from_init(CustomData &custom_data,
const CustomDataType data_type,
const int domain_size,
@@ -595,13 +603,7 @@ bool CustomDataAttributeProvider::foreach_attribute(const GeometryComponent &com
const CustomDataType data_type = (CustomDataType)layer.type;
if (this->type_is_supported(data_type)) {
AttributeMetaData meta_data{domain_, data_type};
- AttributeIDRef attribute_id;
- if (layer.anonymous_id != nullptr) {
- attribute_id = layer.anonymous_id;
- }
- else {
- attribute_id = layer.name;
- }
+ const AttributeIDRef attribute_id = attribute_id_from_custom_data_layer(layer);
if (!callback(attribute_id, meta_data)) {
return false;
}
@@ -825,13 +827,7 @@ bool CustomDataAttributes::foreach_attribute(const AttributeForeachCallback call
{
for (const CustomDataLayer &layer : Span(data.layers, data.totlayer)) {
AttributeMetaData meta_data{domain, (CustomDataType)layer.type};
- AttributeIDRef attribute_id;
- if (layer.anonymous_id != nullptr) {
- attribute_id = layer.anonymous_id;
- }
- else {
- attribute_id = layer.name;
- }
+ const AttributeIDRef attribute_id = attribute_id_from_custom_data_layer(layer);
if (!callback(attribute_id, meta_data)) {
return false;
}