[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [34029] trunk/blender: rna/api

Campbell Barton ideasman42 at gmail.com
Mon Jan 3 10:09:30 CET 2011


Revision: 34029
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=34029
Author:   campbellbarton
Date:     2011-01-03 10:09:30 +0100 (Mon, 03 Jan 2011)

Log Message:
-----------
rna/api
move Object.update(...) to ID.update(). since depsgraph update function can now be called on ID types.

also changed how update flags work.

  obj.update(scene, 1, 1, 1)
... is now
  obj.update({'OBJECT', 'DATA', 'TIME'})

Don't pass scene anymore. This was used for recalculating text but I think this is better dont in a different function.

Modified Paths:
--------------
    trunk/blender/release/scripts/op/io_scene_fbx/export_fbx.py
    trunk/blender/source/blender/blenkernel/intern/depsgraph.c
    trunk/blender/source/blender/makesrna/intern/rna_ID.c
    trunk/blender/source/blender/makesrna/intern/rna_object_api.c

Modified: trunk/blender/release/scripts/op/io_scene_fbx/export_fbx.py
===================================================================
--- trunk/blender/release/scripts/op/io_scene_fbx/export_fbx.py	2011-01-03 08:28:22 UTC (rev 34028)
+++ trunk/blender/release/scripts/op/io_scene_fbx/export_fbx.py	2011-01-03 09:09:30 UTC (rev 34029)
@@ -1907,7 +1907,7 @@
         if ob_arms_orig_rest:
             for ob_base in bpy.data.objects:
                 if ob_base.type == 'ARMATURE':
-                    ob_base.update(scene)
+                    ob_base.update()
 
             # This causes the makeDisplayList command to effect the mesh
             scene.frame_set(scene.frame_current)
@@ -2055,7 +2055,7 @@
         if ob_arms_orig_rest:
             for ob_base in bpy.data.objects:
                 if ob_base.type == 'ARMATURE':
-                    ob_base.update(scene)
+                    ob_base.update()
             # This causes the makeDisplayList command to effect the mesh
             scene.frame_set(scene.frame_current)
 

Modified: trunk/blender/source/blender/blenkernel/intern/depsgraph.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/depsgraph.c	2011-01-03 08:28:22 UTC (rev 34028)
+++ trunk/blender/source/blender/blenkernel/intern/depsgraph.c	2011-01-03 09:09:30 UTC (rev 34029)
@@ -2463,6 +2463,9 @@
 				}
 			}
 		}
+		else {
+			BKE_assert(!"invalid flag for this 'idtype'");
+		}
 	}
 }
 

Modified: trunk/blender/source/blender/makesrna/intern/rna_ID.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_ID.c	2011-01-03 08:28:22 UTC (rev 34028)
+++ trunk/blender/source/blender/makesrna/intern/rna_ID.c	2011-01-03 09:09:30 UTC (rev 34029)
@@ -30,6 +30,7 @@
 
 #include "DNA_ID.h"
 #include "DNA_vfont_types.h"
+#include "DNA_object_types.h"
 
 #include "WM_types.h"
 
@@ -73,6 +74,7 @@
 #include "BKE_library.h"
 #include "BKE_animsys.h"
 #include "BKE_material.h"
+#include "BKE_depsgraph.h"
 
 /* name functions that ignore the first two ID characters */
 void rna_ID_name_get(PointerRNA *ptr, char *value)
@@ -248,6 +250,43 @@
 	return NULL;
 }
 
+static void rna_ID_update(ID *id, ReportList *reports, int flag)
+{
+	/* XXX, new function for this! */
+	/*if (ob->type == OB_FONT) {
+		Curve *cu = ob->data;
+		freedisplist(&cu->disp);
+		BKE_text_to_curve(sce, ob, CU_LEFT);
+	}*/
+
+	if(flag == 0) {
+		/* pass */
+	}
+	else {
+		/* ensure flag us correct for the type */
+		switch(GS(id->name)) {
+		case ID_OB:
+			if(flag & ~(OB_RECALC_ALL)) {
+				BKE_report(reports, RPT_ERROR, "'refresh' incompatible with Object ID type");
+				return;
+			}
+			break;
+		/* Could add particle updates later */
+/*		case ID_PA:
+			if(flag & ~(OB_RECALC_ALL|PSYS_RECALC)) {
+				BKE_report(reports, RPT_ERROR, "'refresh' incompatible with ParticleSettings ID type");
+				return;
+			}
+			break; */
+		default:
+			BKE_report(reports, RPT_ERROR, "This ID type is not compatible with any 'refresh' options");
+			return;
+		}
+	}
+
+	DAG_id_tag_update(id, flag);
+}
+
 void rna_ID_user_clear(ID *id)
 {
 	id->us= 0; /* dont save */
@@ -382,6 +421,12 @@
 	FunctionRNA *func;
 	PropertyRNA *prop, *parm;
 
+	static EnumPropertyItem update_flag_items[] = {
+		{OB_RECALC_OB, "OBJECT", 0, "Object", ""},
+		{OB_RECALC_DATA, "DATA", 0, "Data", ""},
+		{OB_RECALC_TIME, "TIME", 0, "Time", ""},
+		{0, NULL, 0, NULL, NULL}};
+
 	srna= RNA_def_struct(brna, "ID", NULL);
 	RNA_def_struct_ui_text(srna, "ID", "Base type for datablocks, defining a unique name, linking from other libraries and garbage collection");
 	RNA_def_struct_flag(srna, STRUCT_ID|STRUCT_ID_REFCOUNT);
@@ -433,6 +478,11 @@
 	func= RNA_def_function(srna, "animation_data_clear", "BKE_free_animdata");
 	RNA_def_function_ui_description(func, "Clear animation on this this ID.");
 
+	func= RNA_def_function(srna, "update", "rna_ID_update");
+	RNA_def_function_flag(func, FUNC_USE_REPORTS);
+	RNA_def_function_ui_description(func, "Tag the id to update its display data.");
+	parm= RNA_def_enum(func, "refresh", update_flag_items, 0, "", "Type of updates to perform.");
+	RNA_def_property_flag(parm, PROP_ENUM_FLAG);
 }
 
 static void rna_def_library(BlenderRNA *brna)

Modified: trunk/blender/source/blender/makesrna/intern/rna_object_api.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_object_api.c	2011-01-03 08:28:22 UTC (rev 34028)
+++ trunk/blender/source/blender/makesrna/intern/rna_object_api.c	2011-01-03 09:09:30 UTC (rev 34029)
@@ -262,25 +262,6 @@
 	}
 }
 
-/* copied from old API Object.makeDisplayList (Object.c)
- * use _ suffix because this exists for internal rna */
-static void rna_Object_update(Object *ob, Scene *sce, int object, int data, int time)
-{
-	int flag= 0;
-
-	if (ob->type == OB_FONT) {
-		Curve *cu = ob->data;
-		freedisplist(&cu->disp);
-		BKE_text_to_curve(sce, ob, CU_LEFT);
-	}
-
-	if(object) flag |= OB_RECALC_OB;
-	if(data) flag |= OB_RECALC_DATA;
-	if(time) flag |= OB_RECALC_TIME;
-
-	DAG_id_tag_update(&ob->id, flag);
-}
-
 static PointerRNA rna_Object_shape_key_add(Object *ob, bContext *C, ReportList *reports, const char *name, int from_mix)
 {
 	Scene *scene= CTX_data_scene(C);
@@ -462,16 +443,6 @@
 	parm= RNA_def_int(func, "index", 0, 0, 0, "", "The face index, -1 when no intersection is found.", 0, 0);
 	RNA_def_function_output(func, parm);
 
-	
-	/* DAG */
-	func= RNA_def_function(srna, "update", "rna_Object_update");
-	RNA_def_function_ui_description(func, "Tag the object to update its display data.");
-	parm= RNA_def_pointer(func, "scene", "Scene", "", "");
-	RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL);
-	RNA_def_boolean(func, "object", 1, "", "Tag the object for updating");
-	RNA_def_boolean(func, "data", 1, "", "Tag the objects display data for updating");
-	RNA_def_boolean(func, "time", 1, "", "Tag the object time related data for updating");
-
 	/* View */
 	func= RNA_def_function(srna, "is_visible", "rna_Object_is_visible");
 	RNA_def_function_ui_description(func, "Determine if object is visible in a given scene.");





More information about the Bf-blender-cvs mailing list