Page MenuHome
Paste P921

T62209_snippet
ActivePublic

Authored by Philipp Oeser (lichtwerk) on Mar 5 2019, 4:11 PM.
diff --git a/source/blender/makesrna/intern/rna_material.c b/source/blender/makesrna/intern/rna_material.c
index ca0e58a0f5a..6d9d17ba935 100644
--- a/source/blender/makesrna/intern/rna_material.c
+++ b/source/blender/makesrna/intern/rna_material.c
@@ -135,6 +135,20 @@ static void rna_Material_texpaint_begin(CollectionPropertyIterator *iter, Pointe
rna_iterator_array_begin(iter, (void *)ma->texpaintslot, sizeof(TexPaintSlot), ma->tot_slots, 0, NULL);
}
+void set_node_active_recursive(bNodeTree *nodetree, Material *ma, int *index)
+{
+ for (bNode *node = nodetree->nodes.first; node; node = node->next) {
+ if (node->typeinfo->nclass == NODE_CLASS_TEXTURE && node->typeinfo->type == SH_NODE_TEX_IMAGE && node->id) {
+ if ((*index)++ == ma->paint_active_slot) {
+ nodeSetActive(ma->nodetree, node);
+ break;
+ }
+ }
+ else if (node->type == NODE_GROUP) {
+ set_node_active_recursive((bNodeTree *)node->id, ma, index);
+ }
+ }
+}
static void rna_Material_active_paint_texture_index_update(Main *bmain, Scene *scene, PointerRNA *ptr)
{
@@ -142,17 +156,8 @@ static void rna_Material_active_paint_texture_index_update(Main *bmain, Scene *s
Material *ma = ptr->id.data;
if (ma->use_nodes && ma->nodetree) {
- struct bNode *node;
int index = 0;
- for (node = ma->nodetree->nodes.first; node; node = node->next) {
- if (node->typeinfo->nclass == NODE_CLASS_TEXTURE && node->typeinfo->type == SH_NODE_TEX_IMAGE && node->id) {
- if (index++ == ma->paint_active_slot) {
- break;
- }
- }
- }
- if (node)
- nodeSetActive(ma->nodetree, node);
+ set_node_active_recursive(ma->nodetree, ma, &index);
}
if (ma->texpaintslot) {