[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [55981] trunk/blender/source/blender/ makesrna/intern/rna_nodetree.c: Made the update callback in bNodeTree registerable in RNA, this was still missing for pynodes.

Lukas Toenne lukas.toenne at googlemail.com
Fri Apr 12 10:43:09 CEST 2013


Revision: 55981
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=55981
Author:   lukastoenne
Date:     2013-04-12 08:43:08 +0000 (Fri, 12 Apr 2013)
Log Message:
-----------
Made the update callback in bNodeTree registerable in RNA, this was still missing for pynodes. This update callback can be used for "global" updates of the node tree as a whole, as opposed to "local" updates of individual nodes. Any kind of update that takes node connections into account (such as dependency sorting) and does not just work on a single node should be done in the nodetree.update function rather than node.update.

Modified Paths:
--------------
    trunk/blender/source/blender/makesrna/intern/rna_nodetree.c

Modified: trunk/blender/source/blender/makesrna/intern/rna_nodetree.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_nodetree.c	2013-04-12 07:35:49 UTC (rev 55980)
+++ trunk/blender/source/blender/makesrna/intern/rna_nodetree.c	2013-04-12 08:43:08 UTC (rev 55981)
@@ -536,6 +536,23 @@
 	return visible;
 }
 
+static void rna_NodeTree_update_reg(bNodeTree *ntree)
+{
+	extern FunctionRNA rna_NodeTree_update_func;
+
+	PointerRNA ptr;
+	ParameterList list;
+	FunctionRNA *func;
+
+	RNA_id_pointer_create(&ntree->id, &ptr);
+	func = &rna_NodeTree_update_func; /* RNA_struct_find_function(&ptr, "update"); */
+
+	RNA_parameter_list_create(&list, &ptr, func);
+	ntree->typeinfo->ext.call(NULL, &ptr, func, &list);
+
+	RNA_parameter_list_free(&list);
+}
+
 static void rna_NodeTree_draw_add_menu(const bContext *C, struct uiLayout *layout, bNodeTree *ntree)
 {
 	extern FunctionRNA rna_NodeTree_draw_add_menu_func;
@@ -605,7 +622,7 @@
 	bNodeTreeType *nt, dummynt;
 	bNodeTree dummyntree;
 	PointerRNA dummyptr;
-	int have_function[3];
+	int have_function[4];
 
 	/* setup dummy tree & tree type to store static properties in */
 	memset(&dummynt, 0, sizeof(bNodeTreeType));
@@ -644,8 +661,9 @@
 	RNA_def_struct_ui_icon(nt->ext.srna, nt->ui_icon);
 
 	nt->poll = (have_function[0]) ? rna_NodeTree_poll : NULL;
-	nt->draw_add_menu = (have_function[1]) ? rna_NodeTree_draw_add_menu : NULL;
-	nt->get_from_context = (have_function[2]) ? rna_NodeTree_get_from_context : NULL;
+	nt->update = (have_function[1]) ? rna_NodeTree_update_reg : NULL;
+	nt->draw_add_menu = (have_function[2]) ? rna_NodeTree_draw_add_menu : NULL;
+	nt->get_from_context = (have_function[3]) ? rna_NodeTree_get_from_context : NULL;
 
 	ntreeTypeAdd(nt);
 
@@ -6988,6 +7006,11 @@
 	RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL);
 	RNA_def_function_return(func, RNA_def_boolean(func, "visible", FALSE, "", ""));
 
+	/* update */
+	func = RNA_def_function(srna, "update", NULL);
+	RNA_def_function_ui_description(func, "Update on editor changes");
+	RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL | FUNC_ALLOW_WRITE);
+
 	/* draw add menu */
 	func = RNA_def_function(srna, "draw_add_menu", NULL);
 	RNA_def_function_ui_description(func, "Draw the menu for adding nodes");




More information about the Bf-blender-cvs mailing list