diff options
Diffstat (limited to 'source/blender/editors/animation/keyingsets.c')
-rw-r--r-- | source/blender/editors/animation/keyingsets.c | 80 |
1 files changed, 52 insertions, 28 deletions
diff --git a/source/blender/editors/animation/keyingsets.c b/source/blender/editors/animation/keyingsets.c index c525c9af626..dcd1c3abbde 100644 --- a/source/blender/editors/animation/keyingsets.c +++ b/source/blender/editors/animation/keyingsets.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or @@ -224,6 +222,7 @@ static int add_empty_ks_path_exec (bContext *C, wmOperator *op) ksp->groupmode= KSP_GROUP_KSNAME; // XXX? ksp->idtype= ID_OB; + ksp->flag= KSP_FLAG_WHOLE_ARRAY; return OPERATOR_FINISHED; } @@ -782,19 +781,19 @@ void ANIM_keying_sets_menu_setup (bContext *C, const char title[], const char op * - these are listed in the order in which they were defined for the active scene */ if (scene->keyingsets.first) { - for (ks= scene->keyingsets.first; ks; ks= ks->next) { + for (ks= scene->keyingsets.first; ks; ks=ks->next, i++) { if (ANIM_keyingset_context_ok_poll(C, ks)) - uiItemIntO(layout, ks->name, ICON_NONE, op_name, "type", i++); + uiItemIntO(layout, ks->name, ICON_NONE, op_name, "type", i); } uiItemS(layout); } /* builtin Keying Sets */ i= -1; - for (ks= builtin_keyingsets.first; ks; ks= ks->next) { + for (ks= builtin_keyingsets.first; ks; ks=ks->next, i--) { /* only show KeyingSet if context is suitable */ if (ANIM_keyingset_context_ok_poll(C, ks)) - uiItemEnumO_value(layout, ks->name, ICON_NONE, op_name, "type", i--); + uiItemEnumO_value(layout, ks->name, ICON_NONE, op_name, "type", i); } uiPupMenuEnd(C, pup); @@ -876,33 +875,19 @@ void ANIM_relative_keyingset_add_source (ListBase *dsources, ID *id, StructRNA * /* KeyingSet Operations (Insert/Delete Keyframes) ------------ */ -/* Given a KeyingSet and context info (if required), modify keyframes for the channels specified - * by the KeyingSet. This takes into account many of the different combinations of using KeyingSets. - * Returns the number of channels that keyframes were added to +/* Given a KeyingSet and context info, validate Keying Set's paths. + * This is only really necessary with relative/built-in KeyingSets + * where their list of paths is dynamically generated based on the + * current context info. + * + * Returns 0 if succeeded, otherwise an error code: eModifyKey_Returns */ -int ANIM_apply_keyingset (bContext *C, ListBase *dsources, bAction *act, KeyingSet *ks, short mode, float cfra) +short ANIM_validate_keyingset (bContext *C, ListBase *dsources, KeyingSet *ks) { - Scene *scene= CTX_data_scene(C); - ReportList *reports = CTX_wm_reports(C); - KS_Path *ksp; - int kflag=0, success= 0; - char *groupname= NULL; - - /* sanity checks */ + /* sanity check */ if (ks == NULL) return 0; - /* get flags to use */ - if (mode == MODIFYKEY_MODE_INSERT) { - /* use KeyingSet's flags as base */ - kflag= ks->keyingflag; - - /* suppliment with info from the context */ - kflag |= ANIM_get_keyframing_flags(scene, 1); - } - else if (mode == MODIFYKEY_MODE_DELETE) - kflag= 0; - /* if relative Keying Sets, poll and build up the paths */ if ((ks->flag & KEYINGSET_ABSOLUTE) == 0) { KeyingSetInfo *ksi = ANIM_keyingset_info_find_named(ks->typeinfo); @@ -937,6 +922,45 @@ int ANIM_apply_keyingset (bContext *C, ListBase *dsources, bAction *act, KeyingS } } + /* succeeded; return 0 to tag error free */ + return 0; +} + +/* Given a KeyingSet and context info (if required), modify keyframes for the channels specified + * by the KeyingSet. This takes into account many of the different combinations of using KeyingSets. + * Returns the number of channels that keyframes were added to + */ +int ANIM_apply_keyingset (bContext *C, ListBase *dsources, bAction *act, KeyingSet *ks, short mode, float cfra) +{ + Scene *scene= CTX_data_scene(C); + ReportList *reports = CTX_wm_reports(C); + KS_Path *ksp; + int kflag=0, success= 0; + char *groupname= NULL; + + /* sanity checks */ + if (ks == NULL) + return 0; + + /* get flags to use */ + if (mode == MODIFYKEY_MODE_INSERT) { + /* use KeyingSet's flags as base */ + kflag= ks->keyingflag; + + /* suppliment with info from the context */ + kflag |= ANIM_get_keyframing_flags(scene, 1); + } + else if (mode == MODIFYKEY_MODE_DELETE) + kflag= 0; + + /* if relative Keying Sets, poll and build up the paths */ + success = ANIM_validate_keyingset(C, dsources, ks); + + if (success != 0) { + /* return error code if failed */ + return success; + } + /* apply the paths as specified in the KeyingSet now */ for (ksp= ks->paths.first; ksp; ksp= ksp->next) { int arraylen, i; |