[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [23704] trunk/blender: Keying Sets - Bugfixes + Auto-Keyframing

Joshua Leung aligorith at gmail.com
Thu Oct 8 08:39:45 CEST 2009


Revision: 23704
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=23704
Author:   aligorith
Date:     2009-10-08 08:39:45 +0200 (Thu, 08 Oct 2009)

Log Message:
-----------
Keying Sets - Bugfixes + Auto-Keyframing

* Added a new option for Auto-Keyframing which makes it only insert keyframes for the items included in the active Keying Set. 
This only works for Transform Auto-Keyframing so far (other tools will get it added later). The option is disabled by default.

* Fixed bug where adding an 'entire' array to some KeyingSet would only start from the index of the button that the mouse was over at the time

* Made some UI tweaks for Keying Sets buttons (still heaps of missing options there). 

Modified Paths:
--------------
    trunk/blender/release/scripts/ui/buttons_scene.py
    trunk/blender/release/scripts/ui/space_userpref.py
    trunk/blender/source/blender/editors/animation/keyingsets.c
    trunk/blender/source/blender/editors/include/ED_keyframing.h
    trunk/blender/source/blender/editors/transform/transform.h
    trunk/blender/source/blender/editors/transform/transform_conversions.c
    trunk/blender/source/blender/makesdna/DNA_userdef_types.h
    trunk/blender/source/blender/makesrna/intern/rna_userdef.c

Modified: trunk/blender/release/scripts/ui/buttons_scene.py
===================================================================
--- trunk/blender/release/scripts/ui/buttons_scene.py	2009-10-08 06:32:07 UTC (rev 23703)
+++ trunk/blender/release/scripts/ui/buttons_scene.py	2009-10-08 06:39:45 UTC (rev 23704)
@@ -474,7 +474,10 @@
 		scene = context.scene
 		
 		row = layout.row()
+		row.itemL(text="Keying Sets")
 		
+		row = layout.row()
+		
 		col = row.column()
 		col.template_list(scene, "keying_sets", scene, "active_keying_set_index", rows=2)
 		
@@ -509,7 +512,10 @@
 		ks = scene.active_keying_set
 		
 		row = layout.row()
+		row.itemL(text="Paths")
 		
+		row = layout.row()
+		
 		col = row.column()
 		col.template_list(ks, "paths", ks, "active_path_index", rows=2)
 		

Modified: trunk/blender/release/scripts/ui/space_userpref.py
===================================================================
--- trunk/blender/release/scripts/ui/space_userpref.py	2009-10-08 06:32:07 UTC (rev 23703)
+++ trunk/blender/release/scripts/ui/space_userpref.py	2009-10-08 06:39:45 UTC (rev 23704)
@@ -199,13 +199,16 @@
 		sub1 = sub.column()
 		sub1.itemL(text="Keyframing:")
 		sub1.itemR(edit, "use_visual_keying")
-		sub1.itemR(edit, "auto_keyframe_insert_available", text="Only Insert Available")
-		sub1.itemR(edit, "auto_keyframe_insert_needed", text="Only Insert Needed")
+		sub1.itemR(edit, "keyframe_insert_needed", text="Only Insert Needed")
 		sub1.itemS()
 		sub1.itemL(text="New F-Curve Defaults:")
 		sub1.itemR(edit, "new_interpolation_type", text="Interpolation")
 		sub1.itemS()
-		sub1.itemR(edit, "auto_keying_enable", text="Auto Keyframing")
+		sub1.itemR(edit, "auto_keying_enable", text="Auto Keyframing:")
+		sub2 = sub1.column()
+		sub2.active = edit.auto_keying_enable
+		sub2.itemR(edit, "auto_keyframe_insert_keyingset", text="Only Insert for Keying Set")
+		sub2.itemR(edit, "auto_keyframe_insert_available", text="Only Insert Available")
 		
 		sub1.itemS()
 		sub1.itemS()

Modified: trunk/blender/source/blender/editors/animation/keyingsets.c
===================================================================
--- trunk/blender/source/blender/editors/animation/keyingsets.c	2009-10-08 06:32:07 UTC (rev 23703)
+++ trunk/blender/source/blender/editors/animation/keyingsets.c	2009-10-08 06:39:45 UTC (rev 23704)
@@ -337,9 +337,16 @@
 		
 		if (path) {
 			/* set flags */
-			if (all) 
+			if (all) {
 				pflag |= KSP_FLAG_WHOLE_ARRAY;
 				
+				/* we need to set the index for this to 0, even though it may break in some cases, this is 
+				 * necessary if we want the entire array for most cases to get included without the user
+				 * having to worry about where they clicked
+				 */
+				index= 0;
+			}
+				
 			/* add path to this setting */
 			BKE_keyingset_add_destination(ks, ptr.id.data, NULL, path, index, pflag, KSP_GROUP_KSNAME);
 			success= 1;
@@ -1109,6 +1116,24 @@
 	return NULL;
 }
 
+
+/* Get the active Keying Set for the Scene provided */
+KeyingSet *ANIM_scene_get_active_keyingset (Scene *scene)
+{
+	if (ELEM(NULL, scene, scene->keyingsets.first))
+		return NULL;
+	
+	/* currently, there are several possibilities here:
+	 *	-   0: no active keying set
+	 *	- > 0: one of the user-defined Keying Sets, but indices start from 0 (hence the -1)
+	 *	- < 0: a builtin keying set (XXX this isn't enabled yet so that we don't get errors on reading back files)
+	 */
+	if (scene->active_keyingset > 0)
+		return BLI_findlink(&scene->keyingsets, scene->active_keyingset-1);
+	else // for now...
+		return NULL; 
+}
+
 /* ******************************************* */
 /* KEYFRAME MODIFICATION */
 

Modified: trunk/blender/source/blender/editors/include/ED_keyframing.h
===================================================================
--- trunk/blender/source/blender/editors/include/ED_keyframing.h	2009-10-08 06:32:07 UTC (rev 23703)
+++ trunk/blender/source/blender/editors/include/ED_keyframing.h	2009-10-08 06:39:45 UTC (rev 23704)
@@ -135,6 +135,12 @@
 /* Initialise builtin KeyingSets on startup */
 void init_builtin_keyingsets(void);
 
+
+/* -------- */
+
+/* Get the active KeyingSet for the given scene */
+struct KeyingSet *ANIM_scene_get_active_keyingset(struct Scene *scene);
+
 /* ************ Drivers ********************** */
 
 /* Returns whether there is a driver in the copy/paste buffer to paste */

Modified: trunk/blender/source/blender/editors/transform/transform.h
===================================================================
--- trunk/blender/source/blender/editors/transform/transform.h	2009-10-08 06:32:07 UTC (rev 23703)
+++ trunk/blender/source/blender/editors/transform/transform.h	2009-10-08 06:39:45 UTC (rev 23704)
@@ -216,7 +216,7 @@
 	void  *extra;		 /* extra data (mirrored element pointer, in editmode mesh to EditVert) (editbone for roll fixing) (...) */
     short  flag;         /* Various flags */
 	short  protectflag;	 /* If set, copy of Object or PoseChannel protection */
-	int    rotOrder;	/* rotation order (for eulers), as defined in BLI_arithb.h */
+	int    rotOrder;	/* rotation mode,  as defined in eRotationModes (DNA_action_types.h) */
 } TransData;
 
 typedef struct MouseInput {

Modified: trunk/blender/source/blender/editors/transform/transform_conversions.c
===================================================================
--- trunk/blender/source/blender/editors/transform/transform_conversions.c	2009-10-08 06:32:07 UTC (rev 23703)
+++ trunk/blender/source/blender/editors/transform/transform_conversions.c	2009-10-08 06:39:45 UTC (rev 23704)
@@ -4242,6 +4242,7 @@
 
 	// TODO: this should probably be done per channel instead...
 	if (autokeyframe_cfra_can_key(scene, id)) {
+		KeyingSet *active_ks = ANIM_scene_get_active_keyingset(scene);
 		bCommonKeySrc cks;
 		ListBase dsources = {&cks, &cks};
 		float cfra= (float)CFRA; // xxx this will do for now
@@ -4258,7 +4259,12 @@
 		if (IS_AUTOKEY_MODE(scene, EDITKEYS))
 			flag |= INSERTKEY_REPLACE;
 			
-		if (IS_AUTOKEY_FLAG(INSERTAVAIL)) {
+		
+		if (IS_AUTOKEY_FLAG(ONLYKEYINGSET) && (active_ks)) {
+			/* only insert into active keyingset */
+			modify_keyframes(scene, &dsources, NULL, active_ks, MODIFYKEY_MODE_INSERT, cfra);
+		}
+		else if (IS_AUTOKEY_FLAG(INSERTAVAIL)) {
 			AnimData *adt= ob->adt;
 			
 			/* only key on available channels */
@@ -4337,6 +4343,7 @@
 
 	// TODO: this should probably be done per channel instead...
 	if (autokeyframe_cfra_can_key(scene, id)) {
+		KeyingSet *active_ks = ANIM_scene_get_active_keyingset(scene);
 		bCommonKeySrc cks;
 		ListBase dsources = {&cks, &cks};
 		float cfra= (float)CFRA;
@@ -4363,8 +4370,14 @@
 				/* clear any 'unkeyed' flag it may have */
 				pchan->bone->flag &= ~BONE_UNKEYED;
 				
+				/* only insert into active keyingset? */
+				if (IS_AUTOKEY_FLAG(ONLYKEYINGSET) && (active_ks)) {
+					/* init cks for this PoseChannel, then use the relative KeyingSets to keyframe it */
+					cks.pchan= pchan;
+					modify_keyframes(scene, &dsources, NULL, active_ks, MODIFYKEY_MODE_INSERT, cfra);
+				}
 				/* only insert into available channels? */
-				if (IS_AUTOKEY_FLAG(INSERTAVAIL)) {
+				else if (IS_AUTOKEY_FLAG(INSERTAVAIL)) {
 					if (act) {
 						for (fcu= act->curves.first; fcu; fcu= fcu->next)
 							insert_keyframe(id, act, ((fcu->grp)?(fcu->grp->name):(NULL)), fcu->rna_path, fcu->array_index, cfra, flag);

Modified: trunk/blender/source/blender/makesdna/DNA_userdef_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_userdef_types.h	2009-10-08 06:32:07 UTC (rev 23703)
+++ trunk/blender/source/blender/makesdna/DNA_userdef_types.h	2009-10-08 06:39:45 UTC (rev 23704)
@@ -412,10 +412,12 @@
 #define		AUTOKEY_MODE_EDITKEYS	5
 
 /* Auto-Keying flag */
-	/* U.autokey_flag */
+	/* U.autokey_flag (not strictly used when autokeying only - is also used when keyframing these days) */
 #define		AUTOKEY_FLAG_INSERTAVAIL	(1<<0)
 #define		AUTOKEY_FLAG_INSERTNEEDED	(1<<1)
 #define		AUTOKEY_FLAG_AUTOMATKEY		(1<<2)
+	/* U.autokey_flag (strictly autokeying only) */
+#define 	AUTOKEY_FLAG_ONLYKEYINGSET	(1<<6)
 	/* toolsettings->autokey_flag */
 #define 	ANIMRECORD_FLAG_WITHNLA		(1<<10)
 

Modified: trunk/blender/source/blender/makesrna/intern/rna_userdef.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_userdef.c	2009-10-08 06:32:07 UTC (rev 23703)
+++ trunk/blender/source/blender/makesrna/intern/rna_userdef.c	2009-10-08 06:39:45 UTC (rev 23704)
@@ -1881,10 +1881,14 @@
 	prop= RNA_def_property(srna, "auto_keyframe_insert_available", PROP_BOOLEAN, PROP_NONE);
 	RNA_def_property_boolean_sdna(prop, NULL, "autokey_flag", AUTOKEY_FLAG_INSERTAVAIL);
 	RNA_def_property_ui_text(prop, "Auto Keyframe Insert Available", "Automatic keyframe insertion in available curves.");
-
-	prop= RNA_def_property(srna, "auto_keyframe_insert_needed", PROP_BOOLEAN, PROP_NONE);
+	
+	prop= RNA_def_property(srna, "auto_keyframe_insert_keyingset", PROP_BOOLEAN, PROP_NONE);
+	RNA_def_property_boolean_sdna(prop, NULL, "autokey_flag", AUTOKEY_FLAG_ONLYKEYINGSET);
+	RNA_def_property_ui_text(prop, "Auto Keyframe Insert Keying Set", "Automatic keyframe insertion using active Keying Set.");
+	
+	prop= RNA_def_property(srna, "keyframe_insert_needed", PROP_BOOLEAN, PROP_NONE);
 	RNA_def_property_boolean_sdna(prop, NULL, "autokey_flag", AUTOKEY_FLAG_INSERTNEEDED);
-	RNA_def_property_ui_text(prop, "Auto Keyframe Insert Needed", "Automatic keyframe insertion only when keyframe needed.");
+	RNA_def_property_ui_text(prop, "Keyframe Insert Needed", "Keyframe insertion only when keyframe needed.");
 
 	prop= RNA_def_property(srna, "use_visual_keying", PROP_BOOLEAN, PROP_NONE);
 	RNA_def_property_boolean_sdna(prop, NULL, "autokey_flag", AUTOKEY_FLAG_AUTOMATKEY);





More information about the Bf-blender-cvs mailing list