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
This commit is contained in:
Philipp Oeser 2022-08-23 14:19:23 +02:00 committed by Philipp Oeser
parent 1663530408
commit 0bc95b7b40
Notes: blender-bot 2023-02-14 06:37:09 +01:00
Referenced by issue #54314, Contents of "Viewer Node" image block do not get updated
Referenced by issue #54314, Contents of "Viewer Node" image block do not get updated
1 changed files with 15 additions and 1 deletions

View File

@ -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)