Fix #106235: Use consistent order for multi-input socket links #106320

Closed
Iliya Katushenock wants to merge 17 commits from mod_moder:fix_internal_link_drawing into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
5 changed files with 8 additions and 7 deletions
Showing only changes of commit b60c388faf - Show all commits

View File

@ -130,7 +130,7 @@ static void update_directly_linked_links_and_sockets(const bNodeTree &ntree)
std::sort(socket->runtime->directly_linked_links.begin(),
socket->runtime->directly_linked_links.end(),
[&](const bNodeLink *a, const bNodeLink *b) {
return a->multi_input_socket_index > b->multi_input_socket_index;
return a->multi_input_socket_index < b->multi_input_socket_index;
});
}
}

View File

@ -667,9 +667,7 @@ class NodeTreeMainUpdater {
link.tonode = &node;
link.tosock = to_socket;
link.flag |= NODE_LINK_VALID;
const int internal_multi_input_socket_index = from_socket->directly_linked_links().size() -
1;
link.multi_input_socket_index = internal_multi_input_socket_index;
link.multi_input_socket_index = 0;
node.runtime->internal_links.append(link);
}
BKE_ntree_update_tag_node_internal_link(&ntree, &node);

View File

@ -1595,8 +1595,11 @@ static float2 socket_link_connection_location(const bNode &node,
{
const float2 socket_location = socket.runtime->location;
if (socket.is_multi_input() && socket.is_input() && !(node.flag & NODE_HIDDEN)) {
/* If link didn't connected to socket. In this case, at less this link have to be counted in
* the list as single one. */
const int total_inputs = math::max<int>(1, socket.runtime->total_inputs);
return node_link_calculate_multi_input_position(
socket_location, link.multi_input_socket_index, socket.runtime->total_inputs);
socket_location, link.multi_input_socket_index, total_inputs);
}
return socket_location;
}

View File

@ -112,7 +112,7 @@ float2 node_link_calculate_multi_input_position(const float2 &socket_position,
{
const float offset = (total_inputs * NODE_MULTI_INPUT_LINK_GAP - NODE_MULTI_INPUT_LINK_GAP) *
0.5f;
return {socket_position.x, socket_position.y - offset + index * NODE_MULTI_INPUT_LINK_GAP};
return {socket_position.x, socket_position.y + offset - index * NODE_MULTI_INPUT_LINK_GAP};
}
static void compo_tag_output_nodes(bNodeTree *nodetree, int recalc_flags)

View File

@ -309,7 +309,7 @@ static void sort_multi_input_socket_links_with_drag(bNodeSocket &socket,
});
for (const int i : links.index_range()) {
links[i].link->multi_input_socket_index = i;
links[i].link->multi_input_socket_index = links.size() - 1 - i;
}
}