Geometry Nodes: store available attribute names in node ui storage
This information will be used by the attribute search in string sockets. Ref T85657. Differential Revision: https://developer.blender.org/D10462
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
#include "BLI_hash.hh"
|
||||
#include "BLI_map.hh"
|
||||
#include "BLI_session_uuid.h"
|
||||
#include "BLI_set.hh"
|
||||
|
||||
#include "DNA_ID.h"
|
||||
#include "DNA_modifier_types.h"
|
||||
@@ -76,6 +77,7 @@ struct NodeWarning {
|
||||
|
||||
struct NodeUIStorage {
|
||||
blender::Vector<NodeWarning> warnings;
|
||||
blender::Set<std::string> attribute_name_hints;
|
||||
};
|
||||
|
||||
struct NodeTreeUIStorage {
|
||||
@@ -94,3 +96,8 @@ void BKE_nodetree_error_message_add(bNodeTree &ntree,
|
||||
const bNode &node,
|
||||
const NodeWarningType type,
|
||||
std::string message);
|
||||
|
||||
void BKE_nodetree_attribute_hint_add(bNodeTree &ntree,
|
||||
const NodeTreeEvaluationContext &context,
|
||||
const bNode &node,
|
||||
const blender::StringRef attribute_name);
|
||||
|
@@ -136,3 +136,12 @@ void BKE_nodetree_error_message_add(bNodeTree &ntree,
|
||||
NodeUIStorage &node_ui_storage = find_node_ui_storage(ntree, context, node);
|
||||
node_ui_storage.warnings.append({type, std::move(message)});
|
||||
}
|
||||
|
||||
void BKE_nodetree_attribute_hint_add(bNodeTree &ntree,
|
||||
const NodeTreeEvaluationContext &context,
|
||||
const bNode &node,
|
||||
const StringRef attribute_name)
|
||||
{
|
||||
NodeUIStorage &node_ui_storage = find_node_ui_storage(ntree, context, node);
|
||||
node_ui_storage.attribute_name_hints.add_as(attribute_name);
|
||||
}
|
||||
|
@@ -82,6 +82,7 @@ using blender::Map;
|
||||
using blender::Set;
|
||||
using blender::Span;
|
||||
using blender::StringRef;
|
||||
using blender::StringRefNull;
|
||||
using blender::Vector;
|
||||
using blender::bke::PersistentCollectionHandle;
|
||||
using blender::bke::PersistentDataHandleMap;
|
||||
@@ -388,6 +389,8 @@ class GeometryNodesEvaluator {
|
||||
{
|
||||
const bNode &bnode = params.node();
|
||||
|
||||
this->store_ui_hints(node, params);
|
||||
|
||||
/* Use the geometry-node-execute callback if it exists. */
|
||||
if (bnode.typeinfo->geometry_node_execute != nullptr) {
|
||||
bnode.typeinfo->geometry_node_execute(params);
|
||||
@@ -405,6 +408,33 @@ class GeometryNodesEvaluator {
|
||||
this->execute_unknown_node(node, params);
|
||||
}
|
||||
|
||||
void store_ui_hints(const DNode &node, GeoNodeExecParams params) const
|
||||
{
|
||||
for (const DInputSocket *dsocket : node.inputs()) {
|
||||
if (!dsocket->is_available()) {
|
||||
continue;
|
||||
}
|
||||
if (dsocket->bsocket()->type != SOCK_GEOMETRY) {
|
||||
continue;
|
||||
}
|
||||
|
||||
bNodeTree *btree_cow = node.node_ref().tree().btree();
|
||||
bNodeTree *btree_original = (bNodeTree *)DEG_get_original_id((ID *)btree_cow);
|
||||
const NodeTreeEvaluationContext context(*self_object_, *modifier_);
|
||||
|
||||
const GeometrySet &geometry_set = params.get_input<GeometrySet>(dsocket->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 &UNUSED(meta_data)) {
|
||||
BKE_nodetree_attribute_hint_add(*btree_original, context, *node.bnode(), attribute_name);
|
||||
return true;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void execute_multi_function_node(const DNode &node,
|
||||
GeoNodeExecParams params,
|
||||
const MultiFunction &fn)
|
||||
|
Reference in New Issue
Block a user