Keying Sets - Bugfixes + Auto-Keyframing
authorJoshua Leung <aligorith@gmail.com>
Thu, 8 Oct 2009 06:39:45 +0000 (06:39 +0000)
committerJoshua Leung <aligorith@gmail.com>
Thu, 8 Oct 2009 06:39:45 +0000 (06:39 +0000)
* 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).

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

index 666bbacea5004938eb51f31f6565474f971b1f93..9bd0019bd6c5c7510e252e136a291b242eca2a82 100644 (file)
@@ -473,6 +473,9 @@ class SCENE_PT_keying_sets(SceneButtonsPanel):
                
                scene = context.scene
                
+               row = layout.row()
+               row.itemL(text="Keying Sets")
+               
                row = layout.row()
                
                col = row.column()
@@ -508,6 +511,9 @@ class SCENE_PT_keying_set_paths(SceneButtonsPanel):
                scene = context.scene
                ks = scene.active_keying_set
                
+               row = layout.row()
+               row.itemL(text="Paths")
+               
                row = layout.row()
                
                col = row.column()
index ce8d03d3292000058a70d1cdce1fc390ce08dccb..43c70dac4b1851c819c4194114578a1bf175d08c 100644 (file)
@@ -199,13 +199,16 @@ class USERPREF_PT_edit(bpy.types.Panel):
                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()
index a9a3612b79bf4d8c8841d1fbfc900f8c84841b89..afaa9e3f400674f93ccfae00111999808d0e61a7 100644 (file)
@@ -337,9 +337,16 @@ static int add_keyingset_button_exec (bContext *C, wmOperator *op)
                
                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 @@ KeyingSet *ANIM_builtin_keyingset_get_named (KeyingSet *prevKS, char name[])
        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 */
 
index 2b41cb5c9db41023c5950711ae1eb26c5c7b9283..802ceff1c07531980a09d8b360e08c7bcbe7caef 100644 (file)
@@ -135,6 +135,12 @@ struct KeyingSet *ANIM_builtin_keyingset_get_named(struct KeyingSet *prevKS, cha
 /* 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 */
index ee6871d67bd40c904749a2028bb8e8a791aceb3b..1c170a31c45b59ddd25d2564ed6c62e3aee5b511 100644 (file)
@@ -216,7 +216,7 @@ typedef struct TransData {
        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 {
index d2c1c9f55f0a62879462e3f099dc7ee2e6b41311..a9c3e4676a068fd95018333fedcf6b70e3b3b1ca 100644 (file)
@@ -4242,6 +4242,7 @@ void autokeyframe_ob_cb_func(Scene *scene, View3D *v3d, Object *ob, int tmode)
 
        // 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 @@ void autokeyframe_ob_cb_func(Scene *scene, View3D *v3d, Object *ob, int tmode)
                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 @@ void autokeyframe_pose_cb_func(Scene *scene, View3D *v3d, Object *ob, int tmode,
 
        // 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 @@ void autokeyframe_pose_cb_func(Scene *scene, View3D *v3d, Object *ob, int tmode,
                                /* 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);
index edfc4999d80a49554a899836d0842cbe4355327a..5aa1aa6dfff0b4c392a6e428b9485ec1045e5bc2 100644 (file)
@@ -412,10 +412,12 @@ extern UserDef U; /* from blenkernel blender.c */
 #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)
 
index 1c6bd6515ff680c08758f590232147652315580d..8f999300c718abccf7e177b6633cb221220b8f36 100644 (file)
@@ -1881,10 +1881,14 @@ static void rna_def_userdef_edit(BlenderRNA *brna)
        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);