[Bf-blender-cvs] [7aa311e5396] blender-v3.0-release: Cleanup: Add function to get attribute ID from custom data layer

Hans Goudey noreply at git.blender.org
Tue Nov 2 19:44:04 CET 2021


Commit: 7aa311e5396bca5d65ba9cd00060d61bafbf28e9
Author: Hans Goudey
Date:   Tue Nov 2 13:43:54 2021 -0500
Branches: blender-v3.0-release
https://developer.blender.org/rB7aa311e5396bca5d65ba9cd00060d61bafbf28e9

Cleanup: Add function to get attribute ID from custom data layer

===================================================================

M	source/blender/blenkernel/intern/attribute_access.cc

===================================================================

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;
     }



More information about the Bf-blender-cvs mailing list