[Bf-blender-cvs] [22a341d9d8d] master: Fix T96292: unable to set active material output using Python

Jacques Lucke noreply at git.blender.org
Thu Mar 10 18:04:21 CET 2022


Commit: 22a341d9d8d3d337f79df228ab2e4e0726f81430
Author: Jacques Lucke
Date:   Thu Mar 10 18:04:07 2022 +0100
Branches: master
https://developer.blender.org/rB22a341d9d8d3d337f79df228ab2e4e0726f81430

Fix T96292: unable to set active material output using Python

Differential Revision: https://developer.blender.org/D14301

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

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 cc97dca9387..640fe3b919b 100644
--- a/source/blender/makesrna/intern/rna_nodetree.c
+++ b/source/blender/makesrna/intern/rna_nodetree.c
@@ -4520,6 +4520,25 @@ static void rna_CompositorNodeScale_update(Main *bmain, Scene *scene, PointerRNA
   rna_Node_update(bmain, scene, ptr);
 }
 
+static void rna_ShaderNode_is_active_output_set(PointerRNA *ptr, bool value)
+{
+  bNodeTree *ntree = (bNodeTree *)ptr->owner_id;
+  bNode *node = ptr->data;
+  if (value) {
+    /* 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;
+  }
+  else {
+    node->flag &= ~NODE_DO_OUTPUT;
+  }
+}
+
 static PointerRNA rna_ShaderNodePointDensity_psys_get(PointerRNA *ptr)
 {
   bNode *node = ptr->data;
@@ -5288,6 +5307,7 @@ static void def_sh_output(StructRNA *srna)
   RNA_def_property_boolean_sdna(prop, NULL, "flag", NODE_DO_OUTPUT);
   RNA_def_property_ui_text(
       prop, "Active Output", "True if this node is used as the active output");
+  RNA_def_property_boolean_funcs(prop, NULL, "rna_ShaderNode_is_active_output_set");
   RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
 
   prop = RNA_def_property(srna, "target", PROP_ENUM, PROP_NONE);



More information about the Bf-blender-cvs mailing list