diff options
author | Hans Goudey <h.goudey@me.com> | 2021-04-08 20:19:09 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2021-04-08 20:19:09 +0300 |
commit | 1ec9ac201652be6031379e39e98e7dd9dc4a2375 (patch) | |
tree | 880f6c342a8bb6f7dd4fdb7f5fbf611790c9fab1 /source/blender/modifiers/intern/MOD_nodes.cc | |
parent | fd414b49068c011a1fd63a304ea95bbe420d6570 (diff) |
Geometry Nodes: Support instances in attribute search
Previously only attributes of "real" geometry were displayed in
attribute search. This commit adds code to look through attributes
on instances and add those to the search drop-down too.
This required implementing the same sort of recursive traversal as
the realize instances code. The situation is a bit different though,
this can return early and doesn't need to keep track of transforms.
I added a limit so that it doesn't look through the attributes of
too many instanced geometry sets. I think this is important, since
this isn't a trivial operation and it could potentially happen for
every node in a large node tree. Currently the limit is set at 8
geometry sets, which I expect will be enough, since the set of
attributes is mostly not very unique anyway.
Fixes T86282
Diffrential Revision: https://developer.blender.org/D10919
Diffstat (limited to 'source/blender/modifiers/intern/MOD_nodes.cc')
-rw-r--r-- | source/blender/modifiers/intern/MOD_nodes.cc | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/source/blender/modifiers/intern/MOD_nodes.cc b/source/blender/modifiers/intern/MOD_nodes.cc index c7d822e5418..7a2f8640202 100644 --- a/source/blender/modifiers/intern/MOD_nodes.cc +++ b/source/blender/modifiers/intern/MOD_nodes.cc @@ -47,6 +47,7 @@ #include "DNA_windowmanager_types.h" #include "BKE_customdata.h" +#include "BKE_geometry_set_instances.hh" #include "BKE_global.h" #include "BKE_idprop.h" #include "BKE_lib_query.h" @@ -489,20 +490,19 @@ class GeometryNodesEvaluator { const NodeTreeEvaluationContext context(*self_object_, *modifier_); const GeometrySet &geometry_set = params.get_input<GeometrySet>(socket_ref->identifier()); - const Vector<const GeometryComponent *> components = geometry_set.get_components_for_read(); - - for (const GeometryComponent *component : components) { - component->attribute_foreach( - [&](StringRefNull attribute_name, const AttributeMetaData &meta_data) { - BKE_nodetree_attribute_hint_add(*btree_original, - context, - *node->bnode(), - attribute_name, - meta_data.domain, - meta_data.data_type); - return true; - }); - } + + blender::bke::geometry_set_instances_attribute_foreach( + geometry_set, + [&](StringRefNull attribute_name, const AttributeMetaData &meta_data) { + BKE_nodetree_attribute_hint_add(*btree_original, + context, + *node->bnode(), + attribute_name, + meta_data.domain, + meta_data.data_type); + return true; + }, + 8); } } |