Revision: 32650
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=32650
Author:   lukastoenne
Date:     2010-10-22 13:19:11 +0200 (Fri, 22 Oct 2010)

Log Message:
-----------
Changed path sockets into node options. This makes it easier to resolve paths 
at build time and add dynamic properties and removes the need for an additional 
type field. The downside is that using strings from scene data for reference 
paths is not possible, but this is a hardly necessary and could be added back 
with special nodes that set the self context if the need should ever arise.

Modified Paths:
--------------
    branches/particles-2010/source/blender/blenkernel/BKE_node.h
    branches/particles-2010/source/blender/blenloader/intern/readfile.c
    branches/particles-2010/source/blender/blenloader/intern/writefile.c
    branches/particles-2010/source/blender/editors/space_node/drawnode.c
    branches/particles-2010/source/blender/makesdna/DNA_node_types.h
    branches/particles-2010/source/blender/makesrna/intern/rna_nodetree.c
    branches/particles-2010/source/blender/nodes/intern/simulation/SIM_util.c
    branches/particles-2010/source/blender/nodes/intern/simulation/SIM_util.h
    
branches/particles-2010/source/blender/nodes/intern/simulation/nodes/SIM_get_data.c
    
branches/particles-2010/source/blender/nodes/intern/simulation/nodes/SIM_set_data.c

Modified: branches/particles-2010/source/blender/blenkernel/BKE_node.h
===================================================================
--- branches/particles-2010/source/blender/blenkernel/BKE_node.h        
2010-10-22 10:18:58 UTC (rev 32649)
+++ branches/particles-2010/source/blender/blenkernel/BKE_node.h        
2010-10-22 11:19:11 UTC (rev 32650)
@@ -590,14 +590,14 @@
 /* node-specific functions for UI */
 /* XXX having these here is ugly, should be in nodes directory */
 void sim_getdata_add_property_socket(struct bNode *node, const char *prop);
-struct StructRNA *sim_getdata_type_get(struct bNode *node);
-void sim_getdata_type_set(struct bNodeTree *ntree, struct bNode *node, struct 
StructRNA *type);
 void sim_getdata_foreach_property(struct bNode *node, void *items, const char 
*str, int (*cb)(void *items, const char *str, const char *name, const char 
*identifier, int icon));
+void sim_getdata_path_set(struct bNodeTree *ntree, struct bNode *node, const 
char *path);
+const char *sim_getdata_path_get(struct bNode *node);
 
 void sim_setdata_add_property_socket(struct bNode *node, const char *prop);
-struct StructRNA *sim_setdata_type_get(struct bNode *node);
-void sim_setdata_type_set(struct bNodeTree *ntree, struct bNode *node, struct 
StructRNA *type);
 void sim_setdata_foreach_property(struct bNode *node, void *items, const char 
*str, int (*cb)(void *items, const char *str, const char *name, const char 
*identifier, int icon));
+void sim_setdata_path_set(struct bNodeTree *ntree, struct bNode *node, const 
char *path);
+const char *sim_setdata_path_get(struct bNode *node);
 
 /**/
 

Modified: branches/particles-2010/source/blender/blenloader/intern/readfile.c
===================================================================
--- branches/particles-2010/source/blender/blenloader/intern/readfile.c 
2010-10-22 10:18:58 UTC (rev 32649)
+++ branches/particles-2010/source/blender/blenloader/intern/readfile.c 
2010-10-22 11:19:11 UTC (rev 32650)
@@ -2064,19 +2064,6 @@
        }
 }
 
-static void direct_link_node_rna_data(FileData *fd, bNodeTree *ntree, bNode 
*node)
-{
-       SimDataNode *rna_data= (SimDataNode*)node->storage;
-       
-       /* restore the identifier string */
-       rna_data->save_type = newdataadr(fd, (void*)rna_data->save_type);
-       rna_data->type = RNA_find_struct(rna_data->save_type);
-       if (rna_data->save_type) {
-               MEM_freeN((void*)rna_data->save_type);
-               rna_data->save_type = NULL;
-       }
-}
-
 extern StructRNA RNA_SimulationNodeGetData;
 extern StructRNA RNA_SimulationNodeSetData;
 /* ntree itself has been read! */
@@ -2123,10 +2110,6 @@
                        else if( ntree->type==NTREE_TEXTURE && 
(node->type==TEX_NODE_CURVE_RGB || node->type==TEX_NODE_CURVE_TIME) ) {
                                direct_link_curvemapping(fd, node->storage);
                        }
-                       else if( ntree->type==NTREE_SIMULATION ) {
-                               if( node->type==SIM_NODE_GETDATA || 
node->type==SIM_NODE_SETDATA )
-                                       direct_link_node_rna_data(fd, ntree, 
node);
-                       }
                }
        }
        link_list(fd, &ntree->links);

Modified: branches/particles-2010/source/blender/blenloader/intern/writefile.c
===================================================================
--- branches/particles-2010/source/blender/blenloader/intern/writefile.c        
2010-10-22 10:18:58 UTC (rev 32649)
+++ branches/particles-2010/source/blender/blenloader/intern/writefile.c        
2010-10-22 11:19:11 UTC (rev 32650)
@@ -446,16 +446,6 @@
                writestruct(wd, DATA, "CurveMapPoint", cumap->cm[a].totpoint, 
cumap->cm[a].curve);
 }
 
-static void write_node_rna_data(WriteData *wd, SimDataNode *rna_data)
-{
-       writestruct(wd, DATA, "SimDataNode", 1, rna_data);
-       if (rna_data->type) {
-               /* save identifier string, to allow restoring the StructRNA 
pointer */
-               rna_data->save_type= RNA_struct_identifier(rna_data->type);
-               writedata(wd, DATA, strlen(rna_data->save_type)+1, 
(void*)rna_data->save_type);
-       }
-}
-
 /* this is only direct data, tree itself should have been written */
 static void write_nodetree(WriteData *wd, bNodeTree *ntree)
 {
@@ -496,10 +486,6 @@
                                write_curvemapping(wd, node->storage);
                        else if(ntree->type==NTREE_TEXTURE && 
(node->type==TEX_NODE_CURVE_RGB || node->type==TEX_NODE_CURVE_TIME) )
                                write_curvemapping(wd, node->storage);
-                       else if(ntree->type==NTREE_SIMULATION) {
-                               if(node->type==SIM_NODE_GETDATA || 
node->type==SIM_NODE_SETDATA)
-                                       write_node_rna_data(wd, node->storage);
-                       }
                        else
                                writestruct(wd, DATA, 
node->typeinfo->storagename, 1, node->storage);
                }

Modified: branches/particles-2010/source/blender/editors/space_node/drawnode.c
===================================================================
--- branches/particles-2010/source/blender/editors/space_node/drawnode.c        
2010-10-22 10:18:58 UTC (rev 32649)
+++ branches/particles-2010/source/blender/editors/space_node/drawnode.c        
2010-10-22 11:19:11 UTC (rev 32650)
@@ -1311,7 +1311,7 @@
        col= uiLayoutColumn(layout, 0);
        uiLayoutSetContextPointer(col, "node", ptr);
 
-       uiItemR(col, ptr, "typename", 0, NULL, 0);
+       uiItemR(col, ptr, "path", 0, NULL, 0);
        
        getdata_add_property_search(layout, node);
 }
@@ -1358,7 +1358,7 @@
        col= uiLayoutColumn(layout, 0);
        uiLayoutSetContextPointer(col, "node", ptr);
 
-       uiItemR(col, ptr, "typename", 0, NULL, 0);
+       uiItemR(col, ptr, "path", 0, NULL, 0);
        
        setdata_add_property_search(layout, node);
 }

Modified: branches/particles-2010/source/blender/makesdna/DNA_node_types.h
===================================================================
--- branches/particles-2010/source/blender/makesdna/DNA_node_types.h    
2010-10-22 10:18:58 UTC (rev 32649)
+++ branches/particles-2010/source/blender/makesdna/DNA_node_types.h    
2010-10-22 11:19:11 UTC (rev 32650)
@@ -394,9 +394,7 @@
 } SimDataNodeSocket;
 
 typedef struct SimDataNode {
-       struct StructRNA *type;                 /* context type of the 
properties */
-       /* only used during read/write file! */
-       const char *save_type;                  /* identifier string */
+       char path[128];
 } SimDataNode;
 
 /* comp channel matte */

Modified: branches/particles-2010/source/blender/makesrna/intern/rna_nodetree.c
===================================================================
--- branches/particles-2010/source/blender/makesrna/intern/rna_nodetree.c       
2010-10-22 10:18:58 UTC (rev 32649)
+++ branches/particles-2010/source/blender/makesrna/intern/rna_nodetree.c       
2010-10-22 11:19:11 UTC (rev 32650)
@@ -441,50 +441,34 @@
        return item;
 }
 
-static void rna_Node_getdata_typename_get(PointerRNA *ptr, char *value)
+static void rna_Node_getdata_path_get(PointerRNA *ptr, char *value)
 {
-       StructRNA *type= sim_getdata_type_get((bNode*)ptr->data);
-       if (type)
-               strcpy(value, RNA_struct_identifier(type));
-       else
-               value[0] = '\0';
+       strcpy(value, sim_getdata_path_get((bNode*)ptr->data));
 }
 
-static int rna_Node_getdata_typename_length(PointerRNA *ptr)
+static int rna_Node_getdata_path_length(PointerRNA *ptr)
 {
-       StructRNA *type= sim_getdata_type_get((bNode*)ptr->data);
-       if (type)
-               return strlen(RNA_struct_identifier(type));
-       else
-               return 0;
+       return strlen(sim_getdata_path_get((bNode*)ptr->data));
 }
 
-static void rna_Node_getdata_typename_set(PointerRNA *ptr, const char *value)
+static void rna_Node_getdata_path_set(PointerRNA *ptr, const char *value)
 {
-       sim_getdata_type_set((bNodeTree*)ptr->id.data, (bNode*)ptr->data, 
RNA_find_struct(value));
+       sim_getdata_path_set((bNodeTree*)ptr->id.data, (bNode*)ptr->data, 
value);
 }
 
-static void rna_Node_setdata_typename_get(PointerRNA *ptr, char *value)
+static void rna_Node_setdata_path_get(PointerRNA *ptr, char *value)
 {
-       StructRNA *type= sim_setdata_type_get((bNode*)ptr->data);
-       if (type)
-               strcpy(value, RNA_struct_identifier(type));
-       else
-               value[0] = '\0';
+       strcpy(value, sim_setdata_path_get((bNode*)ptr->data));
 }
 
-static int rna_Node_setdata_typename_length(PointerRNA *ptr)
+static int rna_Node_setdata_path_length(PointerRNA *ptr)
 {
-       StructRNA *type= sim_setdata_type_get((bNode*)ptr->data);
-       if (type)
-               return strlen(RNA_struct_identifier(type));
-       else
-               return 0;
+       return strlen(sim_setdata_path_get((bNode*)ptr->data));
 }
 
-static void rna_Node_setdata_typename_set(PointerRNA *ptr, const char *value)
+static void rna_Node_setdata_path_set(PointerRNA *ptr, const char *value)
 {
-       sim_setdata_type_set((bNodeTree*)ptr->id.data, (bNode*)ptr->data, 
RNA_find_struct(value));
+       sim_setdata_path_set((bNodeTree*)ptr->id.data, (bNode*)ptr->data, 
value);
 }
 
 #else
@@ -2202,9 +2186,9 @@
 {
        PropertyRNA *prop;
 
-       prop = RNA_def_property(srna, "typename", PROP_STRING, PROP_NONE);
-       RNA_def_property_string_funcs(prop, "rna_Node_getdata_typename_get", 
"rna_Node_getdata_typename_length", "rna_Node_getdata_typename_set");
-       RNA_def_property_ui_text(prop, "Type", "RNA struct name of the data 
node");
+       prop = RNA_def_property(srna, "path", PROP_STRING, PROP_NONE);
+       RNA_def_property_string_funcs(prop, "rna_Node_getdata_path_get", 
"rna_Node_getdata_path_length", "rna_Node_getdata_path_set");
+       RNA_def_property_ui_text(prop, "Path", "RNA path of the data node");
        RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
 }
 
@@ -2212,9 +2196,9 @@
 {
        PropertyRNA *prop;
 
-       prop = RNA_def_property(srna, "typename", PROP_STRING, PROP_NONE);
-       RNA_def_property_string_funcs(prop, "rna_Node_setdata_typename_get", 
"rna_Node_setdata_typename_length", "rna_Node_setdata_typename_set");
-       RNA_def_property_ui_text(prop, "Type", "RNA struct name of the data 
node");
+       prop = RNA_def_property(srna, "path", PROP_STRING, PROP_NONE);
+       RNA_def_property_string_funcs(prop, "rna_Node_setdata_path_get", 
"rna_Node_setdata_path_length", "rna_Node_setdata_path_set");
+       RNA_def_property_ui_text(prop, "Path", "RNA path of the data node");
        RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
 }
 

Modified: 
branches/particles-2010/source/blender/nodes/intern/simulation/SIM_util.c
===================================================================
--- branches/particles-2010/source/blender/nodes/intern/simulation/SIM_util.c   
2010-10-22 10:18:58 UTC (rev 32649)
+++ branches/particles-2010/source/blender/nodes/intern/simulation/SIM_util.c   
2010-10-22 11:19:11 UTC (rev 32650)
@@ -107,12 +107,14 @@
                return ctx->ptr.type;
 }
 
+int sim_context_is_defined(SimDataContext *ctx)
+{
+       return (ctx->ptr.data != NULL);
+}
+
 int sim_context_is_collection(SimDataContext *ctx)
 {
-       if (ctx->prop)
-               return (RNA_property_type(ctx->prop) == PROP_COLLECTION);
-       else
-               return 0;
+       return (ctx->prop != NULL && RNA_property_type(ctx->prop) == 
PROP_COLLECTION);
 }
 

@@ 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