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-04-08 20:19:09 +0300
committerHans Goudey <h.goudey@me.com>2021-04-08 20:19:09 +0300
commit1ec9ac201652be6031379e39e98e7dd9dc4a2375 (patch)
tree880f6c342a8bb6f7dd4fdb7f5fbf611790c9fab1 /source/blender/blenkernel/intern/attribute_access.cc
parentfd414b49068c011a1fd63a304ea95bbe420d6570 (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/blenkernel/intern/attribute_access.cc')
-rw-r--r--source/blender/blenkernel/intern/attribute_access.cc14
1 files changed, 10 insertions, 4 deletions
diff --git a/source/blender/blenkernel/intern/attribute_access.cc b/source/blender/blenkernel/intern/attribute_access.cc
index 52f89ca302b..5bd3b990a63 100644
--- a/source/blender/blenkernel/intern/attribute_access.cc
+++ b/source/blender/blenkernel/intern/attribute_access.cc
@@ -822,12 +822,16 @@ Set<std::string> GeometryComponent::attribute_names() const
return attributes;
}
-void GeometryComponent::attribute_foreach(const AttributeForeachCallback callback) const
+/**
+ * \return False if the callback explicitly returned false at any point, otherwise true,
+ * meaning the callback made it all the way through.
+ */
+bool GeometryComponent::attribute_foreach(const AttributeForeachCallback callback) const
{
using namespace blender::bke;
const ComponentAttributeProviders *providers = this->get_attribute_providers();
if (providers == nullptr) {
- return;
+ return true;
}
/* Keep track handled attribute names to make sure that we do not return the same name twice. */
@@ -838,7 +842,7 @@ void GeometryComponent::attribute_foreach(const AttributeForeachCallback callbac
if (provider->exists(*this)) {
AttributeMetaData meta_data{provider->domain(), provider->data_type()};
if (!callback(provider->name(), meta_data)) {
- return;
+ return false;
}
handled_attribute_names.add_new(provider->name());
}
@@ -852,9 +856,11 @@ void GeometryComponent::attribute_foreach(const AttributeForeachCallback callbac
return true;
});
if (!continue_loop) {
- return;
+ return false;
}
}
+
+ return true;
}
bool GeometryComponent::attribute_exists(const blender::StringRef attribute_name) const