[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [26088] trunk/blender/source/blender: Timeline: Keyframe Drawing for All Selected Objects

Joshua Leung aligorith at gmail.com
Tue Jan 19 00:31:46 CET 2010


Revision: 26088
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=26088
Author:   aligorith
Date:     2010-01-19 00:31:46 +0100 (Tue, 19 Jan 2010)

Log Message:
-----------
Timeline: Keyframe Drawing for All Selected Objects

When 'Only Selected' is ON, or the Active Object is in PoseMode, only the keyframes for the active Object are drawn (*).

Otherwise, the keyframes for the scene (sequence+nodes+world), and the selected Objects (including the Active Object) are drawn.


(*) I've also made some changes here to try and get only the selected bones showing here, but some further changes are still needed for that to be able to work.

---

Also, fixed bug in makesrna caused by missing newlines for error prints. This resulted in all error-output from makesrna appearing on a single line.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/space_time/space_time.c
    trunk/blender/source/blender/makesrna/intern/makesrna.c
    trunk/blender/source/blender/makesrna/intern/rna_space.c

Modified: trunk/blender/source/blender/editors/space_time/space_time.c
===================================================================
--- trunk/blender/source/blender/editors/space_time/space_time.c	2010-01-18 22:21:32 UTC (rev 26087)
+++ trunk/blender/source/blender/editors/space_time/space_time.c	2010-01-18 23:31:46 UTC (rev 26088)
@@ -113,21 +113,28 @@
 }
 
 /* helper for time_draw_keyframes() */
-static void time_draw_idblock_keyframes(View2D *v2d, ID *id)
+static void time_draw_idblock_keyframes(View2D *v2d, ID *id, short onlysel)
 {
+	bDopeSheet ads;
 	DLRBT_Tree keys;
 	ActKeyColumn *ak;
 	
 	/* init binarytree-list for getting keyframes */
 	BLI_dlrbTree_init(&keys);
 	
+	/* init dopesheet settings */
+	// FIXME: the ob_to_keylist function currently doesn't take this into account...
+	memset(&ads, 0, sizeof(bDopeSheet));
+	if (onlysel)
+		ads.filterflag |= ADS_FILTER_ONLYSEL;
+	
 	/* populate tree with keyframe nodes */
 	switch (GS(id->name)) {
 		case ID_SCE:
-			scene_to_keylist(NULL, (Scene *)id, &keys, NULL);
+			scene_to_keylist(&ads, (Scene *)id, &keys, NULL);
 			break;
 		case ID_OB:
-			ob_to_keylist(NULL, (Object *)id, &keys, NULL);
+			ob_to_keylist(&ads, (Object *)id, &keys, NULL);
 			break;
 	}
 		
@@ -159,22 +166,48 @@
 	Scene *scene= CTX_data_scene(C);
 	Object *ob= CTX_data_active_object(C);
 	View2D *v2d= &ar->v2d;
+	short onlysel= (stime->flag & TIME_ONLYACTSEL);
 	
 	/* draw scene keyframes first 
-	 *	- only if we're not only showing the 
+	 *	- don't try to do this when only drawing active/selected data keyframes,
+	 *	  since this can become quite slow
 	 */
-	if ((scene) && (stime->flag & TIME_ONLYACTSEL)==0) {
+	if (scene && onlysel==0) {
 		/* set draw color */
 		glColor3ub(0xDD, 0xA7, 0x00);
-		time_draw_idblock_keyframes(v2d, (ID *)scene);
+		time_draw_idblock_keyframes(v2d, (ID *)scene, onlysel);
 	}
 	
-	/* draw active object's keyframes */
-	if (ob) {
-		/* set draw color */
-		glColor3ub(0xDD, 0xD7, 0x00);
-		time_draw_idblock_keyframes(v2d, (ID *)ob);
+	/* draw keyframes from selected objects 
+	 *	- only do the active object if in posemode (i.e. showing only keyframes for the bones)
+	 *	  OR the onlysel flag was set, which means that only active object's keyframes should
+	 *	  be considered
+	 */
+	glColor3ub(0xDD, 0xD7, 0x00);
+	
+	if (ob && ((ob->mode == OB_MODE_POSE) || onlysel)) {
+		/* draw keyframes for active object only */
+		time_draw_idblock_keyframes(v2d, (ID *)ob, onlysel);
 	}
+	else {
+		short active_done = 0;
+		
+		/* draw keyframes from all selected objects */
+		CTX_DATA_BEGIN(C, Object*, obsel, selected_objects) 
+		{
+			/* last arg is 0, since onlysel doesn't apply here... */
+			time_draw_idblock_keyframes(v2d, (ID *)obsel, 0);
+			
+			/* if this object is the active one, set flag so that we don't draw again */
+			if (obsel == ob)
+				active_done= 1;
+		}
+		CTX_DATA_END;
+		
+		/* if active object hasn't been done yet, draw it... */
+		if (ob && (active_done == 0))
+			time_draw_idblock_keyframes(v2d, (ID *)ob, 0);
+	}
 }
 
 /* ---------------- */

Modified: trunk/blender/source/blender/makesrna/intern/makesrna.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/makesrna.c	2010-01-18 22:21:32 UTC (rev 26087)
+++ trunk/blender/source/blender/makesrna/intern/makesrna.c	2010-01-18 23:31:46 UTC (rev 26088)
@@ -52,7 +52,7 @@
 
 #define REN_IF_DIFF \
 	if(rename(tmpfile, orgfile) != 0) { \
-		fprintf(stderr, "%s:%d, rename error: \"%s\" -> \"%s\"", __FILE__, __LINE__, tmpfile, orgfile); \
+		fprintf(stderr, "%s:%d, rename error: \"%s\" -> \"%s\"\n", __FILE__, __LINE__, tmpfile, orgfile); \
 		return -1; \
 	} \
 	remove(tmpfile); \
@@ -79,7 +79,7 @@
 
 	if(fp_new==NULL) {
 		/* shouldn't happen, just to be safe */
-		fprintf(stderr, "%s:%d, open error: \"%s\"", __FILE__, __LINE__, tmpfile);
+		fprintf(stderr, "%s:%d, open error: \"%s\"\n", __FILE__, __LINE__, tmpfile);
 		return -1;
 	}
 

Modified: trunk/blender/source/blender/makesrna/intern/rna_space.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_space.c	2010-01-18 22:21:32 UTC (rev 26087)
+++ trunk/blender/source/blender/makesrna/intern/rna_space.c	2010-01-18 23:31:46 UTC (rev 26088)
@@ -1517,7 +1517,7 @@
 	/* Other options */	
 	prop= RNA_def_property(srna, "only_selected", PROP_BOOLEAN, PROP_NONE);
 	RNA_def_property_boolean_sdna(prop, NULL, "flag", TIME_ONLYACTSEL);
-	RNA_def_property_ui_text(prop, "Only Selected channels", "Show keyframes only from active/selected channels.");	
+	RNA_def_property_ui_text(prop, "Only Selected channels", "Show keyframes for active Object and/or its selected channels only.");	
 	RNA_def_property_update(prop, NC_SPACE|ND_SPACE_TIME, NULL);
 	
 	prop= RNA_def_property(srna, "show_cframe_indicator", PROP_BOOLEAN, PROP_NONE);





More information about the Bf-blender-cvs mailing list