From 9306037ed3d14a7afce607738f83c8b9968d478d Mon Sep 17 00:00:00 2001 From: Alexander Gavrilov Date: Mon, 27 Jul 2020 15:03:23 +0300 Subject: Node Groups: expose the SOCK_HIDE_VALUE flag for node group inputs. This flag specifies that even when the socket is not connected, the node should not display the input field for the constant input value. This is useful for inputs like Normal, which have special handling for the missing input case and don't use a constant value. Currently there is no way to change this flag from Python, and through UI it can only be done by re-creating the socket. This patch exposes the flag through RNA and UI, makes sure it is properly updated when changed, and adds special handling to ensure that it is correctly set when creating a node group from a node set that includes reroute nodes. Differential Revision: https://developer.blender.org/D8395 --- source/blender/nodes/intern/node_socket.cc | 48 ++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) (limited to 'source/blender/nodes/intern/node_socket.cc') diff --git a/source/blender/nodes/intern/node_socket.cc b/source/blender/nodes/intern/node_socket.cc index 49868505d68..04d86f5b44e 100644 --- a/source/blender/nodes/intern/node_socket.cc +++ b/source/blender/nodes/intern/node_socket.cc @@ -356,6 +356,54 @@ void node_socket_copy_default_value(bNodeSocket *to, const bNodeSocket *from) to->flag |= (from->flag & SOCK_HIDE_VALUE); } +void node_socket_skip_reroutes( + ListBase *links, bNode *node, bNodeSocket *socket, bNode **r_node, bNodeSocket **r_socket) +{ + const int loop_limit = 100; /* Limit in case there is a connection cycle. */ + + if (socket->in_out == SOCK_IN) { + bNodeLink *first_link = (bNodeLink *)links->first; + + for (int i = 0; node->type == NODE_REROUTE && i < loop_limit; i++) { + bNodeLink *link = first_link; + + for (; link; link = link->next) { + if (link->fromnode == node && link->tonode != node) { + break; + } + } + + if (link) { + node = link->tonode; + socket = link->tosock; + } + else { + break; + } + } + } + else { + for (int i = 0; node->type == NODE_REROUTE && i < loop_limit; i++) { + bNodeSocket *input = (bNodeSocket *)node->inputs.first; + + if (input && input->link) { + node = input->link->fromnode; + socket = input->link->fromsock; + } + else { + break; + } + } + } + + if (r_node) { + *r_node = node; + } + if (r_socket) { + *r_socket = socket; + } +} + static void standard_node_socket_interface_init_socket(bNodeTree *UNUSED(ntree), bNodeSocket *stemp, bNode *UNUSED(node), -- cgit v1.2.3