diff --git a/source/blender/blenkernel/intern/node_runtime.cc b/source/blender/blenkernel/intern/node_runtime.cc index b7c474f07d2..c875dedb50d 100644 --- a/source/blender/blenkernel/intern/node_runtime.cc +++ b/source/blender/blenkernel/intern/node_runtime.cc @@ -136,7 +136,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; }); } } diff --git a/source/blender/blenloader/intern/versioning_400.cc b/source/blender/blenloader/intern/versioning_400.cc index 57abf901ad8..b8bd8a3b0fb 100644 --- a/source/blender/blenloader/intern/versioning_400.cc +++ b/source/blender/blenloader/intern/versioning_400.cc @@ -1685,6 +1685,29 @@ void blo_do_versions_400(FileData *fd, Library * /*lib*/, Main *bmain) } } + if (!MAIN_VERSION_FILE_ATLEAST(bmain, 401, 1)) { + FOREACH_NODETREE_BEGIN (bmain, ntree, id) { + blender::Map total_inputs; + LISTBASE_FOREACH (bNodeLink *, link, &ntree->links) { + const bNodeSocket &socket = *link->tosock; + if (!socket.is_multi_input()) { + continue; + } + total_inputs.add_or_modify( + &socket, [](int *value) { *value = 0; }, [](int *value) { (*value)++; }); + } + LISTBASE_FOREACH (bNodeLink *, link, &ntree->links) { + const bNodeSocket &socket = *link->tosock; + if (!socket.is_multi_input()) { + continue; + } + const int last_input_index = total_inputs.lookup(&socket); + link->multi_input_socket_index = last_input_index - link->multi_input_socket_index; + } + } + FOREACH_NODETREE_END; + } + /** * Versioning code until next subversion bump goes here. * diff --git a/source/blender/editors/space_node/node_edit.cc b/source/blender/editors/space_node/node_edit.cc index 89713fb2b4e..e3846f3c95e 100644 --- a/source/blender/editors/space_node/node_edit.cc +++ b/source/blender/editors/space_node/node_edit.cc @@ -120,7 +120,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) diff --git a/source/blender/editors/space_node/node_relationships.cc b/source/blender/editors/space_node/node_relationships.cc index 51127adf591..c52dbb4bb8f 100644 --- a/source/blender/editors/space_node/node_relationships.cc +++ b/source/blender/editors/space_node/node_relationships.cc @@ -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; } }