Revision: 36515
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=36515
Author:   lukastoenne
Date:     2011-05-06 13:04:47 +0000 (Fri, 06 May 2011)
Log Message:
-----------
Fixed a couple of issues pointed out by Brecht via bf-codereview.

Modified Paths:
--------------
    branches/particles-2010/source/blender/blenkernel/intern/node.c
    branches/particles-2010/source/blender/editors/space_api/spacetypes.c
    branches/particles-2010/source/blender/editors/space_node/drawnode.c
    branches/particles-2010/source/blender/editors/space_node/node_edit.c
    branches/particles-2010/source/blender/makesdna/DNA_node_types.h
    branches/particles-2010/source/blender/nodes/intern/CMP_nodes/CMP_common.c
    branches/particles-2010/source/blender/nodes/intern/node_common.c

Modified: branches/particles-2010/source/blender/blenkernel/intern/node.c
===================================================================
--- branches/particles-2010/source/blender/blenkernel/intern/node.c     
2011-05-06 11:27:04 UTC (rev 36514)
+++ branches/particles-2010/source/blender/blenkernel/intern/node.c     
2011-05-06 13:04:47 UTC (rev 36515)
@@ -464,8 +464,6 @@
                sockdef= ntype->inputs;
                while(sockdef->type != -1) {
                        sock = node_add_input_from_template(ntree, node, 
sockdef);
-                       /* tag socket as static */
-                       sock->flag |= SOCK_STATIC;
                        
                        sockdef++;
                }
@@ -474,8 +472,6 @@
                sockdef= ntype->outputs;
                while(sockdef->type != -1) {
                        sock = node_add_output_from_template(ntree, node, 
sockdef);
-                       /* tag socket as static */
-                       sock->flag |= SOCK_STATIC;
                        
                        sockdef++;
                }

Modified: branches/particles-2010/source/blender/editors/space_api/spacetypes.c
===================================================================
--- branches/particles-2010/source/blender/editors/space_api/spacetypes.c       
2011-05-06 11:27:04 UTC (rev 36514)
+++ branches/particles-2010/source/blender/editors/space_api/spacetypes.c       
2011-05-06 13:04:47 UTC (rev 36515)
@@ -63,7 +63,6 @@
 #include "ED_uvedit.h"
 #include "ED_mball.h"
 #include "ED_logic.h"
-#include "ED_particleset.h"
 
 /* only call once on startup, storage is global in BKE kernel listbase */
 void ED_spacetypes_init(void)

Modified: branches/particles-2010/source/blender/editors/space_node/drawnode.c
===================================================================
--- branches/particles-2010/source/blender/editors/space_node/drawnode.c        
2011-05-06 11:27:04 UTC (rev 36514)
+++ branches/particles-2010/source/blender/editors/space_node/drawnode.c        
2011-05-06 13:04:47 UTC (rev 36515)
@@ -638,11 +638,7 @@
        bNodeTree *ngroup= (bNodeTree*)gnode->id;
        uiBut *bt;
        
-       if (sock->flag & SOCK_STATIC)
-               uiDefBut(gnode->block, LABEL, 0, sock->name, 
-                                sock->locx+xoffset, sock->locy+1+yoffset, 72, 
NODE_DY,
-                                NULL, 0, 31, 0, 0, "");
-       else {
+       if (sock->flag & SOCK_DYNAMIC) {
                bt = uiDefBut(gnode->block, TEX, 0, "", 
                                          sock->locx+xoffset, 
sock->locy+1+yoffset, 72, NODE_DY,
                                          sock->name, 0, 31, 0, 0, "");
@@ -651,6 +647,11 @@
                else
                        uiButSetFunc(bt, update_group_output_cb, snode, ngroup);
        }
+       else {
+               uiDefBut(gnode->block, LABEL, 0, sock->name, 
+                                sock->locx+xoffset, sock->locy+1+yoffset, 72, 
NODE_DY,
+                                NULL, 0, 31, 0, 0, "");
+       }
 }
 
 static void draw_group_socket(const bContext *C, SpaceNode *snode, bNodeTree 
*ntree, bNode *gnode, bNodeSocket *sock, bNodeSocket *gsock, int index, int 
in_out)
@@ -708,20 +709,20 @@
                        draw_group_socket_name(snode, gnode, sock, in_out, 
offset, -NODE_DYS);
        }
        
-       if (gsock && !(gsock->flag & SOCK_STATIC)) {
+       if (gsock && (gsock->flag & SOCK_DYNAMIC)) {
                /* up/down buttons */
                offset = (in_out==SOCK_IN ? -40 : 24);
                uiBlockSetDirection(gnode->block, UI_TOP);
                uiBlockBeginAlign(gnode->block);
                bt = uiDefIconButO(gnode->block, BUT, 
"NODE_OT_group_socket_move_up", 0, ICON_TRIA_UP,
                                                   gsock->locx+offset, 
gsock->locy, 16, 16, "");
-               if (!gsock->prev || (gsock->prev->flag & SOCK_STATIC))
+               if (!gsock->prev || !(gsock->prev->flag & SOCK_DYNAMIC))
                        uiButSetFlag(bt, UI_BUT_DISABLED);
                RNA_int_set(uiButGetOperatorPtrRNA(bt), "index", index);
                RNA_enum_set(uiButGetOperatorPtrRNA(bt), "in_out", in_out);
                bt = uiDefIconButO(gnode->block, BUT, 
"NODE_OT_group_socket_move_down", 0, ICON_TRIA_DOWN,
                                                   gsock->locx+offset, 
gsock->locy-16, 16, 16, "");
-               if (!gsock->next || (gsock->next->flag & SOCK_STATIC))
+               if (!gsock->next || !(gsock->next->flag & SOCK_DYNAMIC))
                        uiButSetFlag(bt, UI_BUT_DISABLED);
                RNA_int_set(uiButGetOperatorPtrRNA(bt), "index", index);
                RNA_enum_set(uiButGetOperatorPtrRNA(bt), "in_out", in_out);

Modified: branches/particles-2010/source/blender/editors/space_node/node_edit.c
===================================================================
--- branches/particles-2010/source/blender/editors/space_node/node_edit.c       
2011-05-06 11:27:04 UTC (rev 36514)
+++ branches/particles-2010/source/blender/editors/space_node/node_edit.c       
2011-05-06 13:04:47 UTC (rev 36515)
@@ -2102,6 +2102,8 @@
                                nodeRemSocketLinks(snode->edittree, sock_to);
                        
                        link = nodeAddLink(snode->edittree, node_fr, sock_fr, 
node_to, sock_to);
+                       /* validate the new link */
+                       ntreeUpdateTree(snode->edittree);
                        if (!(link->flag & NLINK_VALID)) {
                                nodeRemLink(snode->edittree, link);
                                continue;
@@ -3112,24 +3114,24 @@
        if (snode->nodetree->type==NTREE_COMPOSIT)
                ntemp.type = CMP_NODE_IMAGE;
 
-       if (ntemp.type >= 0) {
-               ED_preview_kill_jobs(C);
+       if (ntemp.type < 0)
+               return OPERATOR_CANCELLED;
                
-               node = node_add_node(snode, scene, &ntemp, snode->mx, 
snode->my);
-               
-               if (!node) {
-                       BKE_report(op->reports, RPT_WARNING, "Could not add an 
image node.");
-                       return OPERATOR_CANCELLED;
-               }
-               
-               node->id = (ID *)ima;
-               
-               snode_notify(C, snode);
-               snode_dag_update(C, snode);
-               return OPERATOR_FINISHED;
+       ED_preview_kill_jobs(C);
+       
+       node = node_add_node(snode, scene, &ntemp, snode->mx, snode->my);
+       
+       if (!node) {
+               BKE_report(op->reports, RPT_WARNING, "Could not add an image 
node.");
+               return OPERATOR_CANCELLED;
        }
-       else
-               return OPERATOR_CANCELLED;
+       
+       node->id = (ID *)ima;
+       
+       snode_notify(C, snode);
+       snode_dag_update(C, snode);
+       
+       return OPERATOR_FINISHED;
 }
 
 static int node_add_file_invoke(bContext *C, wmOperator *op, wmEvent *event)
@@ -3175,7 +3177,7 @@
        PointerRNA ptr, idptr;
        PropertyRNA *prop;
        int treetype;
-       char treename[22] = "NodeTree";
+       char treename[MAX_ID_NAME-2] = "NodeTree";
        
        /* retrieve state */
        snode= CTX_wm_space_node(C);
@@ -3222,10 +3224,11 @@
        
        /* api callbacks */
        ot->exec= new_node_tree_exec;
+       ot->poll= ED_operator_node_active;
        
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
        
        RNA_def_enum(ot->srna, "type", nodetree_type_items, NTREE_COMPOSIT, 
"Tree Type", "");
-       RNA_def_string(ot->srna, "name", "NodeTree", 22, "Name", "");
+       RNA_def_string(ot->srna, "name", "NodeTree", MAX_ID_NAME-2, "Name", "");
 }

Modified: branches/particles-2010/source/blender/makesdna/DNA_node_types.h
===================================================================
--- branches/particles-2010/source/blender/makesdna/DNA_node_types.h    
2011-05-06 11:27:04 UTC (rev 36514)
+++ branches/particles-2010/source/blender/makesdna/DNA_node_types.h    
2011-05-06 13:04:47 UTC (rev 36515)
@@ -43,17 +43,10 @@
 struct SpaceNode;
 struct bNodeLink;
 struct bNodeType;
-struct bNodeSocketType;
-struct bNodeSocketTemplate;
-struct bNodeGroup;
 struct bNodeTreeExec;
 struct AnimData;
 struct bGPdata;
 struct uiBlock;
-struct StructRNA;
-struct PropertyRNA;
-struct PointerRNA;
-struct SimDataContext;
 
 #define NODE_MAXSTR 32
 
@@ -102,8 +95,8 @@
        
        /* execution data */
        short stack_index;                      /* local stack index */
-       short need_exec;
-       int pad;
+       short pad2;
+       int pad3;
        void *cache;                            /* cached data from execution */
        
        /* internal data to retrieve relations and groups */
@@ -111,7 +104,7 @@
        int to_index;                           /* XXX deprecated, only used 
for restoring old group node links */
        struct bNodeSocket *groupsock;
        
-       struct bNodeLink *link;         /* a link pointer, set in 
nodeSolveOrder() */
+       struct bNodeLink *link;         /* a link pointer, set in 
ntreeUpdateTree */
 
        /* DEPRECATED only needed for do_versions */
        bNodeStack ns;                          /* custom data for inputs, only 
UI writes in this */
@@ -128,8 +121,8 @@
 #define SOCK_IN_USE                            4       /* XXX deprecated */
        /* unavailable is for dynamic sockets */
 #define SOCK_UNAVAIL                   8
-       /* static socket (from initial node type lists) */
-#define SOCK_STATIC                            16
+       /* dynamic socket (can be modified by user) */
+#define SOCK_DYNAMIC                   16
        /* group socket should not be exposed */
 #define SOCK_INTERNAL                  32
        /* use this socket as the viewer output */

Modified: 
branches/particles-2010/source/blender/nodes/intern/CMP_nodes/CMP_common.c
===================================================================
--- branches/particles-2010/source/blender/nodes/intern/CMP_nodes/CMP_common.c  
2011-05-06 11:27:04 UTC (rev 36514)
+++ branches/particles-2010/source/blender/nodes/intern/CMP_nodes/CMP_common.c  
2011-05-06 13:04:47 UTC (rev 36515)
@@ -239,9 +239,9 @@
        
        while (gin && gout) {
                /* skip static (non-looping) sockets */
-               while (gin && (gin->flag & SOCK_STATIC))
+               while (gin && !(gin->flag & SOCK_DYNAMIC))
                        gin=gin->next;
-               while (gout && (gout->flag & SOCK_STATIC))
+               while (gout && !(gout->flag & SOCK_DYNAMIC))
                        gout=gout->next;
                
                if (gin && gout) {

Modified: branches/particles-2010/source/blender/nodes/intern/node_common.c
===================================================================
--- branches/particles-2010/source/blender/nodes/intern/node_common.c   
2011-05-06 11:27:04 UTC (rev 36514)
+++ branches/particles-2010/source/blender/nodes/intern/node_common.c   
2011-05-06 13:04:47 UTC (rev 36515)
@@ -89,6 +89,9 @@
        sock->next = sock->prev = NULL;
        sock->new_sock = NULL;
        
+       /* group sockets are dynamically added */
+       sock->flag |= SOCK_DYNAMIC;
+       
        sock->own_index = gsock->own_index;
        sock->groupsock = gsock;
        sock->limit = (in_out==SOCK_IN ? 1 : 0xFFF);
@@ -567,7 +570,8 @@
        
        strncpy(gsock->name, name, sizeof(gsock->name));
        gsock->type = type;
-       gsock->flag = 0;
+       /* group sockets are dynamically added */
+       gsock->flag |= SOCK_DYNAMIC;
 
        gsock->next = gsock->prev = NULL;
        gsock->new_sock = NULL;
@@ -734,7 +738,7 @@
        /* leftovers are removed */
        for (sock=lb->first; sock; sock=nextsock) {
                nextsock=sock->next;
-               if (!(sock->flag & SOCK_STATIC))
+               if (sock->flag & SOCK_DYNAMIC)
                        nodeRemoveSocket(ntree, node, sock);
        }
        /* and we put back the verified sockets */
@@ -823,7 +827,6 @@
        node->id = (ID*)ntemp->ngroup;
        
        sock = nodeAddInputValue(ntree, node, "Iterations", PROP_UNSIGNED, 1, 
0, 10000);
-       sock->flag |= SOCK_STATIC;
        
        /* NB: group socket input/output roles are inverted internally!
         * Group "inputs" work as outputs in links and vice versa.
@@ -841,7 +844,7 @@
 {
        bNodeSocket *sock;
        sock = node_group_add_socket(ntree, "Iteration", SOCK_VALUE, SOCK_IN);
-       sock->flag |= SOCK_STATIC | SOCK_INTERNAL;
+       sock->flag |= SOCK_INTERNAL;
 }
 
 static void loop_sync(bNodeTree *ntree, int sync_in_out)
@@ -868,10 +871,10 @@
        
        while (sock) {
                /* skip static and internal sockets on the sync side (preserves 
socket order!) */

@@ Diff output truncated at 10240 characters. @@
_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to