From d76a0e98baecfca4e691fd29bcf027d8cc1e07bf Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Tue, 17 Jan 2023 12:16:38 -0600 Subject: [PATCH] Fix: Avoid node reevaluations for selection and parenting Since 90ea1b76434fe175e9, node trees have been reevaluated after many selection operations because nodes are sorted based on the selection status and an update tag was added for that. However, for years the node order was allowed to be different between the original and evaluated copy of node trees. Though it is a bit sketchy to have that difference in the evaluated node tree, reevaluations for just selection are very bad, so use a "smaller" update tag and add a comment for justification. Differential Revision: https://developer.blender.org/D17023 --- source/blender/blenkernel/intern/node_tree_update.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/source/blender/blenkernel/intern/node_tree_update.cc b/source/blender/blenkernel/intern/node_tree_update.cc index 2943bea830b..374d67bbfa8 100644 --- a/source/blender/blenkernel/intern/node_tree_update.cc +++ b/source/blender/blenkernel/intern/node_tree_update.cc @@ -1131,7 +1131,11 @@ void BKE_ntree_update_tag_node_removed(bNodeTree *ntree) void BKE_ntree_update_tag_node_reordered(bNodeTree *ntree) { - add_tree_tag(ntree, NTREE_CHANGED_ANY); + /* Don't add a tree update tag to avoid reevaluations for trivial operations like selection or + * parenting that typically influence the node order. This means the node order can be different + * for original and evaluated trees. A different solution might avoid sorting nodes based on UI + * states like selection, which would require not tying the node order to the drawing order. */ + ntree->runtime->topology_cache_mutex.tag_dirty(); } void BKE_ntree_update_tag_node_mute(bNodeTree *ntree, bNode *node)