Fixed some redraw problems with texture nodes.
authorRobin Allen <roblovski@gmail.com>
Tue, 18 Aug 2009 14:31:13 +0000 (14:31 +0000)
committerRobin Allen <roblovski@gmail.com>
Tue, 18 Aug 2009 14:31:13 +0000 (14:31 +0000)
source/blender/blenkernel/intern/node.c
source/blender/editors/space_node/node_draw.c
source/blender/editors/space_node/node_edit.c
source/blender/editors/space_node/space_node.c
source/blender/nodes/intern/TEX_nodes/TEX_output.c
source/blender/nodes/intern/TEX_util.c

index 836f4281eb9822e4932f5c9cd026489921fcebe8..bd6919dc1150777e98cc4fcd15f5a3c7b9c09c46 100644 (file)
@@ -950,9 +950,6 @@ bNode *nodeAddNodeType(bNodeTree *ntree, int type, bNodeTree *ngroup, ID *id)
        if(ntype->initfunc!=NULL)
                ntype->initfunc(node);
        
-       if(type==TEX_NODE_OUTPUT)
-               ntreeTexAssignIndex(ntree, node);
-
        nodeAddSockets(node, ntype);
        
        return node;
@@ -1021,9 +1018,6 @@ bNode *nodeCopyNode(struct bNodeTree *ntree, struct bNode *node, int internal)
        nnode->new_node= NULL;
        nnode->preview= NULL;
        
-       if(node->type==TEX_NODE_OUTPUT)
-               ntreeTexAssignIndex(ntree, node);
-
        return nnode;
 }
 
index 70e2167c1e4be9a129becaf929cfc772642ea711..f3df7a29c2e059663534212cf0007d22cf6160c1 100644 (file)
@@ -607,9 +607,9 @@ static void do_node_internal_buttons(bContext *C, void *node_v, int event)
                        }
                        WM_event_add_notifier(C, NC_SCENE|ND_NODES, CTX_data_scene(C));
                }                       
-               
-       //      else if(snode->treetype==NTREE_TEXTURE)
-       //              texture_node_event(snode, val);
+               else if(snode->treetype==NTREE_TEXTURE) {
+                       WM_event_add_notifier(C, NC_TEXTURE|ND_NODES, snode->id);
+               }
        }
        
 }
index d66cbb55baa4ce9a457ccbc50820ab43ed407904..20abcdf9f974a7e5c9aec4650dd0487cdb354837 100644 (file)
@@ -213,10 +213,8 @@ void snode_handle_recalc(bContext *C, SpaceNode *snode)
                WM_event_add_notifier(C, NC_MATERIAL|ND_NODES, snode->id);
        else if(snode->treetype==NTREE_COMPOSIT)
                WM_event_add_notifier(C, NC_SCENE|ND_NODES, snode->id);
-       else if(snode->treetype==NTREE_TEXTURE) {
-               // ntreeTexUpdatePreviews(snode->nodetree); /* XXX texture nodes should follow shader node methods (ton) */
-               // XXX BIF_preview_changed(ID_TE);
-       }
+       else if(snode->treetype==NTREE_TEXTURE)
+               WM_event_add_notifier(C, NC_TEXTURE|ND_NODES, snode->id);
 }
 
 #if 0
index 25e1b368ccb65d0f1026cb02b915dbec137c2361..5db9d7331b80885bee752b92f054d2706dde2587 100644 (file)
@@ -152,12 +152,16 @@ static void node_area_listener(ScrArea *sa, wmNotifier *wmn)
                        if(wmn->data==ND_FILEREAD)
                                ED_area_tag_refresh(sa);
                        break;
-                               
+                       
+               /* future: add ID checks? */
                case NC_MATERIAL:
-                       /* future: add ID check? */
                        if(wmn->data==ND_SHADING)
                                ED_area_tag_refresh(sa);
                        break;
+               case NC_TEXTURE:
+                       if(wmn->data==ND_NODES)
+                               ED_area_tag_refresh(sa);
+                       break;
        }
 }
 
@@ -280,6 +284,9 @@ static void node_region_listener(ARegion *ar, wmNotifier *wmn)
                case NC_MATERIAL:
                        ED_region_tag_redraw(ar);
                        break;
+               case NC_TEXTURE:
+                       ED_region_tag_redraw(ar);
+                       break;
        }
 }
 
index 96ee5d74f66952881b927f8761c951b28dd2286f..7ce5ec88c48850ac0752d9c25199138743e316f7 100644 (file)
@@ -152,6 +152,26 @@ static void unique_name(bNode *node)
        }
 }
 
+static void assign_index(struct bNode *node)
+{
+       bNode *tnode;
+       int index = 1;
+       
+       tnode = node;
+       while(tnode->prev)
+               tnode = tnode->prev;
+       
+       check_index:
+       for(; tnode; tnode= tnode->next)
+               if(tnode->type == TEX_NODE_OUTPUT && tnode != node)
+                       if(tnode->custom1 == index) {
+                               index ++;
+                               goto check_index;
+                       }
+                       
+       node->custom1 = index;
+}
+
 static void init(bNode *node)
 {
        TexNodeOutput *tno = MEM_callocN(sizeof(TexNodeOutput), "TEX_output");
@@ -159,17 +179,16 @@ static void init(bNode *node)
        
        strcpy(tno->name, "Default");
        unique_name(node);
-       ntreeTexAssignIndex(0, node);
+       assign_index(node);
 }
 
 static void copy(bNode *orig, bNode *new)
 {
        node_copy_standard_storage(orig, new);
        unique_name(new);
-       ntreeTexAssignIndex(0, new);
+       assign_index(new);
 }
 
-
 bNodeType tex_node_output= {
        /* *next,*prev     */  NULL, NULL,
        /* type code       */  TEX_NODE_OUTPUT,
index 36182d2498dff74d3096cb0d45d1fe9ca4d336a7..0bb9d887ae3399d6470cd11401bcca86682390b1 100644 (file)
@@ -297,26 +297,3 @@ char* ntreeTexOutputMenu(bNodeTree *ntree)
        return str;
 }
 
-void ntreeTexAssignIndex(struct bNodeTree *ntree, struct bNode *node)
-{
-       bNode *tnode;
-       int index = 1;
-       
-       if(ntree) 
-               tnode = ntree->nodes.first;
-       else {
-               tnode = node;
-               while(tnode->prev) tnode = tnode->prev;
-       }
-       
-       check_index:
-       for(; tnode; tnode= tnode->next)
-               if(tnode->type == TEX_NODE_OUTPUT && tnode != node)
-                       if(tnode->custom1 == index) {
-                               index ++;
-                               goto check_index;
-                       }
-                       
-       node->custom1 = index;
-}
-