Commit: 570fbba3f33484111a472a835522d5ec30143a7c
Author: Joshua Leung
Date:   Sun Mar 13 03:49:26 2016 +1300
Branches: master
https://developer.blender.org/rB570fbba3f33484111a472a835522d5ec30143a7c

Keyframing: Added ToolSetting for choosing default keyframe type

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.

===================================================================

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

===================================================================

diff --git a/release/scripts/startup/bl_ui/space_time.py 
b/release/scripts/startup/bl_ui/space_time.py
index 817c28c..0a274c3 100644
--- a/release/scripts/startup/bl_ui/space_time.py
+++ b/release/scripts/startup/bl_ui/space_time.py
@@ -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')
diff --git a/source/blender/editors/animation/anim_channels_defines.c 
b/source/blender/editors/animation/anim_channels_defines.c
index 95354bc..9d54fd8 100644
--- a/source/blender/editors/animation/anim_channels_defines.c
+++ b/source/blender/editors/animation/anim_channels_defines.c
@@ -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);
diff --git a/source/blender/editors/animation/drivers.c 
b/source/blender/editors/animation/drivers.c
index b2a34d7..1f77ddc 100644
--- a/source/blender/editors/animation/drivers.c
+++ b/source/blender/editors/animation/drivers.c
@@ -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++) {
diff --git a/source/blender/editors/animation/keyframes_general.c 
b/source/blender/editors/animation/keyframes_general.c
index bd8aa21..9733d92 100644
--- a/source/blender/editors/animation/keyframes_general.c
+++ b/source/blender/editors/animation/keyframes_general.c
@@ -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 */
diff --git a/source/blender/editors/animation/keyframing.c 
b/source/blender/editors/animation/keyframing.c
index d376a20..8841a05 100644
--- a/source/blender/editors/animation/keyframing.c
+++ b/source/blender/editors/animation/keyframing.c
@@ -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 *repor

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to