Nodes: Skip node tree update for unused sockets of muted node #109088

Open
Iliya Katushenock wants to merge 2 commits from mod_moder/blender:tmp_skip_socket_update into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
1 changed files with 19 additions and 1 deletions

View File

@ -2912,7 +2912,25 @@ static void rna_NodeSocket_update(Main *bmain, Scene * /*scene*/, PointerRNA *pt
{
bNodeTree *ntree = reinterpret_cast<bNodeTree *>(ptr->owner_id);
bNodeSocket *sock = static_cast<bNodeSocket *>(ptr->data);
const bool skip_tree_update = [&]() -> bool {
mod_moder marked this conversation as resolved Outdated

Why use [=] instead of [&]?

Why use `[=]` instead of `[&]`?

Just socket/tree pointers, can be captured by value

Just socket/tree pointers, can be captured by value

Yeah, generally prefer [&] if the lambda does not leave the current scope, unless there is a good reason for doing something else.

Yeah, generally prefer `[&]` if the lambda does not leave the current scope, unless there is a good reason for doing something else.
if (!sock->is_input()) {
return false;
}
ntree->ensure_topology_cache();
const bNode &node = sock->owner_node();
if (!node.is_muted()) {
return false;
}
for (const bNodeLink &link : node.internal_links()) {
if (link.fromsock == sock) {
return false;
}
}
return true;
}();
if (skip_tree_update) {
return;
}
BKE_ntree_update_tag_socket_property(ntree, sock);
ED_node_tree_propagate_change(nullptr, bmain, ntree);
}