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
This commit is contained in:
@@ -288,18 +288,14 @@ struct LinkAndPosition {
|
|||||||
float2 multi_socket_position;
|
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,
|
bNodeLink &drag_link,
|
||||||
const float2 &cursor)
|
const float2 &cursor)
|
||||||
{
|
{
|
||||||
for (bNodeSocket *socket : node.input_sockets()) {
|
const float2 &socket_location = {socket.runtime->locx, socket.runtime->locy};
|
||||||
if (!socket->is_multi_input()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
const float2 &socket_location = {socket->runtime->locx, socket->runtime->locy};
|
|
||||||
|
|
||||||
Vector<LinkAndPosition, 8> links;
|
Vector<LinkAndPosition, 8> links;
|
||||||
for (bNodeLink *link : socket->directly_linked_links()) {
|
for (bNodeLink *link : socket.directly_linked_links()) {
|
||||||
const float2 location = node_link_calculate_multi_input_position(
|
const float2 location = node_link_calculate_multi_input_position(
|
||||||
socket_location, link->multi_input_socket_index, link->tosock->runtime->total_inputs);
|
socket_location, link->multi_input_socket_index, link->tosock->runtime->total_inputs);
|
||||||
links.append({link, location});
|
links.append({link, location});
|
||||||
@@ -314,7 +310,6 @@ static void sort_multi_input_socket_links_with_drag(bNode &node,
|
|||||||
for (const int i : links.index_range()) {
|
for (const int i : links.index_range()) {
|
||||||
links[i].link->multi_input_socket_index = i;
|
links[i].link->multi_input_socket_index = i;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void update_multi_input_indices_for_removed_links(bNode &node)
|
void update_multi_input_indices_for_removed_links(bNode &node)
|
||||||
@@ -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;
|
existing_link_connected_to_fromsock->multi_input_socket_index;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (link.tosock && link.tosock->flag & SOCK_MULTI_INPUT) {
|
if (tsock && tsock->is_multi_input()) {
|
||||||
sort_multi_input_socket_links_with_drag(tnode, link, cursor);
|
sort_multi_input_socket_links_with_drag(*tsock, link, cursor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user