Nodes: support interface items lookup by Identifier

Currently, the `NodeTreeInterface` only allows lookup via the item names, and not
their identifiers. This is problematic when there are multiple items with the
same name, they can only be selected via index and not name / identifier.

The following examples are done on a default Geometry Nodes tree that just has a
`Geometry` input and `Geometry` output.

Pull Request: https://projects.blender.org/blender/blender/pulls/140196
This commit is contained in:
Brady Johnston
2025-07-24 10:25:35 +02:00
committed by Jacques Lucke
parent 6ca5c0fa92
commit 6f2988f0af

View File

@@ -1003,6 +1003,20 @@ static bool rna_NodeTreeInterface_items_lookup_string(PointerRNA *ptr,
}
ntree->ensure_interface_cache();
for (bNodeTreeInterfaceItem *item : ntree->interface_items()) {
switch (NodeTreeInterfaceItemType(item->item_type)) {
case NODE_INTERFACE_SOCKET: {
bNodeTreeInterfaceSocket *socket = reinterpret_cast<bNodeTreeInterfaceSocket *>(item);
if (STREQ(socket->identifier, key)) {
rna_pointer_create_with_ancestors(*ptr, &RNA_NodeTreeInterfaceSocket, socket, *r_ptr);
return true;
}
break;
}
default:
break;
}
}
for (bNodeTreeInterfaceItem *item : ntree->interface_items()) {
switch (NodeTreeInterfaceItemType(item->item_type)) {
case NODE_INTERFACE_SOCKET: {