Fix #31318: cycles preview missing update for other materials using same node
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Sat, 5 May 2012 19:44:28 +0000 (19:44 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Sat, 5 May 2012 19:44:28 +0000 (19:44 +0000)
group with certain operations.

source/blender/editors/space_node/node_edit.c

index fd4e9bc4ef098ea92b934a7177730264ba23b7db..9e59b3372cb2571a04697ec55ecd6c5018317361 100644 (file)
@@ -243,8 +243,37 @@ static bNode *editnode_get_active(bNodeTree *ntree)
                return nodeGetActive(ntree);
 }
 
-void snode_dag_update(bContext *UNUSED(C), SpaceNode *snode)
+static int has_nodetree(bNodeTree *ntree, bNodeTree *lookup)
 {
+       bNode *node;
+       
+       if (ntree == lookup)
+               return 1;
+       
+       for (node=ntree->nodes.first; node; node=node->next)
+               if (node->type == NODE_GROUP && node->id)
+                       if (has_nodetree((bNodeTree*)node->id, lookup))
+                               return 1;
+       
+       return 0;
+}
+
+static void snode_dag_update_group(void *calldata, ID *owner_id, bNodeTree *ntree)
+{
+       if (has_nodetree(ntree, calldata))
+               DAG_id_tag_update(owner_id, 0);
+}
+
+void snode_dag_update(bContext *C, SpaceNode *snode)
+{
+       Main *bmain = CTX_data_main(C);
+
+       /* for groups, update all ID's using this */
+       if (snode->edittree!=snode->nodetree) {
+               bNodeTreeType *tti= ntreeGetType(snode->edittree->type);
+               tti->foreach_nodetree(bmain, snode->edittree, snode_dag_update_group);
+       }
+
        DAG_id_tag_update(snode->id, 0);
 }
 
@@ -585,21 +614,6 @@ static void snode_update(SpaceNode *snode, bNode *node)
                nodeUpdateID(snode->nodetree, gnode->id);
 }
 
-static int has_nodetree(bNodeTree *ntree, bNodeTree *lookup)
-{
-       bNode *node;
-       
-       if (ntree == lookup)
-               return 1;
-       
-       for (node=ntree->nodes.first; node; node=node->next)
-               if (node->type == NODE_GROUP && node->id)
-                       if (has_nodetree((bNodeTree*)node->id, lookup))
-                               return 1;
-       
-       return 0;
-}
-
 void ED_node_set_active(Main *bmain, bNodeTree *ntree, bNode *node)
 {
        int was_active_texture = (node->flag & NODE_ACTIVE_TEXTURE);