Fix: socket hidden in the link drag operator for group input nodes

Two issues fixed here:
1. Mixup of "in" and "out" flags.
2. Missing node tree update tag to ensure group input nodes all have
   the new socket so it can be hidden.

Pull Request: https://projects.blender.org/blender/blender/pulls/111707
This commit is contained in:
Lukas Tönne
2023-08-31 14:42:06 +02:00
parent af54b16778
commit fde35b65d1

View File

@@ -87,16 +87,14 @@ static void add_reroute_node_fn(nodes::LinkSearchOpParams &params)
static void add_group_input_node_fn(nodes::LinkSearchOpParams &params)
{
/* Add a group input based on the connected socket, and add a new group input node. */
const eNodeSocketInOut in_out = eNodeSocketInOut(params.socket.in_out);
NodeTreeInterfaceSocketFlag flag = NodeTreeInterfaceSocketFlag(0);
SET_FLAG_FROM_TEST(flag, in_out & SOCK_IN, NODE_INTERFACE_SOCKET_INPUT);
SET_FLAG_FROM_TEST(flag, in_out & SOCK_OUT, NODE_INTERFACE_SOCKET_OUTPUT);
bNodeTreeInterfaceSocket *socket_iface = params.node_tree.tree_interface.add_socket(
params.socket.name,
params.socket.description,
params.socket.typeinfo->idname,
flag,
NODE_INTERFACE_SOCKET_INPUT,
nullptr);
BKE_ntree_update_tag_interface(&params.node_tree);
bNode &group_input = params.add_node("NodeGroupInput");
/* This is necessary to create the new sockets in the other input nodes. */
@@ -105,7 +103,8 @@ static void add_group_input_node_fn(nodes::LinkSearchOpParams &params)
/* Hide the new input in all other group input nodes, to avoid making them taller. */
for (bNode *node : params.node_tree.all_nodes()) {
if (node->type == NODE_GROUP_INPUT) {
bNodeSocket *new_group_input_socket = nodeFindSocket(node, in_out, socket_iface->identifier);
bNodeSocket *new_group_input_socket = nodeFindSocket(
node, SOCK_OUT, socket_iface->identifier);
if (new_group_input_socket) {
new_group_input_socket->flag |= SOCK_HIDDEN;
}
@@ -117,7 +116,7 @@ static void add_group_input_node_fn(nodes::LinkSearchOpParams &params)
socket->flag |= SOCK_HIDDEN;
}
bNodeSocket *socket = nodeFindSocket(&group_input, in_out, socket_iface->identifier);
bNodeSocket *socket = nodeFindSocket(&group_input, SOCK_OUT, socket_iface->identifier);
if (socket) {
/* Unhide the socket for the new input in the new node and make a connection to it. */
socket->flag &= ~SOCK_HIDDEN;