Fix #106235: Use first link of multi-input socket for internal link #119280
|
@ -619,9 +619,9 @@ class NodeTreeMainUpdater {
|
|||
struct InternalLink {
|
||||
bNodeSocket *from;
|
||||
bNodeSocket *to;
|
||||
int input_index = 0;
|
||||
int multi_input_socket_index = 0;
|
||||
mod_moder marked this conversation as resolved
Outdated
|
||||
|
||||
BLI_STRUCT_EQUALITY_OPERATORS_3(InternalLink, from, to, input_index);
|
||||
BLI_STRUCT_EQUALITY_OPERATORS_3(InternalLink, from, to, multi_input_socket_index);
|
||||
};
|
||||
|
||||
const bNodeLink *first_non_dangling_link(const bNodeTree &ntree,
|
||||
|
@ -660,12 +660,11 @@ class NodeTreeMainUpdater {
|
|||
continue;
|
||||
}
|
||||
|
||||
mod_moder marked this conversation as resolved
Outdated
Jacques Lucke
commented
These are not "legacy". We will still change the name from These are not "legacy". We will still change the name from `index` to `sort_id` but the values will stay the same.
Iliya Katushenock
commented
Reason why i don't like sort_id in the fact that order of sort_id is not explicit, and somewhere should be noted that order is reversed enumeration. How i should comment (if i should) the fact that i have to inverse index here? Reason why i don't like sort_id in the fact that order of sort_id is not explicit, and somewhere should be noted that order is reversed enumeration. How i should comment (if i should) the fact that i have to inverse index here?
Jacques Lucke
commented
That comment still has to be added to the dna property. I'm also fine with just using the exact same name that's used in dna for now. That comment still has to be added to the dna property. I'm also fine with just using the exact same name that's used in dna for now.
|
||||
/* Multi-input index of link. */
|
||||
const Span<const bNodeLink *> connected_links = input_socket->directly_linked_links();
|
||||
mod_moder marked this conversation as resolved
Outdated
Jacques Lucke
commented
This comment seems to be at the wrong line. This comment seems to be at the wrong line.
Iliya Katushenock
commented
This comment is about all below lines, but i think now this one is just redundant. This comment is about all below lines, but i think now this one is just redundant.
|
||||
const bNodeLink *connected_link = first_non_dangling_link(ntree, connected_links);
|
||||
mod_moder marked this conversation as resolved
Outdated
Jacques Lucke
commented
Use the index stored in the connected link instead of trying to compute it here. Use the index stored in the connected link instead of trying to compute it here.
Iliya Katushenock
commented
That is idea. That is idea.
|
||||
|
||||
const int index = connected_link ? connected_link->multi_input_socket_index :
|
||||
math::max<int>(0, connected_links.size() - 1);
|
||||
std::max<int>(0, connected_links.size() - 1);
|
||||
expected_internal_links.append(InternalLink{const_cast<bNodeSocket *>(input_socket),
|
||||
mod_moder marked this conversation as resolved
Outdated
Jacques Lucke
commented
Can use Can use `std::max` here. I also get a compile error with `math::max`, probably because of a missing include.
|
||||
const_cast<bNodeSocket *>(output_socket),
|
||||
index});
|
||||
|
@ -677,7 +676,7 @@ class NodeTreeMainUpdater {
|
|||
continue;
|
||||
}
|
||||
|
||||
const bool skip = std::all_of(
|
||||
const bool all_expected_internal_links_exist = std::all_of(
|
||||
node->runtime->internal_links.begin(),
|
||||
mod_moder marked this conversation as resolved
Outdated
Jacques Lucke
commented
`skip` -> `all_expected_internal_links_exist`
|
||||
node->runtime->internal_links.end(),
|
||||
[&](const bNodeLink &link) {
|
||||
|
@ -686,7 +685,7 @@ class NodeTreeMainUpdater {
|
|||
return expected_internal_links.as_span().contains(internal_link);
|
||||
});
|
||||
|
||||
if (skip) {
|
||||
if (all_expected_internal_links_exist) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -740,7 +739,7 @@ class NodeTreeMainUpdater {
|
|||
link.fromsock = internal_link.from;
|
||||
link.tonode = &node;
|
||||
link.tosock = internal_link.to;
|
||||
link.multi_input_socket_index = internal_link.input_index;
|
||||
link.multi_input_socket_index = internal_link.multi_input_socket_index;
|
||||
link.flag |= NODE_LINK_VALID;
|
||||
node.runtime->internal_links.append(link);
|
||||
}
|
||||
|
|
Call it
multi_input_socket_index
. It should be renamed at the same time when we renamebNodeLink::multi_input_socket_index
.