From 0bc95b7b400963eabb261b006f8c4cbb60a0e1fa Mon Sep 17 00:00:00 2001 From: Philipp Oeser Date: Tue, 23 Aug 2022 14:19:23 +0200 Subject: Compositor: handle NODE_DO_OUTPUT in RNA when setting a node active Main motivation is from T54314 where there was no way to read from a Viewer image datablock after setting another viewer node active. Part of the problem was addressed in rB16d329da284c (where handlers for the compositing background job were added so that you can act after the compositor has run), however there was still the remaining issue that setting another viewer node active would not properly tag the node NODE_DO_OUTPUT. This forced users into a complicated workaround (using switch nodes feeding into a single viewer node). Now handle NODE_DO_OUTPUT properly in RNA, too, and do proper updates so that behavior from RNA matches that of the Node Editor when setting a viewer node active. ref T54314. Reviewed By: JacquesLucke Maniphest Tasks: T54314 Differential Revision: https://developer.blender.org/D15203 --- source/blender/makesrna/intern/rna_nodetree.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'source/blender/makesrna') diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index 9d204d38292..14f439db443 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -1267,6 +1267,20 @@ static void rna_NodeTree_active_node_set(PointerRNA *ptr, if (node && BLI_findindex(&ntree->nodes, node) != -1) { nodeSetActive(ntree, node); + + /* Handle NODE_DO_OUTPUT as well. */ + if (node->typeinfo->nclass == NODE_CLASS_OUTPUT && node->type != CMP_NODE_OUTPUT_FILE) { + /* If this node becomes the active output, the others of the same type can't be the active + * output anymore. */ + LISTBASE_FOREACH (bNode *, other_node, &ntree->nodes) { + if (other_node->type == node->type) { + other_node->flag &= ~NODE_DO_OUTPUT; + } + } + node->flag |= NODE_DO_OUTPUT; + ntreeSetOutput(ntree); + BKE_ntree_update_tag_active_output_changed(ntree); + } } else { nodeClearActive(ntree); @@ -12400,7 +12414,7 @@ static void rna_def_nodetree_nodes_api(BlenderRNA *brna, PropertyRNA *cprop) prop, "rna_NodeTree_active_node_get", "rna_NodeTree_active_node_set", NULL, NULL); RNA_def_property_flag(prop, PROP_EDITABLE | PROP_NEVER_UNLINK); RNA_def_property_ui_text(prop, "Active Node", "Active node in this tree"); - RNA_def_property_update(prop, NC_SCENE | ND_OB_ACTIVE, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_OB_ACTIVE, "rna_NodeTree_update"); } static void rna_def_nodetree_link_api(BlenderRNA *brna, PropertyRNA *cprop) -- cgit v1.2.3