diff options
author | Hans Goudey <h.goudey@me.com> | 2021-04-22 16:05:02 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2021-04-22 16:05:02 +0300 |
commit | b9a7b40924f6284af5867cb63078dc79c714a675 (patch) | |
tree | 76a455cc2ab73f930c3176aa0e518452d5f00a22 /source/blender/nodes/intern | |
parent | f6efacfec74e0c20fffc75e05007df01536d8924 (diff) |
Geometry Nodes: Get attribute domain and type without allocation
Because we use virtual classes (and for other reasons), we had to do a
small allocation when simply retrieving the data type and domain of an
existing attribute. This happened quite a lot actually-- to determine
these values for result attributes.
This patch adds a simple function to retrieve this meta data without
building the virtual array. This should lower the overhead of every
attribute node, though the difference probably won't be noticible
unless a tree has very many nodes.
Differential Revision: https://developer.blender.org/D11047
Diffstat (limited to 'source/blender/nodes/intern')
-rw-r--r-- | source/blender/nodes/intern/node_geometry_exec.cc | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/source/blender/nodes/intern/node_geometry_exec.cc b/source/blender/nodes/intern/node_geometry_exec.cc index 2648336f0c0..08fbe1ac1e6 100644 --- a/source/blender/nodes/intern/node_geometry_exec.cc +++ b/source/blender/nodes/intern/node_geometry_exec.cc @@ -126,11 +126,11 @@ CustomDataType GeoNodeExecParams::get_input_attribute_data_type( if (found_socket->type == SOCK_STRING) { const std::string name = this->get_input<std::string>(found_socket->identifier); - ReadAttributeLookup attribute = component.attribute_try_get_for_read(name); - if (!attribute) { - return default_type; + std::optional<AttributeMetaData> info = component.attribute_get_meta_data(name); + if (info) { + return info->data_type; } - return bke::cpp_type_to_custom_data_type(attribute.varray->type()); + return default_type; } if (found_socket->type == SOCK_FLOAT) { return CD_PROP_FLOAT; @@ -169,9 +169,9 @@ AttributeDomain GeoNodeExecParams::get_highest_priority_input_domain( if (found_socket->type == SOCK_STRING) { const std::string name = this->get_input<std::string>(found_socket->identifier); - ReadAttributeLookup attribute = component.attribute_try_get_for_read(name); - if (attribute) { - input_domains.append(attribute.domain); + std::optional<AttributeMetaData> info = component.attribute_get_meta_data(name); + if (info) { + input_domains.append(info->domain); } } } |