Fix T96292: unable to set active material output using Python

Differential Revision: https://developer.blender.org/D14301
This commit is contained in:
Jacques Lucke 2022-03-10 18:04:07 +01:00 committed by Philipp Oeser
parent af6b88c629
commit 40cbbe809c
Notes: blender-bot 2023-02-13 16:05:00 +01:00
Referenced by issue #96292, Unable to set active material output node using Python
Referenced by issue #96241, 3.1: Potential candidates for corrective releases
1 changed files with 20 additions and 0 deletions

View File

@ -4533,6 +4533,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;
@ -5301,6 +5320,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);