[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [33681] branches/particles-2010/source/ blender: Replaced the Data node category with 2 menus for GetData and SetData.

Lukas Toenne lukas.toenne at googlemail.com
Wed Dec 15 09:42:38 CET 2010


Revision: 33681
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=33681
Author:   lukastoenne
Date:     2010-12-15 09:42:37 +0100 (Wed, 15 Dec 2010)

Log Message:
-----------
Replaced the Data node category with 2 menus for GetData and SetData. These contain a set of predefined data nodes for common types, like object or scene. This makes it much easier to create data nodes without the need to type in a struct name. The type is also displayed in the data node name for clarity.

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/editors/space_node/node_header.c
    branches/particles-2010/source/blender/nodes/intern/SIM_nodes/SIM_constant.c
    branches/particles-2010/source/blender/nodes/intern/SIM_nodes/SIM_create_mesh_point.c
    branches/particles-2010/source/blender/nodes/intern/SIM_nodes/SIM_debugprint.c
    branches/particles-2010/source/blender/nodes/intern/SIM_nodes/SIM_filter.c
    branches/particles-2010/source/blender/nodes/intern/SIM_nodes/SIM_get_data.c
    branches/particles-2010/source/blender/nodes/intern/SIM_nodes/SIM_get_mesh_data.c
    branches/particles-2010/source/blender/nodes/intern/SIM_nodes/SIM_index.c
    branches/particles-2010/source/blender/nodes/intern/SIM_nodes/SIM_random.c
    branches/particles-2010/source/blender/nodes/intern/SIM_nodes/SIM_set_data.c
    branches/particles-2010/source/blender/nodes/intern/SIM_nodes/SIM_timestep.c

Modified: branches/particles-2010/source/blender/blenkernel/BKE_node.h
===================================================================
--- branches/particles-2010/source/blender/blenkernel/BKE_node.h	2010-12-15 08:21:58 UTC (rev 33680)
+++ branches/particles-2010/source/blender/blenkernel/BKE_node.h	2010-12-15 08:42:37 UTC (rev 33681)
@@ -168,11 +168,12 @@
 #define NODE_CLASS_PATTERN			12
 #define NODE_CLASS_TEXTURE			13
 #define NODE_CLASS_EXECUTION		14
-#define NODE_CLASS_DATA				15
-#define NODE_CLASS_MATH				16
-#define NODE_CLASS_MATH_VECTOR		17
-#define NODE_CLASS_MATH_ROTATION	18
-#define NODE_CLASS_PARTICLES		22
+#define NODE_CLASS_GETDATA			15
+#define NODE_CLASS_SETDATA			16
+#define NODE_CLASS_MATH				17
+#define NODE_CLASS_MATH_VECTOR		18
+#define NODE_CLASS_MATH_ROTATION	19
+#define NODE_CLASS_PARTICLES		25
 
 typedef void (*bNodeTreeCallback)(void *calldata, struct ID *owner_id, struct bNodeTree *ntree);
 typedef struct bNodeTreeTypeInfo

Modified: branches/particles-2010/source/blender/blenkernel/intern/node.c
===================================================================
--- branches/particles-2010/source/blender/blenkernel/intern/node.c	2010-12-15 08:21:58 UTC (rev 33680)
+++ branches/particles-2010/source/blender/blenkernel/intern/node.c	2010-12-15 08:42:37 UTC (rev 33681)
@@ -1299,7 +1299,6 @@
 
 bNodeTree *ntreeAddTree(const char *name, int type, const short is_group)
 {
-	bNodeTreeTypeInfo *treetype= ntreeGetTypeInfo(type);
 	bNodeTree *ntree;
 
 	/* trees are created as local trees if they of compositor, material or texture type,

Modified: branches/particles-2010/source/blender/editors/space_node/node_header.c
===================================================================
--- branches/particles-2010/source/blender/editors/space_node/node_header.c	2010-12-15 08:21:58 UTC (rev 33680)
+++ branches/particles-2010/source/blender/editors/space_node/node_header.c	2010-12-15 08:42:37 UTC (rev 33681)
@@ -43,6 +43,7 @@
 #include "BKE_node.h"
 #include "BKE_main.h"
 
+#include "RNA_access.h"
 
 #include "WM_api.h"
 #include "WM_types.h"
@@ -156,6 +157,71 @@
 	}
 }
 
+static struct StructRNA *data_node_types[] = {
+	&RNA_Scene,
+	&RNA_Object,
+	&RNA_Lamp,
+	&RNA_NParticle,
+	NULL				/* terminator */
+};
+
+static void do_data_node_add(bContext *C, void *arg_nodeclass, int event)
+{
+	SpaceNode *snode= CTX_wm_space_node(C);
+	int nodeclass= GET_INT_FROM_POINTER(arg_nodeclass);
+	/* here the event is not the node type, but the data type */
+	struct StructRNA *datatype= data_node_types[event];
+	bNode *node;
+	
+	/* store selection in temp test flag */
+	for(node= snode->edittree->nodes.first; node; node= node->next) {
+		if(node->flag & NODE_SELECT) node->flag |= NODE_TEST;
+		else node->flag &= ~NODE_TEST;
+	}
+	
+	/* set the data type for this item */
+	if (nodeclass == NODE_CLASS_GETDATA) {
+		node= node_add_node(snode, CTX_data_scene(C), SIM_NODE_GETDATA, snode->mx, snode->my);
+		sim_getdata_type_set(snode->edittree, node, datatype);
+	}
+	else if (nodeclass == NODE_CLASS_SETDATA) {
+		node= node_add_node(snode, CTX_data_scene(C), SIM_NODE_SETDATA, snode->mx, snode->my);
+		sim_setdata_type_set(snode->edittree, node, datatype);
+	}
+	
+	/* select previous selection before autoconnect */
+	for(node= snode->edittree->nodes.first; node; node= node->next) {
+		if(node->flag & NODE_TEST) node->flag |= NODE_SELECT;
+	}
+	
+	snode_autoconnect(snode, 1, 0);
+	
+	/* deselect after autoconnection */
+	for(node= snode->edittree->nodes.first; node; node= node->next) {
+		if(node->flag & NODE_TEST) node->flag &= ~NODE_SELECT;
+	}
+	
+	snode_notify(C, snode);
+}
+
+static void data_node_add_menu(bContext *C, uiLayout *layout, void *arg_nodeclass)
+{
+	SpaceNode *snode= CTX_wm_space_node(C);
+	bNodeTree *ntree= snode->nodetree;
+	int i;
+	
+	if(!ntree) {
+		uiItemS(layout);
+		return;
+	}
+	
+	uiLayoutSetFunc(layout, do_data_node_add, arg_nodeclass);
+	
+	for (i=0; data_node_types[i] != NULL; ++i) {
+		uiItemV(layout, (char*)RNA_struct_ui_name(data_node_types[i]), RNA_struct_ui_icon(data_node_types[i]), i);
+	}
+}
+
 static void node_menu_add(const bContext *C, Menu *menu)
 {
 	uiLayout *layout= menu->layout;
@@ -208,7 +274,8 @@
 	}
 	else if(snode->treetype==NTREE_SIMULATION) {
 		uiItemMenuF(layout, "Execution", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_EXECUTION));
-		uiItemMenuF(layout, "Data", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_DATA));
+		uiItemMenuF(layout, "Get Data", 0, data_node_add_menu, SET_INT_IN_POINTER(NODE_CLASS_GETDATA));
+		uiItemMenuF(layout, "Set Data", 0, data_node_add_menu, SET_INT_IN_POINTER(NODE_CLASS_SETDATA));
 		uiItemMenuF(layout, "Convertor", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_CONVERTOR));
 		uiItemMenuF(layout, "Math", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_MATH));
 		uiItemMenuF(layout, "Vector Math", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_MATH_VECTOR));

Modified: branches/particles-2010/source/blender/nodes/intern/SIM_nodes/SIM_constant.c
===================================================================
--- branches/particles-2010/source/blender/nodes/intern/SIM_nodes/SIM_constant.c	2010-12-15 08:21:58 UTC (rev 33680)
+++ branches/particles-2010/source/blender/nodes/intern/SIM_nodes/SIM_constant.c	2010-12-15 08:42:37 UTC (rev 33681)
@@ -142,7 +142,7 @@
 static void init_common_type(bNodeType *type)
 {
 	memset(type, 0, sizeof(bNodeType));
-	type->nclass = NODE_CLASS_DATA;
+	type->nclass = NODE_CLASS_INPUT;
 	type->width = 140;
 	type->minwidth = 100;
 	type->maxwidth = 320;

Modified: branches/particles-2010/source/blender/nodes/intern/SIM_nodes/SIM_create_mesh_point.c
===================================================================
--- branches/particles-2010/source/blender/nodes/intern/SIM_nodes/SIM_create_mesh_point.c	2010-12-15 08:21:58 UTC (rev 33680)
+++ branches/particles-2010/source/blender/nodes/intern/SIM_nodes/SIM_create_mesh_point.c	2010-12-15 08:42:37 UTC (rev 33681)
@@ -176,7 +176,7 @@
 	type.width = 140;
 	type.minwidth = 100;
 	type.maxwidth = 320;
-	type.nclass = NODE_CLASS_DATA;
+	type.nclass = NODE_CLASS_CONVERTOR;
 	
 	/* optional */
 	type.flag = NODE_OPTIONS;

Modified: branches/particles-2010/source/blender/nodes/intern/SIM_nodes/SIM_debugprint.c
===================================================================
--- branches/particles-2010/source/blender/nodes/intern/SIM_nodes/SIM_debugprint.c	2010-12-15 08:21:58 UTC (rev 33680)
+++ branches/particles-2010/source/blender/nodes/intern/SIM_nodes/SIM_debugprint.c	2010-12-15 08:42:37 UTC (rev 33681)
@@ -51,7 +51,7 @@
 	type.width = 140;
 	type.minwidth = 100;
 	type.maxwidth = 320;
-	type.nclass = NODE_CLASS_DATA;
+	type.nclass = NODE_CLASS_OUTPUT;
 	
 	/* optional */
 //	type.flag = NODE_OPTIONS;

Modified: branches/particles-2010/source/blender/nodes/intern/SIM_nodes/SIM_filter.c
===================================================================
--- branches/particles-2010/source/blender/nodes/intern/SIM_nodes/SIM_filter.c	2010-12-15 08:21:58 UTC (rev 33680)
+++ branches/particles-2010/source/blender/nodes/intern/SIM_nodes/SIM_filter.c	2010-12-15 08:42:37 UTC (rev 33681)
@@ -55,7 +55,7 @@
 	type.width = 140;
 	type.minwidth = 100;
 	type.maxwidth = 320;
-	type.nclass = NODE_CLASS_DATA;
+	type.nclass = NODE_CLASS_CONVERTOR;
 	
 	/* optional */
 	type.inputs = inputs;

Modified: branches/particles-2010/source/blender/nodes/intern/SIM_nodes/SIM_get_data.c
===================================================================
--- branches/particles-2010/source/blender/nodes/intern/SIM_nodes/SIM_get_data.c	2010-12-15 08:21:58 UTC (rev 33680)
+++ branches/particles-2010/source/blender/nodes/intern/SIM_nodes/SIM_get_data.c	2010-12-15 08:42:37 UTC (rev 33681)
@@ -184,6 +184,12 @@
 	}
 	
 	data->type = type;
+	
+	sprintf(node->name, "Get");
+	if (data->type)
+		sprintf(node->name+strlen(node->name), "%s", RNA_struct_ui_name(data->type));
+	sprintf(node->name+strlen(node->name), "Data");
+	nodeUniqueName(ntree, node);
 }
 
 void sim_getdata_foreach_type(struct bNodeTree *ntree, struct bNode *node, void *items, const char *str, SimSearchFunction cb)
@@ -369,7 +375,7 @@
 	type.width = 140;
 	type.minwidth = 100;
 	type.maxwidth = 320;
-	type.nclass = NODE_CLASS_DATA;
+	type.nclass = NODE_CLASS_GETDATA;
 	
 	/* optional */
 	type.flag = NODE_OPTIONS;

Modified: branches/particles-2010/source/blender/nodes/intern/SIM_nodes/SIM_get_mesh_data.c
===================================================================
--- branches/particles-2010/source/blender/nodes/intern/SIM_nodes/SIM_get_mesh_data.c	2010-12-15 08:21:58 UTC (rev 33680)
+++ branches/particles-2010/source/blender/nodes/intern/SIM_nodes/SIM_get_mesh_data.c	2010-12-15 08:42:37 UTC (rev 33681)
@@ -386,7 +386,7 @@
 	type.width = 140;
 	type.minwidth = 100;
 	type.maxwidth = 320;
-	type.nclass = NODE_CLASS_DATA;
+	type.nclass = NODE_CLASS_CONVERTOR;
 	
 	/* optional */
 	type.flag = NODE_OPTIONS;

Modified: branches/particles-2010/source/blender/nodes/intern/SIM_nodes/SIM_index.c
===================================================================
--- branches/particles-2010/source/blender/nodes/intern/SIM_nodes/SIM_index.c	2010-12-15 08:21:58 UTC (rev 33680)
+++ branches/particles-2010/source/blender/nodes/intern/SIM_nodes/SIM_index.c	2010-12-15 08:42:37 UTC (rev 33681)
@@ -77,7 +77,7 @@
 	type.width = 140;
 	type.minwidth = 100;
 	type.maxwidth = 320;
-	type.nclass = NODE_CLASS_DATA;
+	type.nclass = NODE_CLASS_INPUT;
 	
 	/* optional */
 	type.flag = NODE_OPTIONS;

Modified: branches/particles-2010/source/blender/nodes/intern/SIM_nodes/SIM_random.c
===================================================================
--- branches/particles-2010/source/blender/nodes/intern/SIM_nodes/SIM_random.c	2010-12-15 08:21:58 UTC (rev 33680)
+++ branches/particles-2010/source/blender/nodes/intern/SIM_nodes/SIM_random.c	2010-12-15 08:42:37 UTC (rev 33681)
@@ -113,7 +113,7 @@
 	type.width = 140;
 	type.minwidth = 100;
 	type.maxwidth = 320;
-	type.nclass = NODE_CLASS_DATA;
+	type.nclass = NODE_CLASS_INPUT;
 	
 	/* optional */
 	type.flag = NODE_OPTIONS;

Modified: branches/particles-2010/source/blender/nodes/intern/SIM_nodes/SIM_set_data.c
===================================================================
--- branches/particles-2010/source/blender/nodes/intern/SIM_nodes/SIM_set_data.c	2010-12-15 08:21:58 UTC (rev 33680)

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list