diff options
author | Jacques Lucke <jacques@blender.org> | 2021-02-23 17:15:23 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2021-02-23 17:15:29 +0300 |
commit | 18be02b8590b0d7d8bbf9e26b1c49264e9fadd99 (patch) | |
tree | df0ee89b42bce516687d4f6560f70aefdf10c502 /source/blender/blenkernel/intern/geometry_set_instances.cc | |
parent | 420f538fadfdd7f9713db9aea44cd7829cbc2ef4 (diff) |
Geometry Nodes: improve accessing attribute meta data
This allows accessing attribute meta data like domain and data type
without having to create a `ReadAttribute`. I kept the `attribute_names`
method for now to keep the patch more self contained.
Differential Revision: https://developer.blender.org/D10511
Diffstat (limited to 'source/blender/blenkernel/intern/geometry_set_instances.cc')
-rw-r--r-- | source/blender/blenkernel/intern/geometry_set_instances.cc | 26 |
1 files changed, 10 insertions, 16 deletions
diff --git a/source/blender/blenkernel/intern/geometry_set_instances.cc b/source/blender/blenkernel/intern/geometry_set_instances.cc index b315ff8a509..1a260c5d48e 100644 --- a/source/blender/blenkernel/intern/geometry_set_instances.cc +++ b/source/blender/blenkernel/intern/geometry_set_instances.cc @@ -178,29 +178,23 @@ void gather_attribute_info(Map<std::string, AttributeKind> &attributes, } const GeometryComponent &component = *set.get_component_for_read(component_type); - for (const std::string &name : component.attribute_names()) { + component.attribute_foreach([&](StringRefNull name, const AttributeMetaData &meta_data) { if (ignored_attributes.contains(name)) { - continue; + return true; } - const ReadAttributePtr read_attribute = component.attribute_try_get_for_read(name); - if (!read_attribute) { - continue; - } - const AttributeDomain domain = read_attribute->domain(); - const CustomDataType data_type = read_attribute->custom_data_type(); - - auto add_info = [&, data_type, domain](AttributeKind *attribute_kind) { - attribute_kind->domain = domain; - attribute_kind->data_type = data_type; + auto add_info = [&](AttributeKind *attribute_kind) { + attribute_kind->domain = meta_data.domain; + attribute_kind->data_type = meta_data.data_type; }; - auto modify_info = [&, data_type, domain](AttributeKind *attribute_kind) { - attribute_kind->domain = domain; /* TODO: Use highest priority domain. */ + auto modify_info = [&](AttributeKind *attribute_kind) { + attribute_kind->domain = meta_data.domain; /* TODO: Use highest priority domain. */ attribute_kind->data_type = bke::attribute_data_type_highest_complexity( - {attribute_kind->data_type, data_type}); + {attribute_kind->data_type, meta_data.data_type}); }; attributes.add_or_modify(name, add_info, modify_info); - } + return true; + }); } } } |