diff options
author | Joshua Leung <aligorith@gmail.com> | 2009-12-14 15:09:20 +0300 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2009-12-14 15:09:20 +0300 |
commit | b1a39375e5f57723baeb4004a53219f2ecb1181a (patch) | |
tree | ab45e56a63fc3daa2cac22439082f5f04db56e87 /source/blender/editors/animation/keyingsets.c | |
parent | 96df285ff6658b6e65b9aac3e65c506e11913e2d (diff) |
Keyframing Bugfixes and Feature Requests:
* Added a User-Pref option for the "XYZ to RGB" colour-mode setting for new F-Curves to compliment the one used for Keying Sets. With this option enabled, the builtin Keying Sets also can obey this option.
* Made all places that were previously manually checking the flags for keyframing to use a standard API function to do this now.
* Fixed bug introduced earlier today in commit 25353 by reverting the changes to keyingsets.c. Forgot that delete_keyframe doesn't handle do the "entire array" hack with array_index = -1
* Fixed bug with the insert-keyframe code for the array_index = -1 case, where too many channels were being keyed (i.e. an imaginary channel was often keyed in addition to the valid ones)
Diffstat (limited to 'source/blender/editors/animation/keyingsets.c')
-rw-r--r-- | source/blender/editors/animation/keyingsets.c | 86 |
1 files changed, 62 insertions, 24 deletions
diff --git a/source/blender/editors/animation/keyingsets.c b/source/blender/editors/animation/keyingsets.c index afd693d7981..d5624b8bc5b 100644 --- a/source/blender/editors/animation/keyingsets.c +++ b/source/blender/editors/animation/keyingsets.c @@ -133,11 +133,9 @@ static int add_default_keyingset_exec (bContext *C, wmOperator *op) */ flag |= KEYINGSET_ABSOLUTE; - if (IS_AUTOKEY_FLAG(AUTOMATKEY)) - keyingflag |= INSERTKEY_MATRIX; - if (IS_AUTOKEY_FLAG(INSERTNEEDED)) - keyingflag |= INSERTKEY_NEEDED; - + /* 2nd arg is 0 to indicate that we don't want to include autokeying mode related settings */ + keyingflag = ANIM_get_keyframing_flags(scene, 0); + /* call the API func, and set the active keyingset index */ BKE_keyingset_add(&scene->keyingsets, NULL, flag, keyingflag); @@ -326,6 +324,8 @@ static int add_keyingset_button_exec (bContext *C, wmOperator *op) keyingflag |= INSERTKEY_MATRIX; if (IS_AUTOKEY_FLAG(INSERTNEEDED)) keyingflag |= INSERTKEY_NEEDED; + if (IS_AUTOKEY_FLAG(XYZ2RGB)) + keyingflag |= INSERTKEY_XYZ2RGB; /* call the API func, and set the active keyingset index */ ks= BKE_keyingset_add(&scene->keyingsets, "ButtonKeyingSet", flag, keyingflag); @@ -1305,9 +1305,7 @@ int modify_keyframes (Scene *scene, ListBase *dsources, bAction *act, KeyingSet kflag= ks->keyingflag; /* suppliment with info from the context */ - if (IS_AUTOKEY_FLAG(AUTOMATKEY)) kflag |= INSERTKEY_MATRIX; - if (IS_AUTOKEY_FLAG(INSERTNEEDED)) kflag |= INSERTKEY_NEEDED; - if (IS_AUTOKEY_MODE(scene, EDITKEYS)) kflag |= INSERTKEY_REPLACE; + kflag |= ANIM_get_keyframing_flags(scene, 1); } else if (mode == MODIFYKEY_MODE_DELETE) kflag= 0; @@ -1318,7 +1316,7 @@ int modify_keyframes (Scene *scene, ListBase *dsources, bAction *act, KeyingSet * provided by the user, and is stored, ready to use, in the KeyingSet paths. */ for (ksp= ks->paths.first; ksp; ksp= ksp->next) { - int i; + int arraylen, i; /* get pointer to name of group to add channels to */ if (ksp->groupmode == KSP_GROUP_NONE) @@ -1328,14 +1326,36 @@ int modify_keyframes (Scene *scene, ListBase *dsources, bAction *act, KeyingSet else groupname= ksp->group; - /* passing -1 as the array_index results in the entire array being modified */ - i= (ksp->flag & KSP_FLAG_WHOLE_ARRAY) ? (-1) : (ksp->array_index); + /* init arraylen and i - arraylen should be greater than i so that + * normal non-array entries get keyframed correctly + */ + i= ksp->array_index; + arraylen= i; + + /* get length of array if whole array option is enabled */ + if (ksp->flag & KSP_FLAG_WHOLE_ARRAY) { + PointerRNA id_ptr, ptr; + PropertyRNA *prop; + + RNA_id_pointer_create(ksp->id, &id_ptr); + if (RNA_path_resolve(&id_ptr, ksp->rna_path, &ptr, &prop) && prop) + arraylen= RNA_property_array_length(&ptr, prop); + } + + /* we should do at least one step */ + if (arraylen == i) + arraylen++; - /* action to take depends on mode */ - if (mode == MODIFYKEY_MODE_INSERT) - success += insert_keyframe(ksp->id, act, groupname, ksp->rna_path, i, cfra, kflag); - else if (mode == MODIFYKEY_MODE_DELETE) - success += delete_keyframe(ksp->id, act, groupname, ksp->rna_path, i, cfra, kflag); + /* for each possible index, perform operation + * - assume that arraylen is greater than index + */ + for (; i < arraylen; i++) { + /* action to take depends on mode */ + if (mode == MODIFYKEY_MODE_INSERT) + success += insert_keyframe(ksp->id, act, groupname, ksp->rna_path, i, cfra, kflag); + else if (mode == MODIFYKEY_MODE_DELETE) + success += delete_keyframe(ksp->id, act, groupname, ksp->rna_path, i, cfra, kflag); + } /* set recalc-flags */ if (ksp->id) { @@ -1364,7 +1384,7 @@ int modify_keyframes (Scene *scene, ListBase *dsources, bAction *act, KeyingSet for (ksp= ks->paths.first; ksp; ksp= ksp->next) { DynStr *pathds= BLI_dynstr_new(); char *path = NULL; - int i; + int arraylen, i; /* set initial group name */ if (cks->id == NULL) { @@ -1439,14 +1459,32 @@ int modify_keyframes (Scene *scene, ListBase *dsources, bAction *act, KeyingSet else if (ksp->groupmode == KSP_GROUP_NAMED) groupname= ksp->group; - /* passing -1 as the array_index results in the entire array being modified */ - i= (ksp->flag & KSP_FLAG_WHOLE_ARRAY) ? (-1) : (ksp->array_index); + /* init arraylen and i - arraylen should be greater than i so that + * normal non-array entries get keyframed correctly + */ + i= ksp->array_index; + arraylen= i+1; - /* action to take depends on mode */ - if (mode == MODIFYKEY_MODE_INSERT) - success+= insert_keyframe(cks->id, act, groupname, path, i, cfra, kflag); - else if (mode == MODIFYKEY_MODE_DELETE) - success+= delete_keyframe(cks->id, act, groupname, path, i, cfra, kflag); + /* get length of array if whole array option is enabled */ + if (ksp->flag & KSP_FLAG_WHOLE_ARRAY) { + PointerRNA id_ptr, ptr; + PropertyRNA *prop; + + RNA_id_pointer_create(cks->id, &id_ptr); + if (RNA_path_resolve(&id_ptr, path, &ptr, &prop) && prop) + arraylen= RNA_property_array_length(&ptr, prop); + } + + /* for each possible index, perform operation + * - assume that arraylen is greater than index + */ + for (; i < arraylen; i++) { + /* action to take depends on mode */ + if (mode == MODIFYKEY_MODE_INSERT) + success+= insert_keyframe(cks->id, act, groupname, path, i, cfra, kflag); + else if (mode == MODIFYKEY_MODE_DELETE) + success+= delete_keyframe(cks->id, act, groupname, path, i, cfra, kflag); + } /* free the path */ MEM_freeN(path); |