[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [29446] trunk/blender: - option for redraw timer to playback the animation

Campbell Barton ideasman42 at gmail.com
Mon Jun 14 12:33:26 CEST 2010


Revision: 29446
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=29446
Author:   campbellbarton
Date:     2010-06-14 12:33:26 +0200 (Mon, 14 Jun 2010)

Log Message:
-----------
- option for redraw timer to playback the animation
- py utility property group.users_dupli_group

Modified Paths:
--------------
    trunk/blender/release/scripts/modules/bpy_types.py
    trunk/blender/source/blender/makesrna/RNA_access.h
    trunk/blender/source/blender/makesrna/intern/rna_access.c
    trunk/blender/source/blender/windowmanager/intern/wm_operators.c

Modified: trunk/blender/release/scripts/modules/bpy_types.py
===================================================================
--- trunk/blender/release/scripts/modules/bpy_types.py	2010-06-14 10:22:52 UTC (rev 29445)
+++ trunk/blender/release/scripts/modules/bpy_types.py	2010-06-14 10:33:26 UTC (rev 29446)
@@ -79,10 +79,10 @@
     __slots__ = ()
 
     @property
-    def users_dupli_object(self):
-        """The dupli group this group is used in, XXX, TODO, WHY DOESNT THIS WORK???"""
+    def users_dupli_group(self):
+        """The dupli group this group is used in"""
         import bpy
-        return tuple(obj for obj in bpy.data.objects if self == obj.dupli_object)
+        return tuple(obj for obj in bpy.data.objects if self == obj.dupli_group)
 
 
 class Object(bpy_types.ID):

Modified: trunk/blender/source/blender/makesrna/RNA_access.h
===================================================================
--- trunk/blender/source/blender/makesrna/RNA_access.h	2010-06-14 10:22:52 UTC (rev 29445)
+++ trunk/blender/source/blender/makesrna/RNA_access.h	2010-06-14 10:33:26 UTC (rev 29446)
@@ -661,6 +661,7 @@
 int RNA_enum_identifier(EnumPropertyItem *item, const int value, const char **identifier);
 int RNA_enum_bitflag_identifiers(EnumPropertyItem *item, const int value, const char **identifier);
 int RNA_enum_name(EnumPropertyItem *item, const int value, const char **name);
+int RNA_enum_description(EnumPropertyItem *item, const int value, const char **description);
 
 void RNA_property_enum_items(struct bContext *C, PointerRNA *ptr, PropertyRNA *prop, EnumPropertyItem **item, int *totitem, int *free);
 int RNA_property_enum_value(struct bContext *C, PointerRNA *ptr, PropertyRNA *prop, const char *identifier, int *value);

Modified: trunk/blender/source/blender/makesrna/intern/rna_access.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_access.c	2010-06-14 10:22:52 UTC (rev 29445)
+++ trunk/blender/source/blender/makesrna/intern/rna_access.c	2010-06-14 10:33:26 UTC (rev 29446)
@@ -1086,6 +1086,17 @@
 	return 0;
 }
 
+int RNA_enum_description(EnumPropertyItem *item, const int value, const char **description)
+{
+	for (; item->identifier; item++) {
+		if(item->identifier[0] && item->value==value) {
+			*description = item->description;
+			return 1;
+		}
+	}
+	return 0;
+}
+
 int RNA_property_enum_identifier(bContext *C, PointerRNA *ptr, PropertyRNA *prop, const int value, const char **identifier)
 {	
 	EnumPropertyItem *item= NULL;

Modified: trunk/blender/source/blender/windowmanager/intern/wm_operators.c
===================================================================
--- trunk/blender/source/blender/windowmanager/intern/wm_operators.c	2010-06-14 10:22:52 UTC (rev 29445)
+++ trunk/blender/source/blender/windowmanager/intern/wm_operators.c	2010-06-14 10:33:26 UTC (rev 29446)
@@ -2818,6 +2818,28 @@
 
 /* uses no type defines, fully local testing function anyway... ;) */
 
+static void redraw_timer_window_swap(bContext *C)
+{
+	wmWindow *win= CTX_wm_window(C);
+	ScrArea *sa;
+
+	for(sa= CTX_wm_screen(C)->areabase.first; sa; sa= sa->next)
+		ED_area_tag_redraw(sa);
+	wm_draw_update(C);
+
+	CTX_wm_window_set(C, win);	/* XXX context manipulation warning! */
+}
+
+static EnumPropertyItem redraw_timer_type_items[] = {
+	{0, "DRAW", 0, "Draw Region", "Draw Region"},
+	{1, "DRAW_SWAP", 0, "Draw Region + Swap", "Draw Region and Swap"},
+	{2, "DRAW_WIN", 0, "Draw Window", "Draw Window"},
+	{3, "DRAW_WIN_SWAP", 0, "Draw Window + Swap", "Draw Window and Swap"},
+	{4, "ANIM_STEP", 0, "Anim Step", "Animation Steps"},
+	{5, "ANIM_PLAY", 0, "Anim Play", "Animation Playback"},
+	{6, "UNDO", 0, "Undo/Redo", "Undo/Redo"},
+	{0, NULL, 0, NULL, NULL}};
+
 static int redraw_timer_exec(bContext *C, wmOperator *op)
 {
 	ARegion *ar= CTX_wm_region(C);
@@ -2826,7 +2848,7 @@
 	int iter = RNA_int_get(op->ptr, "iterations");
 	int a;
 	float time;
-	char *infostr= "";
+	const char *infostr= "";
 	
 	WM_cursor_wait(1);
 
@@ -2867,14 +2889,7 @@
 			CTX_wm_region_set(C, ar_back);
 		}
 		else if (type==3) {
-			wmWindow *win= CTX_wm_window(C);
-			ScrArea *sa;
-
-			for(sa= CTX_wm_screen(C)->areabase.first; sa; sa= sa->next)
-				ED_area_tag_redraw(sa);
-			wm_draw_update(C);
-			
-			CTX_wm_window_set(C, win);	/* XXX context manipulation warning! */
+			redraw_timer_window_swap(C);
 		}
 		else if (type==4) {
 			Scene *scene= CTX_data_scene(C);
@@ -2883,23 +2898,34 @@
 			else scene->r.cfra++;
 			scene_update_for_newframe(scene, scene->lay);
 		}
-		else {
+		else if (type==5) {
+
+			/* play anim, return on same frame as started with */
+			Scene *scene= CTX_data_scene(C);
+			int tot= (scene->r.efra - scene->r.sfra) + 1;
+
+			while(tot--) {
+				/* todo, ability to escape! */
+				scene->r.cfra++;
+				if(scene->r.cfra > scene->r.efra)
+					scene->r.cfra= scene->r.sfra;
+
+				scene_update_for_newframe(scene, scene->lay);
+				redraw_timer_window_swap(C);
+			}
+		}
+		else { /* 6 */
 			ED_undo_pop(C);
 			ED_undo_redo(C);
 		}
 	}
 	
 	time= ((PIL_check_seconds_timer()-stime)*1000);
-	
-	if(type==0) infostr= "Draw Region";
-	if(type==1) infostr= "Draw Region and Swap";
-	if(type==2) infostr= "Draw Window";
-	if(type==3) infostr= "Draw Window and Swap";
-	if(type==4) infostr= "Animation Steps";
-	if(type==5) infostr= "Undo/Redo";
-	
+
+	RNA_enum_description(redraw_timer_type_items, type, &infostr);
+
 	WM_cursor_wait(0);
-	
+
 	BKE_reportf(op->reports, RPT_WARNING, "%d x %s: %.2f ms,  average: %.4f", iter, infostr, time, time/iter);
 	
 	return OPERATOR_FINISHED;
@@ -2907,24 +2933,15 @@
 
 static void WM_OT_redraw_timer(wmOperatorType *ot)
 {
-	static EnumPropertyItem prop_type_items[] = {
-	{0, "DRAW", 0, "Draw Region", ""},
-	{1, "DRAW_SWAP", 0, "Draw Region + Swap", ""},
-	{2, "DRAW_WIN", 0, "Draw Window", ""},
-	{3, "DRAW_WIN_SWAP", 0, "Draw Window + Swap", ""},
-	{4, "ANIM_STEP", 0, "Anim Step", ""},
-	{5, "UNDO", 0, "Undo/Redo", ""},
-	{0, NULL, 0, NULL, NULL}};
-	
 	ot->name= "Redraw Timer";
 	ot->idname= "WM_OT_redraw_timer";
 	ot->description="Simple redraw timer to test the speed of updating the interface";
-	
+
 	ot->invoke= WM_menu_invoke;
 	ot->exec= redraw_timer_exec;
 	ot->poll= WM_operator_winactive;
-	
-	ot->prop= RNA_def_enum(ot->srna, "type", prop_type_items, 0, "Type", "");
+
+	ot->prop= RNA_def_enum(ot->srna, "type", redraw_timer_type_items, 0, "Type", "");
 	RNA_def_int(ot->srna, "iterations", 10, 1,INT_MAX, "Iterations", "Number of times to redraw", 1,1000);
 
 }





More information about the Bf-blender-cvs mailing list