From bdc3f1581da3d9cb10ae00daf495c36e0ecbc7ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20T=C3=B6nne?= Date: Thu, 30 Mar 2023 16:56:56 +0200 Subject: [PATCH] Fix #106261: When geometry output is viewed the cycling operator picks wrong sockets. The cycling method for the viewer connection starts searching from the next socket after the last current connection. If a geometry socket is is the last connected output this caused the method to jump to the next socket after the geometry, potentially skipping over valid data sockets that are not viewed yet. The solution is to ignore the geometry sockets in the cycling entirely and only consider data sockets (i.e. non-geometry sockets). Pull Request: https://projects.blender.org/blender/blender/pulls/106318 --- .../blender/editors/space_node/node_relationships.cc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/source/blender/editors/space_node/node_relationships.cc b/source/blender/editors/space_node/node_relationships.cc index c65cc2fd398..7d65292ae90 100644 --- a/source/blender/editors/space_node/node_relationships.cc +++ b/source/blender/editors/space_node/node_relationships.cc @@ -524,7 +524,7 @@ static void remove_links_to_unavailable_viewer_sockets(bNodeTree &btree, bNode & static bNodeSocket *determine_socket_to_view(bNode &node_to_view) { - int last_linked_socket_index = -1; + int last_linked_data_socket_index = -1; bool has_linked_geometry_socket = false; for (bNodeSocket *socket : node_to_view.output_sockets()) { if (!socket_can_be_viewed(*socket)) { @@ -541,12 +541,14 @@ static bNodeSocket *determine_socket_to_view(bNode &node_to_view) if (socket->type == SOCK_GEOMETRY) { has_linked_geometry_socket = true; } - last_linked_socket_index = socket->index(); + else { + last_linked_data_socket_index = socket->index(); + } } } } - if (last_linked_socket_index == -1) { + if (last_linked_data_socket_index == -1 && !has_linked_geometry_socket) { /* Return the first socket that can be viewed. */ for (bNodeSocket *socket : node_to_view.output_sockets()) { if (socket_can_be_viewed(*socket)) { @@ -559,7 +561,7 @@ static bNodeSocket *determine_socket_to_view(bNode &node_to_view) /* Pick the next socket to be linked to the viewer. */ const int tot_outputs = node_to_view.output_sockets().size(); for (const int offset : IndexRange(1, tot_outputs)) { - const int index = (last_linked_socket_index + offset) % tot_outputs; + const int index = (last_linked_data_socket_index + offset) % tot_outputs; bNodeSocket &output_socket = node_to_view.output_socket(index); if (!socket_can_be_viewed(output_socket)) { continue;