[Bf-blender-cvs] [433d436b84e] master: Fix: sort link indices in multi input sockets incorrect
Iliya Katueshenock
noreply at git.blender.org
Wed Jan 4 22:39:08 CET 2023
Commit: 433d436b84eacf43e7b9f2bc0c2e49fc29472ce6
Author: Iliya Katueshenock
Date: Wed Jan 4 16:37:32 2023 -0500
Branches: master
https://developer.blender.org/rB433d436b84eacf43e7b9f2bc0c2e49fc29472ce6
Fix: sort link indices in multi input sockets incorrect
For some reason I don't understand, the dragged link is sorted across
all the node's multi-input sockets. This leads to problems when there
are multiple sockets to sort. With this patch, I'm making the feature
work more directional.
Differential Revision: https://developer.blender.org/D16892
===================================================================
M source/blender/editors/space_node/node_relationships.cc
===================================================================
diff --git a/source/blender/editors/space_node/node_relationships.cc b/source/blender/editors/space_node/node_relationships.cc
index 1ccebd18893..d7e73761667 100644
--- a/source/blender/editors/space_node/node_relationships.cc
+++ b/source/blender/editors/space_node/node_relationships.cc
@@ -288,32 +288,27 @@ struct LinkAndPosition {
float2 multi_socket_position;
};
-static void sort_multi_input_socket_links_with_drag(bNode &node,
+static void sort_multi_input_socket_links_with_drag(bNodeSocket &socket,
bNodeLink &drag_link,
const float2 &cursor)
{
- for (bNodeSocket *socket : node.input_sockets()) {
- if (!socket->is_multi_input()) {
- continue;
- }
- const float2 &socket_location = {socket->runtime->locx, socket->runtime->locy};
+ const float2 &socket_location = {socket.runtime->locx, socket.runtime->locy};
- Vector<LinkAndPosition, 8> links;
- for (bNodeLink *link : socket->directly_linked_links()) {
- const float2 location = node_link_calculate_multi_input_position(
- socket_location, link->multi_input_socket_index, link->tosock->runtime->total_inputs);
- links.append({link, location});
- };
+ Vector<LinkAndPosition, 8> links;
+ for (bNodeLink *link : socket.directly_linked_links()) {
+ const float2 location = node_link_calculate_multi_input_position(
+ socket_location, link->multi_input_socket_index, link->tosock->runtime->total_inputs);
+ links.append({link, location});
+ };
- links.append({&drag_link, cursor});
+ links.append({&drag_link, cursor});
- std::sort(links.begin(), links.end(), [](const LinkAndPosition a, const LinkAndPosition b) {
- return a.multi_socket_position.y < b.multi_socket_position.y;
- });
+ std::sort(links.begin(), links.end(), [](const LinkAndPosition a, const LinkAndPosition b) {
+ return a.multi_socket_position.y < b.multi_socket_position.y;
+ });
- for (const int i : links.index_range()) {
- links[i].link->multi_input_socket_index = i;
- }
+ for (const int i : links.index_range()) {
+ links[i].link->multi_input_socket_index = i;
}
}
@@ -972,8 +967,8 @@ static void node_link_find_socket(bContext &C, wmOperator &op, const float2 &cur
existing_link_connected_to_fromsock->multi_input_socket_index;
continue;
}
- if (link.tosock && link.tosock->flag & SOCK_MULTI_INPUT) {
- sort_multi_input_socket_links_with_drag(tnode, link, cursor);
+ if (tsock && tsock->is_multi_input()) {
+ sort_multi_input_socket_links_with_drag(*tsock, link, cursor);
}
}
}
More information about the Bf-blender-cvs
mailing list