Revision: 36333
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=36333
Author:   lukastoenne
Date:     2011-04-26 09:27:43 +0000 (Tue, 26 Apr 2011)
Log Message:
-----------
Too many changes to list them all. Most important one is to the way socket data 
types are defined and default values in sockets are stored.

Each socket type now has a compact definition in the form of a bNodeSocketType 
struct (the original bNodeSocketType struct has already been renamed to 
bNodeSocketTemplate some time ago). This new struct stores all info for this 
socket type, from simple button color to visitor functions for conversion 
methods. The only information that is not to be found in node_socket.h/.c is 
the conversion from socket input button data to execution data, as this depends 
very much on the concrete node tree type.

Instead of the inflexible bNodeStack struct, sockets now have a generic 
default_value pointer to store the input values of buttons. This points to one 
of the bNodeSocketValue*** structs, which store the button value and additional 
information, such as limits and property subtypes for button details.

Modified Paths:
--------------
    branches/particles-2010/source/blender/blenkernel/BKE_node.h
    branches/particles-2010/source/blender/blenkernel/intern/node.c
    branches/particles-2010/source/blender/blenloader/intern/readfile.c
    branches/particles-2010/source/blender/blenloader/intern/writefile.c
    branches/particles-2010/source/blender/editors/include/ED_node.h
    branches/particles-2010/source/blender/editors/space_node/drawnode.c
    branches/particles-2010/source/blender/editors/space_node/node_draw.c
    branches/particles-2010/source/blender/editors/space_node/node_edit.c
    branches/particles-2010/source/blender/editors/space_node/node_intern.h
    branches/particles-2010/source/blender/makesdna/DNA_node_types.h
    branches/particles-2010/source/blender/makesrna/RNA_enum_types.h
    branches/particles-2010/source/blender/makesrna/intern/rna_nodetree.c
    branches/particles-2010/source/blender/makesrna/intern/rna_nodetree_types.h
    branches/particles-2010/source/blender/makesrna/intern/rna_rna.c
    
branches/particles-2010/source/blender/nodes/intern/CMP_nodes/CMP_alphaOver.c
    
branches/particles-2010/source/blender/nodes/intern/CMP_nodes/CMP_bilateralblur.c
    branches/particles-2010/source/blender/nodes/intern/CMP_nodes/CMP_blur.c
    
branches/particles-2010/source/blender/nodes/intern/CMP_nodes/CMP_brightness.c
    
branches/particles-2010/source/blender/nodes/intern/CMP_nodes/CMP_channelMatte.c
    
branches/particles-2010/source/blender/nodes/intern/CMP_nodes/CMP_chromaMatte.c
    
branches/particles-2010/source/blender/nodes/intern/CMP_nodes/CMP_colorMatte.c
    
branches/particles-2010/source/blender/nodes/intern/CMP_nodes/CMP_colorSpill.c
    
branches/particles-2010/source/blender/nodes/intern/CMP_nodes/CMP_colorbalance.c
    branches/particles-2010/source/blender/nodes/intern/CMP_nodes/CMP_common.c
    
branches/particles-2010/source/blender/nodes/intern/CMP_nodes/CMP_composite.c
    branches/particles-2010/source/blender/nodes/intern/CMP_nodes/CMP_crop.c
    branches/particles-2010/source/blender/nodes/intern/CMP_nodes/CMP_curves.c
    branches/particles-2010/source/blender/nodes/intern/CMP_nodes/CMP_defocus.c
    
branches/particles-2010/source/blender/nodes/intern/CMP_nodes/CMP_diffMatte.c
    branches/particles-2010/source/blender/nodes/intern/CMP_nodes/CMP_dilate.c
    
branches/particles-2010/source/blender/nodes/intern/CMP_nodes/CMP_directionalblur.c
    branches/particles-2010/source/blender/nodes/intern/CMP_nodes/CMP_displace.c
    
branches/particles-2010/source/blender/nodes/intern/CMP_nodes/CMP_distanceMatte.c
    branches/particles-2010/source/blender/nodes/intern/CMP_nodes/CMP_filter.c
    branches/particles-2010/source/blender/nodes/intern/CMP_nodes/CMP_flip.c
    branches/particles-2010/source/blender/nodes/intern/CMP_nodes/CMP_gamma.c
    branches/particles-2010/source/blender/nodes/intern/CMP_nodes/CMP_glare.c
    
branches/particles-2010/source/blender/nodes/intern/CMP_nodes/CMP_hueSatVal.c
    
branches/particles-2010/source/blender/nodes/intern/CMP_nodes/CMP_huecorrect.c
    branches/particles-2010/source/blender/nodes/intern/CMP_nodes/CMP_idMask.c
    branches/particles-2010/source/blender/nodes/intern/CMP_nodes/CMP_invert.c
    branches/particles-2010/source/blender/nodes/intern/CMP_nodes/CMP_lensdist.c
    branches/particles-2010/source/blender/nodes/intern/CMP_nodes/CMP_levels.c
    
branches/particles-2010/source/blender/nodes/intern/CMP_nodes/CMP_lummaMatte.c
    branches/particles-2010/source/blender/nodes/intern/CMP_nodes/CMP_mapUV.c
    branches/particles-2010/source/blender/nodes/intern/CMP_nodes/CMP_mapValue.c
    branches/particles-2010/source/blender/nodes/intern/CMP_nodes/CMP_math.c
    branches/particles-2010/source/blender/nodes/intern/CMP_nodes/CMP_mixrgb.c
    branches/particles-2010/source/blender/nodes/intern/CMP_nodes/CMP_normal.c
    
branches/particles-2010/source/blender/nodes/intern/CMP_nodes/CMP_normalize.c
    
branches/particles-2010/source/blender/nodes/intern/CMP_nodes/CMP_outputFile.c
    
branches/particles-2010/source/blender/nodes/intern/CMP_nodes/CMP_premulkey.c
    branches/particles-2010/source/blender/nodes/intern/CMP_nodes/CMP_rgb.c
    branches/particles-2010/source/blender/nodes/intern/CMP_nodes/CMP_rotate.c
    branches/particles-2010/source/blender/nodes/intern/CMP_nodes/CMP_scale.c
    
branches/particles-2010/source/blender/nodes/intern/CMP_nodes/CMP_sepcombHSVA.c
    
branches/particles-2010/source/blender/nodes/intern/CMP_nodes/CMP_sepcombRGBA.c
    
branches/particles-2010/source/blender/nodes/intern/CMP_nodes/CMP_sepcombYCCA.c
    
branches/particles-2010/source/blender/nodes/intern/CMP_nodes/CMP_sepcombYUVA.c
    branches/particles-2010/source/blender/nodes/intern/CMP_nodes/CMP_setalpha.c
    
branches/particles-2010/source/blender/nodes/intern/CMP_nodes/CMP_splitViewer.c
    branches/particles-2010/source/blender/nodes/intern/CMP_nodes/CMP_texture.c
    branches/particles-2010/source/blender/nodes/intern/CMP_nodes/CMP_tonemap.c
    
branches/particles-2010/source/blender/nodes/intern/CMP_nodes/CMP_translate.c
    branches/particles-2010/source/blender/nodes/intern/CMP_nodes/CMP_valToRgb.c
    branches/particles-2010/source/blender/nodes/intern/CMP_nodes/CMP_value.c
    branches/particles-2010/source/blender/nodes/intern/CMP_nodes/CMP_vecBlur.c
    branches/particles-2010/source/blender/nodes/intern/CMP_nodes/CMP_viewer.c
    branches/particles-2010/source/blender/nodes/intern/CMP_nodes/CMP_zcombine.c
    branches/particles-2010/source/blender/nodes/intern/CMP_nodetree.c
    branches/particles-2010/source/blender/nodes/intern/SHD_nodes/SHD_common.c
    branches/particles-2010/source/blender/nodes/intern/SHD_nodes/SHD_normal.c
    branches/particles-2010/source/blender/nodes/intern/SHD_nodes/SHD_rgb.c
    branches/particles-2010/source/blender/nodes/intern/SHD_nodes/SHD_value.c
    branches/particles-2010/source/blender/nodes/intern/SHD_util.c
    branches/particles-2010/source/blender/nodes/intern/TEX_nodes/TEX_common.c
    branches/particles-2010/source/blender/nodes/intern/node_common.c
    branches/particles-2010/source/blender/nodes/intern/node_common.h
    branches/particles-2010/source/blender/nodes/intern/node_exec.c
    branches/particles-2010/source/blender/nodes/intern/node_exec.h
    branches/particles-2010/source/blender/nodes/intern/node_socket.c
    branches/particles-2010/source/blender/nodes/intern/node_socket.h
    branches/particles-2010/source/blender/windowmanager/intern/wm_init_exit.c

Modified: branches/particles-2010/source/blender/blenkernel/BKE_node.h
===================================================================
--- branches/particles-2010/source/blender/blenkernel/BKE_node.h        
2011-04-26 07:17:21 UTC (rev 36332)
+++ branches/particles-2010/source/blender/blenkernel/BKE_node.h        
2011-04-26 09:27:43 UTC (rev 36333)
@@ -61,6 +61,8 @@
 struct ID;
 struct ListBase;
 struct Main;
+struct uiBlock;
+struct uiLayout;
 struct MTex;
 struct StructRNA;
 struct PointerRNA;
@@ -69,7 +71,6 @@
 struct RenderData;
 struct Scene;
 struct Tex;
-struct uiLayout;
 struct SpaceNode;
 struct ARegion;
 struct Object;
@@ -84,15 +85,20 @@
 typedef struct bNodeSocketTemplate {
        int type, limit;
        char name[32];
-       float val1, val2, val3, val4;   /* default alloc value for inputs */
-       float min, max;                                 /* default range for 
inputs */
+       float val1, val2, val3, val4;   /* default alloc value for inputs */
+       float min, max;
+       PropertySubType subtype;
        
        /* after this line is used internal only */
        struct bNodeSocket *sock;               /* used to hold verified socket 
*/
 } bNodeSocketTemplate;
 
+typedef void (*NodeSocketButtonFunction)(const struct bContext *C, struct 
uiBlock *block, 
+                                                                               
 struct bNodeTree *ntree, struct bNode *node, struct bNodeSocket *sock,
+                                                                               
 const char *name, int x, int y, int width);
 /* visitor function for socket converters */
 typedef void (*SocketConvWalkFunc)(void *userdata, int converter, const char 
*name);
+
 typedef struct bNodeSocketType {
        int type;
        char ui_name[32];
@@ -100,8 +106,11 @@
        int ui_icon;
        char ui_color[4];
        
-       int value_size;
+       const char *value_structname;
+       int value_structsize;
        
+       NodeSocketButtonFunction buttonfunc;
+       
        void (*foreach_converter)(void *userdata, int type, SocketConvWalkFunc 
cb);
        
        /* functions for sources of this type */
@@ -130,6 +139,7 @@
        float height, minheight, maxheight;
        short nclass, flag;
        
+       /* templates for static sockets */
        bNodeSocketTemplate *inputs, *outputs;
        
        char storagename[64];                   /* struct name for DNA */
@@ -298,8 +308,8 @@
 
 /* ************** GENERIC API, NODES *************** */
 
-struct bNodeSocket *nodeAddSocket(struct bNodeTree *ntree, struct bNode *node, 
int in_out, const char *name, int type, PropertySubType subtype);
-struct bNodeSocket *nodeInsertSocket(struct bNodeTree *ntree, struct bNode 
*node, int in_out, struct bNodeSocket *next_sock, const char *name, int type, 
PropertySubType subtype);
+struct bNodeSocket *nodeAddSocket(struct bNodeTree *ntree, struct bNode *node, 
int in_out, const char *name, int type);
+struct bNodeSocket *nodeInsertSocket(struct bNodeTree *ntree, struct bNode 
*node, int in_out, struct bNodeSocket *next_sock, const char *name, int type);
 void nodeRemoveSocket(struct bNodeTree *ntree, struct bNode *node, struct 
bNodeSocket *sock);
 void nodeRemoveAllSockets(struct bNodeTree *ntree, struct bNode *node);
 

Modified: branches/particles-2010/source/blender/blenkernel/intern/node.c
===================================================================
--- branches/particles-2010/source/blender/blenkernel/intern/node.c     
2011-04-26 07:17:21 UTC (rev 36332)
+++ branches/particles-2010/source/blender/blenkernel/intern/node.c     
2011-04-26 09:27:43 UTC (rev 36333)
@@ -163,45 +163,27 @@
        ntree->init |= NTREE_TYPE_INIT;
 }
 
-static bNodeSocket *make_socket(bNodeTree *ntree, int in_out, const char 
*name, int type, int subtype)
+static bNodeSocket *make_socket(bNodeTree *ntree, int in_out, const char 
*name, int type)
 {
        bNodeSocketType *stype= ntreeGetSocketType(type);
        bNodeSocket *sock;
-       PropertyRNA *prop;
-       PointerRNA ptr;
        
        sock= MEM_callocN(sizeof(bNodeSocket), "sock");
        
        BLI_strncpy(sock->name, name, NODE_MAXSTR);
        sock->limit = (in_out==SOCK_IN ? 1 : 0xFFF);
        sock->type= type;
-       sock->subtype = subtype;
        sock->storage = NULL;
        
-       if (stype->value_size > 0) {
-               /* NB: all necessary properties for RNA refine have been set! */
-               RNA_pointer_create((ID*)ntree, &RNA_NodeSocket, sock, &ptr);
-               prop = RNA_struct_find_property(&ptr, "default_value");
-               if (prop) {
-                       int index, len= RNA_property_array_length(&ptr, prop);
-                       
-                       sock->default_value = MEM_callocN(stype->value_size, 
"default value");
-                       
-                       /* reset to default value */
-                       for (index=0; index < len; ++index)
-                               RNA_property_reset(&ptr, prop, index);
-               }
-       }
-       zero_v4(sock->ns.vec);
-       sock->ns.min = -FLT_MAX;        /* _not_ FLT_MIN, that would be the 
smallest possible float > 0 */
-       sock->ns.max = FLT_MAX;
+       if (stype->value_structsize > 0)
+               sock->default_value = MEM_callocN(stype->value_structsize, 
"default socket value");
        
        return sock;
 }
 
-bNodeSocket *nodeAddSocket(bNodeTree *ntree, bNode *node, int in_out, const 
char *name, int type, PropertySubType subtype)
+bNodeSocket *nodeAddSocket(bNodeTree *ntree, bNode *node, int in_out, const 
char *name, int type)
 {
-       bNodeSocket *sock = make_socket(ntree, in_out, name, type, subtype);
+       bNodeSocket *sock = make_socket(ntree, in_out, name, type);
        if (in_out==SOCK_IN)
                BLI_addtail(&node->inputs, sock);
        else if (in_out==SOCK_OUT)
@@ -212,9 +194,9 @@
        return sock;
 }
 
-bNodeSocket *nodeInsertSocket(bNodeTree *ntree, bNode *node, int in_out, 
bNodeSocket *next_sock, const char *name, int type, PropertySubType subtype)
+bNodeSocket *nodeInsertSocket(bNodeTree *ntree, bNode *node, int in_out, 
bNodeSocket *next_sock, const char *name, int type)
 {
-       bNodeSocket *sock = make_socket(ntree, in_out, name, type, subtype);
+       bNodeSocket *sock = make_socket(ntree, in_out, name, type);
        if (in_out==SOCK_IN)
                BLI_insertlinkbefore(&node->inputs, next_sock, sock);
        else if (in_out==SOCK_OUT)
@@ -485,36 +467,20 @@
        if(ntype->inputs) {
                sockdef= ntype->inputs;
                while(sockdef->type != -1) {
-                       sock = nodeAddSocket(ntree, node, SOCK_IN, 
sockdef->name, sockdef->type, PROP_NONE);
+                       sock = node_add_input_from_template(ntree, node, 
sockdef);
                        /* tag socket as static */
                        sock->flag |= SOCK_STATIC;
                        
-                       /* init input value */
-                       sock->ns.vec[0] = sockdef->val1;
-                       sock->ns.vec[1] = sockdef->val2;
-                       sock->ns.vec[2] = sockdef->val3;
-                       sock->ns.vec[3] = sockdef->val4;
-                       sock->ns.min = sockdef->min;
-                       sock->ns.max = sockdef->max;
-                       
                        sockdef++;
                }
        }
        if(ntype->outputs) {
                sockdef= ntype->outputs;
                while(sockdef->type != -1) {
-                       sock = nodeAddSocket(ntree, node, SOCK_OUT, 
sockdef->name, sockdef->type, PROP_NONE);
+                       sock = node_add_output_from_template(ntree, node, 
sockdef);
                        /* tag socket as static */
                        sock->flag |= SOCK_STATIC;
                        
-                       /* init input value */
-                       sock->ns.vec[0] = sockdef->val1;
-                       sock->ns.vec[1] = sockdef->val2;
-                       sock->ns.vec[2] = sockdef->val3;
-                       sock->ns.vec[3] = sockdef->val4;
-                       sock->ns.min = sockdef->min;
-                       sock->ns.max = sockdef->max;
-                       
                        sockdef++;
                }
        }
@@ -612,8 +578,10 @@
        for(sock= nnode->inputs.first; sock; sock= sock->next, oldsock= 
oldsock->next) {
                oldsock->new_sock= sock;
                sock->stack_index= 0;
-               sock->ns.data= NULL;
                
+               if (sock->default_value)
+                       sock->default_value = 
MEM_dupallocN(sock->default_value);
+               
                if (sock->panel)
                        sock->panel = sock->panel->new_panel;
        }
@@ -623,8 +591,10 @@
        for(sock= nnode->outputs.first; sock; sock= sock->next, oldsock= 
oldsock->next) {
                oldsock->new_sock= sock;
                sock->stack_index= 0;
-               sock->ns.data= NULL;
                
+               if (sock->default_value)
+                       sock->default_value = 
MEM_dupallocN(sock->default_value);
+               
                if (sock->panel)
                        sock->panel = sock->panel->new_panel;
        }

Modified: branches/particles-2010/source/blender/blenloader/intern/readfile.c
===================================================================
--- branches/particles-2010/source/blender/blenloader/intern/readfile.c 
2011-04-26 07:17:21 UTC (rev 36332)
+++ branches/particles-2010/source/blender/blenloader/intern/readfile.c 
2011-04-26 09:27:43 UTC (rev 36333)
@@ -2221,16 +2221,30 @@
                        sock->storage= newdataadr(fd, sock->storage);
                        sock->panel= newdataadr(fd, sock->panel);
                        sock->default_value= newdataadr(fd, 
sock->default_value);
+                       sock->cache= NULL;
                }
                for(sock= node->outputs.first; sock; sock= sock->next) {
-                       sock->ns.data= NULL;
+                       sock->link= NULL;
                        sock->storage= newdataadr(fd, sock->storage);
                        sock->panel= newdataadr(fd, sock->panel);
                        sock->default_value= newdataadr(fd, 
sock->default_value);
+                       sock->cache= NULL;
                }
        }
-       for(sock= ntree->outputs.first; sock; sock= sock->next)
+       for(sock= ntree->inputs.first; sock; sock= sock->next) {
+               sock->link= NULL;
+               sock->storage= newdataadr(fd, sock->storage);
+               sock->panel= newdataadr(fd, sock->panel);
+               sock->default_value= newdataadr(fd, sock->default_value);
+               sock->cache= NULL;
+       }
+       for(sock= ntree->outputs.first; sock; sock= sock->next) {
                sock->link= newdataadr(fd, sock->link);
+               sock->storage= newdataadr(fd, sock->storage);
+               sock->panel= newdataadr(fd, sock->panel);
+               sock->default_value= newdataadr(fd, sock->default_value);
+               sock->cache= NULL;
+       }
        
        for(link= ntree->links.first; link; link= link->next) {
                link->fromnode= newdataadr(fd, link->fromnode);

Modified: branches/particles-2010/source/blender/blenloader/intern/writefile.c
===================================================================
--- branches/particles-2010/source/blender/blenloader/intern/writefile.c        
2011-04-26 07:17:21 UTC (rev 36332)
+++ branches/particles-2010/source/blender/blenloader/intern/writefile.c        
2011-04-26 09:27:43 UTC (rev 36333)
@@ -663,13 +663,13 @@
                        bNodeSocketType *stype= ntreeGetSocketType(sock->type);
                        writestruct(wd, DATA, "bNodeSocket", 1, sock);
                        if (sock->default_value)
-                               writedata(wd, DATA, stype->value_size, 
sock->default_value);
+                               writestruct(wd, DATA, stype->value_structname, 
1, sock->default_value);
                }
                for(sock= node->outputs.first; sock; sock= sock->next) {
                        bNodeSocketType *stype= ntreeGetSocketType(sock->type);
                        writestruct(wd, DATA, "bNodeSocket", 1, sock);
                        if (sock->default_value)
-                               writedata(wd, DATA, stype->value_size, 
sock->default_value);
+                               writestruct(wd, DATA, stype->value_structname, 
1, sock->default_value);
                }
                
                for(panel=node->inpanels.first; panel; panel = panel->next)
@@ -698,13 +698,13 @@
                bNodeSocketType *stype= ntreeGetSocketType(sock->type);
                writestruct(wd, DATA, "bNodeSocket", 1, sock);
                if (sock->default_value)
-                       writedata(wd, DATA, stype->value_size, 
sock->default_value);
+                       writestruct(wd, DATA, stype->value_structname, 1, 
sock->default_value);
        }

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

Reply via email to