[Bf-blender-cvs] [626be25646d] temp-geometry-nodes-fields-prototype: support attribute search in Attribute node
Jacques Lucke
noreply at git.blender.org
Wed Jul 28 15:41:28 CEST 2021
Commit: 626be25646de25c00520db8ee7102c44402e399c
Author: Jacques Lucke
Date: Wed Jul 28 15:41:00 2021 +0200
Branches: temp-geometry-nodes-fields-prototype
https://developer.blender.org/rB626be25646de25c00520db8ee7102c44402e399c
support attribute search in Attribute node
===================================================================
M source/blender/editors/space_node/node_geometry_attribute_search.cc
M source/blender/nodes/NOD_geometry_nodes_eval_log.hh
M source/blender/nodes/intern/geometry_nodes_eval_log.cc
===================================================================
diff --git a/source/blender/editors/space_node/node_geometry_attribute_search.cc b/source/blender/editors/space_node/node_geometry_attribute_search.cc
index a6901c21862..be6c7a05981 100644
--- a/source/blender/editors/space_node/node_geometry_attribute_search.cc
+++ b/source/blender/editors/space_node/node_geometry_attribute_search.cc
@@ -99,12 +99,23 @@ static void attribute_search_update_fn(
AttributeSearchData *data = static_cast<AttributeSearchData *>(arg);
SpaceNode *snode = CTX_wm_space_node(C);
- const geo_log::NodeLog *node_log = geo_log::ModifierLog::find_node_by_node_editor_context(
- *snode, *data->node);
- if (node_log == nullptr) {
- return;
+ blender::Vector<const GeometryAttributeInfo *> infos;
+ if (data->node->type == GEO_NODE_ATTRIBUTE) {
+ const geo_log::ModifierLog *modifier_log =
+ geo_log::ModifierLog::find_root_by_node_editor_context(*snode);
+ if (modifier_log == nullptr) {
+ return;
+ }
+ infos = modifier_log->lookup_available_attributes();
+ }
+ else {
+ const geo_log::NodeLog *node_log = geo_log::ModifierLog::find_node_by_node_editor_context(
+ *snode, *data->node);
+ if (node_log == nullptr) {
+ return;
+ }
+ infos = node_log->lookup_available_attributes();
}
- blender::Vector<const GeometryAttributeInfo *> infos = node_log->lookup_available_attributes();
GeometryAttributeInfo &dummy_info = get_dummy_item_info();
diff --git a/source/blender/nodes/NOD_geometry_nodes_eval_log.hh b/source/blender/nodes/NOD_geometry_nodes_eval_log.hh
index 00d97b24646..27f67d7d403 100644
--- a/source/blender/nodes/NOD_geometry_nodes_eval_log.hh
+++ b/source/blender/nodes/NOD_geometry_nodes_eval_log.hh
@@ -299,6 +299,7 @@ class ModifierLog {
static const NodeLog *find_node_by_spreadsheet_editor_context(
const SpaceSpreadsheet &sspreadsheet);
void foreach_node_log(FunctionRef<void(const NodeLog &)> fn) const;
+ Vector<const GeometryAttributeInfo *> lookup_available_attributes() const;
private:
using LogByTreeContext = Map<const DTreeContext *, TreeLog *>;
diff --git a/source/blender/nodes/intern/geometry_nodes_eval_log.cc b/source/blender/nodes/intern/geometry_nodes_eval_log.cc
index 7487f11d77d..e8d4d059494 100644
--- a/source/blender/nodes/intern/geometry_nodes_eval_log.cc
+++ b/source/blender/nodes/intern/geometry_nodes_eval_log.cc
@@ -106,6 +106,26 @@ void ModifierLog::foreach_node_log(FunctionRef<void(const NodeLog &)> fn) const
}
}
+Vector<const GeometryAttributeInfo *> ModifierLog::lookup_available_attributes() const
+{
+ Vector<const GeometryAttributeInfo *> attributes;
+ Set<StringRef> names;
+ this->foreach_node_log([&](const NodeLog &node_log) {
+ for (const SocketLog &socket_log : node_log.input_logs()) {
+ const ValueLog *value_log = socket_log.value();
+ if (const GeometryValueLog *geo_value_log = dynamic_cast<const GeometryValueLog *>(
+ value_log)) {
+ for (const GeometryAttributeInfo &attribute : geo_value_log->attributes()) {
+ if (names.add(attribute.name)) {
+ attributes.append(&attribute);
+ }
+ }
+ }
+ }
+ });
+ return attributes;
+}
+
const NodeLog *TreeLog::lookup_node_log(StringRef node_name) const
{
const destruct_ptr<NodeLog> *node_log = node_logs_.lookup_ptr_as(node_name);
More information about the Bf-blender-cvs
mailing list