[Bf-blender-cvs] [0bc95b7b400] blender-v3.3-release: Compositor: handle NODE_DO_OUTPUT in RNA when setting a node active

Philipp Oeser noreply at git.blender.org
Tue Aug 23 14:24:46 CEST 2022


Commit: 0bc95b7b400963eabb261b006f8c4cbb60a0e1fa
Author: Philipp Oeser
Date:   Tue Aug 23 14:19:23 2022 +0200
Branches: blender-v3.3-release
https://developer.blender.org/rB0bc95b7b400963eabb261b006f8c4cbb60a0e1fa

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

===================================================================

M	source/blender/makesrna/intern/rna_nodetree.c

===================================================================

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)



More information about the Bf-blender-cvs mailing list