diff options
author | Joshua Leung <aligorith@gmail.com> | 2016-03-12 17:49:26 +0300 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2016-03-13 08:28:30 +0300 |
commit | 570fbba3f33484111a472a835522d5ec30143a7c (patch) | |
tree | 061c03e275a602490afccefac1ed98a553ba2a9a /source/blender/editors/animation/keyframing.c | |
parent | b10e3cc9973e415189e9f0cdb6af504c41dd9e41 (diff) |
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.
Diffstat (limited to 'source/blender/editors/animation/keyframing.c')
-rw-r--r-- | source/blender/editors/animation/keyframing.c | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c index d376a20d388..8841a05bcd8 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 *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); } |