Keyframing: Added ToolSetting for choosing default keyframe type
authorJoshua Leung <aligorith@gmail.com>
Sat, 12 Mar 2016 14:49:26 +0000 (03:49 +1300)
committerJoshua Leung <aligorith@gmail.com>
Sun, 13 Mar 2016 05:28:30 +0000 (18:28 +1300)
To make it easier for animators working in a multipass pose-to-pose workflow
when inserting breakdown keyframes and so forth, it is now possible to specify
the "type" of keyframe being created (i.e. the colour of the keyframe, when drawn
in the Dope Sheet).

Usage:
1) Choose the type of keyframe ("Keyframe", "Breakdown", "Extreme", etc.) from
   the new dropdown located between the AutoKeying and KeyingSet widgets on the
   timeline header.
2) Insert keyframes
3) Rejoyce that your newly created keyframes have now been coloured for you already
   in the DopeSheet.

Todo:
* Look into a way of using the actual keyframe colours (from the theme) for the icons
  of these types.

17 files changed:
release/scripts/startup/bl_ui/space_time.py
source/blender/editors/animation/anim_channels_defines.c
source/blender/editors/animation/drivers.c
source/blender/editors/animation/keyframes_general.c
source/blender/editors/animation/keyframing.c
source/blender/editors/animation/keyingsets.c
source/blender/editors/gpencil/gpencil_convert.c
source/blender/editors/include/ED_keyframing.h
source/blender/editors/interface/interface_anim.c
source/blender/editors/space_action/action_edit.c
source/blender/editors/space_graph/graph_edit.c
source/blender/editors/space_outliner/outliner_draw.c
source/blender/editors/transform/transform_conversions.c
source/blender/makesdna/DNA_scene_types.h
source/blender/makesrna/intern/rna_fcurve.c
source/blender/makesrna/intern/rna_scene.c
source/blender/python/intern/bpy_rna_anim.c

index 817c28c..0a274c3 100644 (file)
@@ -87,6 +87,8 @@ class TIME_HT_header(Header):
                 subsub = row.row(align=True)
                 subsub.prop(toolsettings, "use_record_with_nla", toggle=True)
 
+        layout.prop(toolsettings, "keyframe_type", icon='SPACE2', text="") # xxx: icon...
+
         row = layout.row(align=True)
         row.prop_search(scene.keying_sets_all, "active", scene, "keying_sets_all", text="")
         row.operator("anim.keyframe_insert", text="", icon='KEY_HLT')
index 95354bc..9d54fd8 100644 (file)
@@ -3874,6 +3874,7 @@ static void achannel_setting_slider_cb(bContext *C, void *id_poin, void *fcu_poi
        
        ReportList *reports = CTX_wm_reports(C);
        Scene *scene = CTX_data_scene(C);
+       ToolSettings *ts = scene->toolsettings;
        PointerRNA id_ptr, ptr;
        PropertyRNA *prop;
        short flag = 0;
@@ -3896,7 +3897,7 @@ static void achannel_setting_slider_cb(bContext *C, void *id_poin, void *fcu_poi
                        flag |= INSERTKEY_REPLACE;
                
                /* insert a keyframe for this F-Curve */
-               done = insert_keyframe_direct(reports, ptr, prop, fcu, cfra, flag);
+               done = insert_keyframe_direct(reports, ptr, prop, fcu, cfra, ts->keyframe_type, flag);
                
                if (done)
                        WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
@@ -3912,6 +3913,7 @@ static void achannel_setting_slider_shapekey_cb(bContext *C, void *key_poin, voi
        
        ReportList *reports = CTX_wm_reports(C);
        Scene *scene = CTX_data_scene(C);
+       ToolSettings *ts = scene->toolsettings;
        PointerRNA id_ptr, ptr;
        PropertyRNA *prop;
        short flag = 0;
@@ -3939,7 +3941,7 @@ static void achannel_setting_slider_shapekey_cb(bContext *C, void *key_poin, voi
                        flag |= INSERTKEY_REPLACE;
                
                /* insert a keyframe for this F-Curve */
-               done = insert_keyframe_direct(reports, ptr, prop, fcu, cfra, flag);
+               done = insert_keyframe_direct(reports, ptr, prop, fcu, cfra, ts->keyframe_type, flag);
                
                if (done)
                        WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
@@ -3962,6 +3964,7 @@ static void achannel_setting_slider_nla_curve_cb(bContext *C, void *UNUSED(id_po
        
        ReportList *reports = CTX_wm_reports(C);
        Scene *scene = CTX_data_scene(C);
+       ToolSettings *ts = scene->toolsettings;
        short flag = 0;
        bool done = false;
        float cfra;
@@ -3981,7 +3984,7 @@ static void achannel_setting_slider_nla_curve_cb(bContext *C, void *UNUSED(id_po
                        flag |= INSERTKEY_REPLACE;
                
                /* insert a keyframe for this F-Curve */
-               done = insert_keyframe_direct(reports, ptr, prop, fcu, cfra, flag);
+               done = insert_keyframe_direct(reports, ptr, prop, fcu, cfra, ts->keyframe_type, flag);
                
                if (done)
                        WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
index b2a34d7..1f77ddc 100644 (file)
@@ -130,8 +130,8 @@ FCurve *verify_driver_fcurve(ID *id, const char rna_path[], const int array_inde
                                 * - These are configured to 0,0 and 1,1 to give a 1-1 mapping
                                 *   which can be easily tweaked from there.
                                 */
-                               insert_vert_fcurve(fcu, 0.0f, 0.0f, INSERTKEY_FAST);
-                               insert_vert_fcurve(fcu, 1.0f, 1.0f, INSERTKEY_FAST);
+                               insert_vert_fcurve(fcu, 0.0f, 0.0f, BEZT_KEYTYPE_KEYFRAME, INSERTKEY_FAST);
+                               insert_vert_fcurve(fcu, 1.0f, 1.0f, BEZT_KEYTYPE_KEYFRAME, INSERTKEY_FAST);
                                
                                /* configure this curve to extrapolate */
                                for (i = 0, bezt = fcu->bezt;  (i < fcu->totvert) && bezt;  i++, bezt++) {
index bd8aa21..9733d92 100644 (file)
@@ -203,7 +203,7 @@ void clean_fcurve(struct bAnimContext *ac, bAnimListElem *ale, float thresh, boo
        
        /* now insert first keyframe, as it should be ok */
        bezt = old_bezts;
-       insert_vert_fcurve(fcu, bezt->vec[1][0], bezt->vec[1][1], 0);
+       insert_vert_fcurve(fcu, bezt->vec[1][0], bezt->vec[1][1], BEZKEYTYPE(bezt), 0);
        if (!(bezt->f2 & SELECT)) {
                lastb = fcu->bezt;
                lastb->f1 = lastb->f2 = lastb->f3 = 0;
@@ -226,13 +226,13 @@ void clean_fcurve(struct bAnimContext *ac, bAnimListElem *ale, float thresh, boo
                }
                lastb = (fcu->bezt + (fcu->totvert - 1));
                bezt = (old_bezts + i);
-
+               
                /* get references for quicker access */
                prev[0] = lastb->vec[1][0]; prev[1] = lastb->vec[1][1];
                cur[0] = bezt->vec[1][0]; cur[1] = bezt->vec[1][1];
-
+               
                if (!(bezt->f2 & SELECT)) {
-                       insert_vert_fcurve(fcu, cur[0], cur[1], 0);
+                       insert_vert_fcurve(fcu, cur[0], cur[1], BEZKEYTYPE(bezt), 0);
                        lastb = (fcu->bezt + (fcu->totvert - 1));
                        lastb->f1 = lastb->f2 = lastb->f3 = 0;
                        continue;
@@ -251,7 +251,7 @@ void clean_fcurve(struct bAnimContext *ac, bAnimListElem *ale, float thresh, boo
                                if (cur[1] > next[1]) {
                                        if (IS_EQT(cur[1], prev[1], thresh) == 0) {
                                                /* add new keyframe */
-                                               insert_vert_fcurve(fcu, cur[0], cur[1], 0);
+                                               insert_vert_fcurve(fcu, cur[0], cur[1], BEZKEYTYPE(bezt), 0);
                                        }
                                }
                        }
@@ -259,7 +259,7 @@ void clean_fcurve(struct bAnimContext *ac, bAnimListElem *ale, float thresh, boo
                                /* only add if values are a considerable distance apart */
                                if (IS_EQT(cur[1], prev[1], thresh) == 0) {
                                        /* add new keyframe */
-                                       insert_vert_fcurve(fcu, cur[0], cur[1], 0);
+                                       insert_vert_fcurve(fcu, cur[0], cur[1], BEZKEYTYPE(bezt), 0);
                                }
                        }
                }
@@ -269,18 +269,18 @@ void clean_fcurve(struct bAnimContext *ac, bAnimListElem *ale, float thresh, boo
                                /* does current have same value as previous and next? */
                                if (IS_EQT(cur[1], prev[1], thresh) == 0) {
                                        /* add new keyframe*/
-                                       insert_vert_fcurve(fcu, cur[0], cur[1], 0);
+                                       insert_vert_fcurve(fcu, cur[0], cur[1], BEZKEYTYPE(bezt), 0);
                                }
                                else if (IS_EQT(cur[1], next[1], thresh) == 0) {
                                        /* add new keyframe */
-                                       insert_vert_fcurve(fcu, cur[0], cur[1], 0);
+                                       insert_vert_fcurve(fcu, cur[0], cur[1], BEZKEYTYPE(bezt), 0);
                                }
                        }
                        else {
                                /* add if value doesn't equal that of previous */
                                if (IS_EQT(cur[1], prev[1], thresh) == 0) {
                                        /* add new keyframe */
-                                       insert_vert_fcurve(fcu, cur[0], cur[1], 0);
+                                       insert_vert_fcurve(fcu, cur[0], cur[1], BEZKEYTYPE(bezt), 0);
                                }
                        }
                }
@@ -436,7 +436,7 @@ void sample_fcurve(FCurve *fcu)
        BezTriple *bezt, *start = NULL, *end = NULL;
        TempFrameValCache *value_cache, *fp;
        int sfra, range;
-       int i, n, nIndex;
+       int i, n;
 
        if (fcu->bezt == NULL) /* ignore baked */
                return;
@@ -467,8 +467,7 @@ void sample_fcurve(FCurve *fcu)
                                        
                                        /* add keyframes with these, tagging as 'breakdowns' */
                                        for (n = 1, fp = value_cache; n < range && fp; n++, fp++) {
-                                               nIndex = insert_vert_fcurve(fcu, fp->frame, fp->val, 1);
-                                               BEZKEYTYPE(fcu->bezt + nIndex) = BEZT_KEYTYPE_BREAKDOWN;
+                                               insert_vert_fcurve(fcu, fp->frame, fp->val, BEZT_KEYTYPE_BREAKDOWN, 1);
                                        }
                                        
                                        /* free temp cache */
index d376a20..8841a05 100644 (file)
@@ -386,8 +386,12 @@ int insert_bezt_fcurve(FCurve *fcu, BezTriple *bezt, short flag)
 /* This function is a wrapper for insert_bezt_fcurve_internal(), and should be used when
  * adding a new keyframe to a curve, when the keyframe doesn't exist anywhere else yet. 
  * It returns the index at which the keyframe was added.
+ *
+ * \param keyframe_type: The type of keyframe (eBezTriple_KeyframeTypes)
+ * \param flag: Optional flags (eInsertKeyFlags) for controlling how keys get added 
+ *              and/or whether updates get done
  */
-int insert_vert_fcurve(FCurve *fcu, float x, float y, short flag)
+int insert_vert_fcurve(FCurve *fcu, float x, float y, char keyframe_type, short flag)
 {
        BezTriple beztr = {{{0}}};
        unsigned int oldTot = fcu->totvert;
@@ -413,9 +417,8 @@ int insert_vert_fcurve(FCurve *fcu, float x, float y, short flag)
                beztr.ipo = BEZT_IPO_BEZ;
        }
        else {
-               /* for UI usage - defaults should come from the */
+               /* for UI usage - defaults should come from the userprefs and/or toolsettings */
                beztr.h1 = beztr.h2 = U.keyhandles_new; /* use default handle type here */
-               //BEZKEYTYPE(&beztr)= scene->keytype; /* default keyframe type */
                
                /* use default interpolation mode, with exceptions for int/discrete values */
                beztr.ipo = U.ipo_new;
@@ -429,6 +432,9 @@ int insert_vert_fcurve(FCurve *fcu, float x, float y, short flag)
                beztr.ipo = BEZT_IPO_LIN;
        }
        
+       /* set keyframe type value (supplied), which should come from the scene settings in most cases */
+       BEZKEYTYPE(&beztr) = keyframe_type;
+       
        /* set default values for "easing" interpolation mode settings
         * NOTE: Even if these modes aren't currently used, if users switch
         *       to these later, we want these to work in a sane way out of
@@ -873,11 +879,13 @@ static float visualkey_get_value(PointerRNA *ptr, PropertyRNA *prop, int array_i
  *  Use this when validation of necessary animation data is not necessary, since an RNA-pointer to the necessary
  *     data being keyframed, and a pointer to the F-Curve to use have both been provided.
  *
+ *  keytype is the "keyframe type" (eBezTriple_KeyframeTypes), as shown in the Dope Sheet.
+ *
  *     The flag argument is used for special settings that alter the behavior of
  *     the keyframe insertion. These include the 'visual' keyframing modes, quick refresh,
  *     and extra keyframe filtering.
  */
-bool insert_keyframe_direct(ReportList *reports, PointerRNA ptr, PropertyRNA *prop, FCurve *fcu, float cfra, short flag)
+bool insert_keyframe_direct(ReportList *reports, PointerRNA ptr, PropertyRNA *prop, FCurve *fcu, float cfra, char keytype, short flag)
 {
        float curval = 0.0f;
        
@@ -946,7 +954,7 @@ bool insert_keyframe_direct(ReportList *reports, PointerRNA ptr, PropertyRNA *pr
                
                /* insert new keyframe at current frame */
                if (insert_mode)
-                       insert_vert_fcurve(fcu, cfra, curval, flag);
+                       insert_vert_fcurve(fcu, cfra, curval, keytype, flag);
                
                /* delete keyframe immediately before/after newly added */
                switch (insert_mode) {
@@ -964,7 +972,7 @@ bool insert_keyframe_direct(ReportList *reports, PointerRNA ptr, PropertyRNA *pr
        }
        else {
                /* just insert keyframe */
-               insert_vert_fcurve(fcu, cfra, curval, flag);
+               insert_vert_fcurve(fcu, cfra, curval, keytype, flag);
                
                /* return success */
                return true;
@@ -983,7 +991,7 @@ bool insert_keyframe_direct(ReportList *reports, PointerRNA ptr, PropertyRNA *pr
  *
  *     index of -1 keys all array indices
  */
-short insert_keyframe(ReportList *reports, ID *id, bAction *act, const char group[], const char rna_path[], int array_index, float cfra, short flag)
+short insert_keyframe(ReportList *reports, ID *id, bAction *act, const char group[], const char rna_path[], int array_index, float cfra, char keytype, short flag)
 {      
        PointerRNA id_ptr, ptr;
        PropertyRNA *prop = NULL;
@@ -1057,7 +1065,7 @@ short insert_keyframe(ReportList *reports, ID *id, bAction *act, const char grou
                        }
                        
                        /* insert keyframe */
-                       ret += insert_keyframe_direct(reports, ptr, prop, fcu, cfra, flag);
+                       ret += insert_keyframe_direct(reports, ptr, prop, fcu, cfra, keytype, flag);
                }
        }
        
@@ -1731,6 +1739,7 @@ void ANIM_OT_keyframe_delete_v3d(wmOperatorType *ot)
 static int insert_key_button_exec(bContext *C, wmOperator *op)
 {
        Scene *scene = CTX_data_scene(C);
+       ToolSettings *ts = scene->toolsettings;
        PointerRNA ptr = {{NULL}};
        PropertyRNA *prop = NULL;
        char *path;
@@ -1755,7 +1764,7 @@ static int insert_key_button_exec(bContext *C, wmOperator *op)
                        NlaStrip *strip = (NlaStrip *)ptr.data;
                        FCurve *fcu = list_find_fcurve(&strip->fcurves, RNA_property_identifier(prop), index);
                        
-                       success = insert_keyframe_direct(op->reports, ptr, prop, fcu, cfra, 0);
+                       success = insert_keyframe_direct(op->reports, ptr, prop, fcu, cfra, ts->keyframe_type, 0);
                }
                else {
                        /* standard properties */
@@ -1767,7 +1776,7 @@ static int insert_key_button_exec(bContext *C, wmOperator *op)
                                        index = -1;
                                }
                                
-                               success = insert_keyframe(op->reports, ptr.id.data, NULL, NULL, path, index, cfra, flag);
+                               success = insert_keyframe(op->reports, ptr.id.data, NULL, NULL, path, index, cfra, ts->keyframe_type, flag);
                                
                                MEM_freeN(path);
                        }
index 4b9a629..060f66f 100644 (file)
@@ -957,6 +957,7 @@ int ANIM_apply_keyingset(bContext *C, ListBase *dsources, bAction *act, KeyingSe
        const short base_kflags = ANIM_get_keyframing_flags(scene, 1);
        short kflag = 0, success = 0;
        const char *groupname = NULL;
+       const char *keytype = scene->toolsettings->keyframe_type;
        
        /* sanity checks */
        if (ks == NULL)
@@ -1028,7 +1029,7 @@ int ANIM_apply_keyingset(bContext *C, ListBase *dsources, bAction *act, KeyingSe
                for (; i < arraylen; i++) {
                        /* action to take depends on mode */
                        if (mode == MODIFYKEY_MODE_INSERT)
-                               success += insert_keyframe(reports, ksp->id, act, groupname, ksp->rna_path, i, cfra, kflag2);
+                               success += insert_keyframe(reports, ksp->id, act, groupname, ksp->rna_path, i, cfra, keytype, kflag2);
                        else if (mode == MODIFYKEY_MODE_DELETE)
                                success += delete_keyframe(reports, ksp->id, act, groupname, ksp->rna_path, i, cfra, kflag2);
                }
index ab02000..c47985e 100644 (file)
@@ -398,7 +398,7 @@ static void gp_stroke_path_animation_add_keyframes(ReportList *reports, PointerR
                                if ((cfra - last_valid_time) < MIN_TIME_DELTA) {
                                        cfra = last_valid_time + MIN_TIME_DELTA;
                                }
-                               insert_keyframe_direct(reports, ptr, prop, fcu, cfra, INSERTKEY_FAST);
+                               insert_keyframe_direct(reports, ptr, prop, fcu, cfra, BEZT_KEYTYPE_KEYFRAME, INSERTKEY_FAST);
                                last_valid_time = cfra;
                        }
                        else if (G.debug & G_DEBUG) {
@@ -410,7 +410,7 @@ static void gp_stroke_path_animation_add_keyframes(ReportList *reports, PointerR
                        if ((cfra - last_valid_time) < MIN_TIME_DELTA) {
                                cfra = last_valid_time + MIN_TIME_DELTA;
                        }
-                       insert_keyframe_direct(reports, ptr, prop, fcu, cfra, INSERTKEY_FAST);
+                       insert_keyframe_direct(reports, ptr, prop, fcu, cfra, BEZT_KEYTYPE_KEYFRAME, INSERTKEY_FAST);
                        last_valid_time = cfra;
                }
                else {
@@ -418,7 +418,7 @@ static void gp_stroke_path_animation_add_keyframes(ReportList *reports, PointerR
                         * and also far enough from (not yet added!) end_stroke keyframe!
                         */
                        if ((cfra - last_valid_time) > MIN_TIME_DELTA && (end_stroke_time - cfra) > MIN_TIME_DELTA) {
-                               insert_keyframe_direct(reports, ptr, prop, fcu, cfra, INSERTKEY_FAST);
+                               insert_keyframe_direct(reports, ptr, prop, fcu, cfra, BEZT_KEYTYPE_BREAKDOWN, INSERTKEY_FAST);
                                last_valid_time = cfra;
                        }
                        else if (G.debug & G_DEBUG) {
@@ -472,7 +472,7 @@ static void gp_stroke_path_animation(bContext *C, ReportList *reports, Curve *cu
                
                cu->ctime = 0.0f;
                cfra = (float)gtd->start_frame;
-               insert_keyframe_direct(reports, ptr, prop, fcu, cfra, INSERTKEY_FAST);
+               insert_keyframe_direct(reports, ptr, prop, fcu, cfra, BEZT_KEYTYPE_KEYFRAME, INSERTKEY_FAST);
                
                cu->ctime = cu->pathlen;
                if (gtd->realtime) {
@@ -481,7 +481,7 @@ static void gp_stroke_path_animation(bContext *C, ReportList *reports, Curve *cu
                else {
                        cfra = (float)gtd->end_frame;
                }
-               insert_keyframe_direct(reports, ptr, prop, fcu, cfra, INSERTKEY_FAST);
+               insert_keyframe_direct(reports, ptr, prop, fcu, cfra, BEZT_KEYTYPE_KEYFRAME, INSERTKEY_FAST);
        }
        else {
                /* Use actual recorded timing! */
index 5d76c9e..3382f45 100644 (file)
@@ -98,7 +98,7 @@ int insert_bezt_fcurve(struct FCurve *fcu, struct BezTriple *bezt, short flag);
  *  already exists. It will insert a keyframe using the current value being keyframed.
  *  Returns the index at which a keyframe was added (or -1 if failed)
  */
-int insert_vert_fcurve(struct FCurve *fcu, float x, float y, short flag);
+int insert_vert_fcurve(struct FCurve *fcu, float x, float y, char keytype, short flag);
 
 /* -------- */
 
@@ -106,7 +106,7 @@ int insert_vert_fcurve(struct FCurve *fcu, float x, float y, short flag);
  *     Use this to insert a keyframe using the current value being keyframed, in the 
  *     nominated F-Curve (no creation of animation data performed). Returns success.
  */
-bool insert_keyframe_direct(struct ReportList *reports, struct PointerRNA ptr, struct PropertyRNA *prop, struct FCurve *fcu, float cfra, short flag);
+bool insert_keyframe_direct(struct ReportList *reports, struct PointerRNA ptr, struct PropertyRNA *prop, struct FCurve *fcu, float cfra, char keytype, short flag);
 
 /* -------- */
 
@@ -114,7 +114,7 @@ bool insert_keyframe_direct(struct ReportList *reports, struct PointerRNA ptr, s
  *     Use this to create any necessary animation data, and then insert a keyframe
  *     using the current value being keyframed, in the relevant place. Returns success.
  */
-short insert_keyframe(struct ReportList *reports, struct ID *id, struct bAction *act, const char group[], const char rna_path[], int array_index, float cfra, short flag);
+short insert_keyframe(struct ReportList *reports, struct ID *id, struct bAction *act, const char group[], const char rna_path[], int array_index, float cfra, char keytype, short flag);
 
 /* Main Keyframing API call: 
  *  Use this to delete keyframe on current frame for relevant channel. Will perform checks just in case.
index 37895a7..178fda0 100644 (file)
@@ -231,13 +231,14 @@ void ui_but_anim_autokey(bContext *C, uiBut *but, Scene *scene, float cfra)
                /* NLA Strip property */
                if (IS_AUTOKEY_ON(scene)) {
                        ReportList *reports = CTX_wm_reports(C);
+                       ToolSettings *ts = scene->toolsettings;
                        PointerRNA ptr = {{NULL}};
                        PropertyRNA *prop = NULL;
                        int index;
                        
                        UI_context_active_but_prop_get(C, &ptr, &prop, &index);
                        
-                       insert_keyframe_direct(reports, ptr, prop, fcu, cfra, 0);
+                       insert_keyframe_direct(reports, ptr, prop, fcu, cfra, ts->keyframe_type, 0);
                        WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
                }
        }
@@ -247,6 +248,7 @@ void ui_but_anim_autokey(bContext *C, uiBut *but, Scene *scene, float cfra)
                /* TODO: this should probably respect the keyingset only option for anim */
                if (autokeyframe_cfra_can_key(scene, id)) {
                        ReportList *reports = CTX_wm_reports(C);
+                       ToolSettings *ts = scene->toolsettings;
                        short flag = ANIM_get_keyframing_flags(scene, 1);
 
                        fcu->flag &= ~FCURVE_SELECTED;
@@ -256,7 +258,7 @@ void ui_but_anim_autokey(bContext *C, uiBut *but, Scene *scene, float cfra)
                         *       E.g., color wheels (see T42567). */
                        BLI_assert((fcu->array_index == but->rnaindex) || (but->rnaindex == -1));
                        insert_keyframe(reports, id, action, ((fcu->grp) ? (fcu->grp->name) : (NULL)),
-                                       fcu->rna_path, but->rnaindex, cfra, flag);
+                                       fcu->rna_path, but->rnaindex, cfra, ts->keyframe_type, flag);
 
                        WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
                }
index e595d5d..c66028b 100644 (file)
@@ -667,6 +667,7 @@ static void insert_action_keys(bAnimContext *ac, short mode)
        
        ReportList *reports = ac->reports;
        Scene *scene = ac->scene;
+       ToolSettings *ts = scene->toolsettings;
        short flag = 0;
        
        /* filter data */
@@ -698,9 +699,9 @@ static void insert_action_keys(bAnimContext *ac, short mode)
                 *                       (TODO: add the full-blown PointerRNA relative parsing case here...)
                 */
                if (ale->id && !ale->owner)
-                       insert_keyframe(reports, ale->id, NULL, ((fcu->grp) ? (fcu->grp->name) : (NULL)), fcu->rna_path, fcu->array_index, cfra, flag);
+                       insert_keyframe(reports, ale->id, NULL, ((fcu->grp) ? (fcu->grp->name) : (NULL)), fcu->rna_path, fcu->array_index, cfra, ts->keyframe_type, flag);
                else
-                       insert_vert_fcurve(fcu, cfra, fcu->curval, 0);
+                       insert_vert_fcurve(fcu, cfra, fcu->curval, ts->keyframe_type, 0);
                
                ale->update |= ANIM_UPDATE_DEFAULT;
        }
index 9653a2c..10baed8 100644 (file)
@@ -522,6 +522,7 @@ static void insert_graph_keys(bAnimContext *ac, eGraphKeys_InsertKey_Types mode)
        ReportList *reports = ac->reports;
        SpaceIpo *sipo = (SpaceIpo *)ac->sl;
        Scene *scene = ac->scene;
+       ToolSettings *ts = scene->toolsettings;
        short flag = 0;
        
        /* filter data */
@@ -574,7 +575,7 @@ static void insert_graph_keys(bAnimContext *ac, eGraphKeys_InsertKey_Types mode)
                                y = 0.0f;
                                
                        /* insert keyframe directly into the F-Curve */
-                       insert_vert_fcurve(fcu, x, y, 0);
+                       insert_vert_fcurve(fcu, x, y, ts->keyframe_type, 0);
                        
                        ale->update |= ANIM_UPDATE_DEFAULT;
                }
@@ -602,9 +603,9 @@ static void insert_graph_keys(bAnimContext *ac, eGraphKeys_InsertKey_Types mode)
                         *                        up adding the keyframes on a new F-Curve in the action data instead.
                         */
                        if (ale->id && !ale->owner && !fcu->driver)
-                               insert_keyframe(reports, ale->id, NULL, ((fcu->grp) ? (fcu->grp->name) : (NULL)), fcu->rna_path, fcu->array_index, cfra, flag);
+                               insert_keyframe(reports, ale->id, NULL, ((fcu->grp) ? (fcu->grp->name) : (NULL)), fcu->rna_path, fcu->array_index, cfra, ts->keyframe_type, flag);
                        else
-                               insert_vert_fcurve(fcu, cfra, fcu->curval, 0);
+                               insert_vert_fcurve(fcu, cfra, fcu->curval, ts->keyframe_type, 0);
                        
                        ale->update |= ANIM_UPDATE_DEFAULT;
                }
@@ -683,9 +684,11 @@ static int graphkeys_click_insert_exec(bContext *C, wmOperator *op)
         */
        if (fcurve_is_keyframable(fcu)) {
                ListBase anim_data;
-
+               ToolSettings *ts = ac.scene->toolsettings;
+               
                short mapping_flag = ANIM_get_normalization_flags(&ac);
                float scale, offset;
+               
                /* get frame and value from props */
                frame = RNA_float_get(op->ptr, "frame");
                val = RNA_float_get(op->ptr, "value");
@@ -696,11 +699,11 @@ static int graphkeys_click_insert_exec(bContext *C, wmOperator *op)
                
                /* apply inverse unit-mapping to value to get correct value for F-Curves */
                scale = ANIM_unit_mapping_get_factor(ac.scene, ale->id, fcu, mapping_flag | ANIM_UNITCONV_RESTORE, &offset);
-
+               
                val = val * scale - offset;
-
+               
                /* insert keyframe on the specified frame + value */
-               insert_vert_fcurve(fcu, frame, val, 0);
+               insert_vert_fcurve(fcu, frame, val, ts->keyframe_type, 0);
                
                ale->update |= ANIM_UPDATE_DEPS;
                
index cc86aa8..b624c7c 100644 (file)
@@ -208,11 +208,12 @@ static void restrictbutton_recursive_child(bContext *C, Scene *scene, Object *ob
                                        id = ptr.id.data;
                                        if (autokeyframe_cfra_can_key(scene, id)) {
                                                ReportList *reports = CTX_wm_reports(C);
+                                               ToolSettings *ts = scene->toolsettings;
                                                eInsertKeyFlags key_flag = ANIM_get_keyframing_flags(scene, 1);
 
                                                fcu->flag &= ~FCURVE_SELECTED;
                                                insert_keyframe(reports, id, action, ((fcu->grp) ? (fcu->grp->name) : (NULL)),
-                                                               fcu->rna_path, fcu->array_index, CFRA, key_flag);
+                                                               fcu->rna_path, fcu->array_index, CFRA, ts->keyframe_type, key_flag);
                                                /* Assuming this is not necessary here, since 'ancestor' object button will do it anyway. */
                                                /* WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); */
                                        }
index 03e3fa0..d52db8c 100644 (file)
@@ -5521,6 +5521,7 @@ void autokeyframe_ob_cb_func(bContext *C, Scene *scene, View3D *v3d, Object *ob,
        // TODO: this should probably be done per channel instead...
        if (autokeyframe_cfra_can_key(scene, id)) {
                ReportList *reports = CTX_wm_reports(C);
+               ToolSettings *ts = scene->toolsettings;
                KeyingSet *active_ks = ANIM_scene_get_active_keyingset(scene);
                ListBase dsources = {NULL, NULL};
                float cfra = (float)CFRA; // xxx this will do for now
@@ -5547,7 +5548,8 @@ void autokeyframe_ob_cb_func(bContext *C, Scene *scene, View3D *v3d, Object *ob,
                                        fcu->flag &= ~FCURVE_SELECTED;
                                        insert_keyframe(reports, id, adt->action,
                                                        (fcu->grp ? fcu->grp->name : NULL),
-                                                       fcu->rna_path, fcu->array_index, cfra, flag);
+                                                       fcu->rna_path, fcu->array_index, cfra, 
+                                                       ts->keyframe_type, flag);
                                }
                        }
                }
@@ -5639,6 +5641,7 @@ void autokeyframe_pose_cb_func(bContext *C, Scene *scene, View3D *v3d, Object *o
        // TODO: this should probably be done per channel instead...
        if (autokeyframe_cfra_can_key(scene, id)) {
                ReportList *reports = CTX_wm_reports(C);
+               ToolSettings *ts = scene->toolsettings;
                KeyingSet *active_ks = ANIM_scene_get_active_keyingset(scene);
                float cfra = (float)CFRA;
                short flag = 0;
@@ -5679,9 +5682,13 @@ void autokeyframe_pose_cb_func(bContext *C, Scene *scene, View3D *v3d, Object *o
                                                                /* only if bone name matches too... 
                                                                 * NOTE: this will do constraints too, but those are ok to do here too?
                                                                 */
-                                                               if (pchanName && STREQ(pchanName, pchan->name)) 
-                                                                       insert_keyframe(reports, id, act, ((fcu->grp) ? (fcu->grp->name) : (NULL)), fcu->rna_path, fcu->array_index, cfra, flag);
-                                                                       
+                                                               if (pchanName && STREQ(pchanName, pchan->name)) {
+                                                                       insert_keyframe(reports, id, act, 
+                                                                                       ((fcu->grp) ? (fcu->grp->name) : (NULL)),
+                                                                                       fcu->rna_path, fcu->array_index, cfra,
+                                                                                       ts->keyframe_type, flag);
+                                                               }
+                                                               
                                                                if (pchanName) MEM_freeN(pchanName);
                                                        }
                                                }
index c4f0395..fd37bde 100644 (file)
@@ -1342,10 +1342,10 @@ typedef struct ToolSettings {
 
        /* Auto-Keying Mode */
        short autokey_mode, autokey_flag;       /* defines in DNA_userdef_types.h */
+       char keyframe_type;                 /* keyframe type (see DNA_curve_types.h) */
 
        /* Multires */
        char multires_subdiv_type;
-       char pad3[1];
 
        /* Skeleton generation */
        short skgen_resolution;
index 398c9aa..8005075 100644 (file)
@@ -740,9 +740,9 @@ static void rna_FModifierStepped_end_frame_range(PointerRNA *ptr, float *min, fl
        *max = MAXFRAMEF;
 }
 
-static BezTriple *rna_FKeyframe_points_insert(FCurve *fcu, float frame, float value, int flag)
+static BezTriple *rna_FKeyframe_points_insert(FCurve *fcu, float frame, float value, char keyframe_type, int flag)
 {
-       int index = insert_vert_fcurve(fcu, frame, value, flag | INSERTKEY_NO_USERPREF);
+       int index = insert_vert_fcurve(fcu, frame, value, keyframe_type, flag | INSERTKEY_NO_USERPREF);
        return ((fcu->bezt) && (index >= 0)) ? (fcu->bezt + index) : NULL;
 }
 
@@ -1777,7 +1777,9 @@ static void rna_def_fcurve_keyframe_points(BlenderRNA *brna, PropertyRNA *cprop)
        parm = RNA_def_float(func, "value", 0.0f, -FLT_MAX, FLT_MAX, "",
                             "Y Value of this keyframe point", -FLT_MAX, FLT_MAX);
        RNA_def_property_flag(parm, PROP_REQUIRED);
-
+       
+       RNA_def_enum(func, "keyframe_type", rna_enum_beztriple_keyframe_type_items, 0, "", 
+                    "Type of keyframe to insert");
        RNA_def_enum_flag(func, "options", keyframe_flag_items, 0, "", "Keyframe options");
 
        parm = RNA_def_pointer(func, "keyframe", "Keyframe", "", "Newly created keyframe");
index 412c0bc..8c9fe9a 100644 (file)
@@ -2379,6 +2379,12 @@ static void rna_def_tool_settings(BlenderRNA  *brna)
                                 "Automatic keyframe insertion using active Keying Set only");
        RNA_def_property_ui_icon(prop, ICON_KEYINGSET, 0);
        
+       /* Keyframing */
+       prop = RNA_def_property(srna, "keyframe_type", PROP_ENUM, PROP_NONE);
+       RNA_def_property_enum_sdna(prop, NULL, "keyframe_type");
+       RNA_def_property_enum_items(prop, rna_enum_beztriple_keyframe_type_items);
+       RNA_def_property_ui_text(prop, "Keyframe Type", "Type of keyframes to create");
+       
        /* UV */
        prop = RNA_def_property(srna, "uv_select_mode", PROP_ENUM, PROP_NONE);
        RNA_def_property_enum_sdna(prop, NULL, "uv_selectmode");
index 63bfdc6..e74a518 100644 (file)
@@ -211,6 +211,7 @@ PyObject *pyrna_struct_keyframe_insert(BPy_StructRNA *self, PyObject *args, PyOb
        int index = -1;
        float cfra = FLT_MAX;
        const char *group_name = NULL;
+       char keytype = BEZT_KEYTYPE_KEYFRAME; /* XXX: Expose this as a one-off option... */
        int options = 0;
 
        PYRNA_STRUCT_CHECK_OBJ(self);
@@ -227,7 +228,7 @@ PyObject *pyrna_struct_keyframe_insert(BPy_StructRNA *self, PyObject *args, PyOb
 
                BKE_reports_init(&reports, RPT_STORE);
 
-               result = insert_keyframe(&reports, (ID *)self->ptr.id.data, NULL, group_name, path_full, index, cfra, options);
+               result = insert_keyframe(&reports, (ID *)self->ptr.id.data, NULL, group_name, path_full, index, cfra, keytype, options);
                MEM_freeN((void *)path_full);
 
                if (BPy_reports_to_error(&reports, PyExc_RuntimeError, true) == -1)