Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Leung <aligorith@gmail.com>2011-06-30 17:56:47 +0400
committerJoshua Leung <aligorith@gmail.com>2011-06-30 17:56:47 +0400
commita6270b0204b2a9424eaa51d475aa761d77f43a69 (patch)
tree92467389c658f50240228583f4d708a68467a243 /source/blender/editors/animation/keyframes_edit.c
parent2a85eff40cba602cb07aeb43c1af672ce2945bbb (diff)
Animation Channels Filtering Refactor - Part 5
Channels can now be used as "animation containers" to be filtered further to obtain a set of subsidiary channels (i.e. F-Curves associated with some summary channel). The main use of this is that object and scene summary channels can now be defined without defining the filtering logic in three different places - once for channel filtering, once for drawing keyframes in action editor, and once for editing these keyframes. An indirect consequence of this, is that the "Only selected channels" option in Timeline will now result in only the keyframes for a selected bones getting shown (when enabled), instead of all keyframes for the active object. This was requested by Lee during Durian, and is something which has only become possible as a result of this commit.
Diffstat (limited to 'source/blender/editors/animation/keyframes_edit.c')
-rw-r--r--source/blender/editors/animation/keyframes_edit.c211
1 files changed, 68 insertions, 143 deletions
diff --git a/source/blender/editors/animation/keyframes_edit.c b/source/blender/editors/animation/keyframes_edit.c
index ca8d1c232fa..a0b1b4a6ede 100644
--- a/source/blender/editors/animation/keyframes_edit.c
+++ b/source/blender/editors/animation/keyframes_edit.c
@@ -224,169 +224,94 @@ static short adt_keyframes_loop(KeyframeEditData *ked, AnimData *adt, KeyframeEd
}
/* This function is used to loop over the keyframe data in an Object */
-static short ob_keyframes_loop(KeyframeEditData *ked, Object *ob, KeyframeEditFunc key_ok, KeyframeEditFunc key_cb, FcuEditFunc fcu_cb, int filterflag)
+static short ob_keyframes_loop(KeyframeEditData *ked, bDopeSheet *ads, Object *ob, KeyframeEditFunc key_ok, KeyframeEditFunc key_cb, FcuEditFunc fcu_cb)
{
- Key *key= ob_get_key(ob);
+ bAnimContext ac = {NULL};
+ ListBase anim_data = {NULL, NULL};
+ bAnimListElem *ale;
+ int filter;
+ int ret=0;
+
+ bAnimListElem dummychan = {0};
+ Base dummybase = {0};
- /* sanity check */
if (ob == NULL)
return 0;
- /* firstly, Object's own AnimData */
- if (ob->adt) {
- if (adt_keyframes_loop(ked, ob->adt, key_ok, key_cb, fcu_cb, filterflag))
- return 1;
- }
+ /* create a dummy wrapper data to work with */
+ dummybase.object = ob;
- /* shapekeys */
- if ((key && key->adt) && !(filterflag & ADS_FILTER_NOSHAPEKEYS)) {
- if (adt_keyframes_loop(ked, key->adt, key_ok, key_cb, fcu_cb, filterflag))
- return 1;
- }
-
- /* Add material keyframes */
- if ((ob->totcol) && !(filterflag & ADS_FILTER_NOMAT)) {
- int a;
-
- for (a=1; a <= ob->totcol; a++) {
- Material *ma= give_current_material(ob, a);
-
- /* there might not be a material */
- if (ELEM(NULL, ma, ma->adt))
- continue;
-
- /* add material's data */
- if (adt_keyframes_loop(ked, ma->adt, key_ok, key_cb, fcu_cb, filterflag))
- return 1;
- }
- }
+ dummychan.type = ANIMTYPE_OBJECT;
+ dummychan.data = &dummybase;
+ dummychan.id = &ob->id;
+ dummychan.adt = ob->adt;
- /* Add object data keyframes */
- switch (ob->type) {
- case OB_CAMERA: /* ------- Camera ------------ */
- {
- Camera *ca= (Camera *)ob->data;
-
- if ((ca->adt) && !(filterflag & ADS_FILTER_NOCAM)) {
- if (adt_keyframes_loop(ked, ca->adt, key_ok, key_cb, fcu_cb, filterflag))
- return 1;
- }
- }
- break;
- case OB_LAMP: /* ---------- Lamp ----------- */
- {
- Lamp *la= (Lamp *)ob->data;
-
- if ((la->adt) && !(filterflag & ADS_FILTER_NOLAM)) {
- if (adt_keyframes_loop(ked, la->adt, key_ok, key_cb, fcu_cb, filterflag))
- return 1;
- }
- }
- break;
- case OB_CURVE: /* ------- Curve ---------- */
- case OB_SURF: /* ------- Nurbs Surface ---------- */
- case OB_FONT: /* ------- Text Curve ---------- */
- {
- Curve *cu= (Curve *)ob->data;
-
- if ((cu->adt) && !(filterflag & ADS_FILTER_NOCUR)) {
- if (adt_keyframes_loop(ked, cu->adt, key_ok, key_cb, fcu_cb, filterflag))
- return 1;
- }
- }
- break;
- case OB_MBALL: /* ------- MetaBall ---------- */
- {
- MetaBall *mb= (MetaBall *)ob->data;
-
- if ((mb->adt) && !(filterflag & ADS_FILTER_NOMBA)) {
- if (adt_keyframes_loop(ked, mb->adt, key_ok, key_cb, fcu_cb, filterflag))
- return 1;
- }
- }
- break;
- case OB_ARMATURE: /* ------- Armature ---------- */
- {
- bArmature *arm= (bArmature *)ob->data;
-
- if ((arm->adt) && !(filterflag & ADS_FILTER_NOARM)) {
- if (adt_keyframes_loop(ked, arm->adt, key_ok, key_cb, fcu_cb, filterflag))
- return 1;
- }
- }
- break;
- case OB_MESH: /* ------- Mesh ---------- */
- {
- Mesh *me= (Mesh *)ob->data;
-
- if ((me->adt) && !(filterflag & ADS_FILTER_NOMESH)) {
- if (adt_keyframes_loop(ked, me->adt, key_ok, key_cb, fcu_cb, filterflag))
- return 1;
- }
- }
+ ac.ads = ads;
+ ac.data = &dummychan;
+ ac.datatype = ANIMCONT_CHANNEL;
+
+ /* get F-Curves to take keyframes from */
+ filter= ANIMFILTER_DATA_VISIBLE; // curves only
+ ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
+
+ /* loop through each F-Curve, applying the operation as required, but stopping on the first one */
+ for (ale= anim_data.first; ale; ale= ale->next) {
+ if (ANIM_fcurve_keyframes_loop(ked, (FCurve*)ale->data, key_ok, key_cb, fcu_cb)) {
+ ret = 1;
break;
- case OB_LATTICE: /* ---- Lattice ------ */
- {
- Lattice *lt= (Lattice *)ob->data;
-
- if ((lt->adt) && !(filterflag & ADS_FILTER_NOLAT)) {
- if (adt_keyframes_loop(ked, lt->adt, key_ok, key_cb, fcu_cb, filterflag))
- return 1;
- }
}
- break;
}
- /* Add Particle System Keyframes */
- if ((ob->particlesystem.first) && !(filterflag & ADS_FILTER_NOPART)) {
- ParticleSystem *psys = ob->particlesystem.first;
-
- for(; psys; psys=psys->next) {
- if (ELEM(NULL, psys->part, psys->part->adt))
- continue;
-
- if (adt_keyframes_loop(ked, psys->part->adt, key_ok, key_cb, fcu_cb, filterflag))
- return 1;
- }
- }
+ BLI_freelistN(&anim_data);
- return 0;
+ /* return return code - defaults to zero if nothing happened */
+ return ret;
}
/* This function is used to loop over the keyframe data in a Scene */
-static short scene_keyframes_loop(KeyframeEditData *ked, Scene *sce, KeyframeEditFunc key_ok, KeyframeEditFunc key_cb, FcuEditFunc fcu_cb, int filterflag)
+static short scene_keyframes_loop(KeyframeEditData *ked, bDopeSheet *ads, Scene *sce, KeyframeEditFunc key_ok, KeyframeEditFunc key_cb, FcuEditFunc fcu_cb)
{
- World *wo= (sce) ? sce->world : NULL;
- bNodeTree *ntree= (sce) ? sce->nodetree : NULL;
+ bAnimContext ac = {NULL};
+ ListBase anim_data = {NULL, NULL};
+ bAnimListElem *ale;
+ int filter;
+ int ret=0;
+
+ bAnimListElem dummychan = {0};
- /* sanity check */
if (sce == NULL)
return 0;
- /* Scene's own animation */
- if (sce->adt) {
- if (adt_keyframes_loop(ked, sce->adt, key_ok, key_cb, fcu_cb, filterflag))
- return 1;
- }
+ /* create a dummy wrapper data to work with */
+ dummychan.type = ANIMTYPE_SCENE;
+ dummychan.data = sce;
+ dummychan.id = &sce->id;
+ dummychan.adt = sce->adt;
- /* World */
- if (wo && wo->adt) {
- if (adt_keyframes_loop(ked, wo->adt, key_ok, key_cb, fcu_cb, filterflag))
- return 1;
- }
+ ac.ads = ads;
+ ac.data = &dummychan;
+ ac.datatype = ANIMCONT_CHANNEL;
- /* NodeTree */
- if (ntree && ntree->adt) {
- if (adt_keyframes_loop(ked, ntree->adt, key_ok, key_cb, fcu_cb, filterflag))
- return 1;
+ /* get F-Curves to take keyframes from */
+ filter= ANIMFILTER_DATA_VISIBLE; // curves only
+ ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
+
+ /* loop through each F-Curve, applying the operation as required, but stopping on the first one */
+ for (ale= anim_data.first; ale; ale= ale->next) {
+ if (ANIM_fcurve_keyframes_loop(ked, (FCurve*)ale->data, key_ok, key_cb, fcu_cb)) {
+ ret = 1;
+ break;
+ }
}
+ BLI_freelistN(&anim_data);
- return 0;
+ /* return return code - defaults to zero if nothing happened */
+ return ret;
}
/* This function is used to loop over the keyframe data in a DopeSheet summary */
-static short summary_keyframes_loop(KeyframeEditData *ked, bAnimContext *ac, KeyframeEditFunc key_ok, KeyframeEditFunc key_cb, FcuEditFunc fcu_cb, int UNUSED(filterflag))
+static short summary_keyframes_loop(KeyframeEditData *ked, bAnimContext *ac, KeyframeEditFunc key_ok, KeyframeEditFunc key_cb, FcuEditFunc fcu_cb)
{
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
@@ -416,7 +341,7 @@ static short summary_keyframes_loop(KeyframeEditData *ked, bAnimContext *ac, Key
/* --- */
/* This function is used to apply operation to all keyframes, regardless of the type */
-short ANIM_animchannel_keyframes_loop(KeyframeEditData *ked, bAnimListElem *ale, KeyframeEditFunc key_ok, KeyframeEditFunc key_cb, FcuEditFunc fcu_cb, int filterflag)
+short ANIM_animchannel_keyframes_loop(KeyframeEditData *ked, bDopeSheet *ads, bAnimListElem *ale, KeyframeEditFunc key_ok, KeyframeEditFunc key_cb, FcuEditFunc fcu_cb)
{
/* sanity checks */
if (ale == NULL)
@@ -437,18 +362,18 @@ short ANIM_animchannel_keyframes_loop(KeyframeEditData *ked, bAnimListElem *ale,
return act_keyframes_loop(ked, (bAction *)ale->key_data, key_ok, key_cb, fcu_cb);
case ALE_OB: /* object */
- return ob_keyframes_loop(ked, (Object *)ale->key_data, key_ok, key_cb, fcu_cb, filterflag);
+ return ob_keyframes_loop(ked, ads, (Object *)ale->key_data, key_ok, key_cb, fcu_cb);
case ALE_SCE: /* scene */
- return scene_keyframes_loop(ked, (Scene *)ale->data, key_ok, key_cb, fcu_cb, filterflag);
+ return scene_keyframes_loop(ked, ads, (Scene *)ale->data, key_ok, key_cb, fcu_cb);
case ALE_ALL: /* 'all' (DopeSheet summary) */
- return summary_keyframes_loop(ked, (bAnimContext *)ale->data, key_ok, key_cb, fcu_cb, filterflag);
+ return summary_keyframes_loop(ked, (bAnimContext *)ale->data, key_ok, key_cb, fcu_cb);
}
return 0;
}
/* This function is used to apply operation to all keyframes, regardless of the type without needed an AnimListElem wrapper */
-short ANIM_animchanneldata_keyframes_loop(KeyframeEditData *ked, void *data, int keytype, KeyframeEditFunc key_ok, KeyframeEditFunc key_cb, FcuEditFunc fcu_cb, int filterflag)
+short ANIM_animchanneldata_keyframes_loop(KeyframeEditData *ked, bDopeSheet *ads, void *data, int keytype, KeyframeEditFunc key_ok, KeyframeEditFunc key_cb, FcuEditFunc fcu_cb)
{
/* sanity checks */
if (data == NULL)
@@ -469,11 +394,11 @@ short ANIM_animchanneldata_keyframes_loop(KeyframeEditData *ked, void *data, int
return act_keyframes_loop(ked, (bAction *)data, key_ok, key_cb, fcu_cb);
case ALE_OB: /* object */
- return ob_keyframes_loop(ked, (Object *)data, key_ok, key_cb, fcu_cb, filterflag);
+ return ob_keyframes_loop(ked, ads, (Object *)data, key_ok, key_cb, fcu_cb);
case ALE_SCE: /* scene */
- return scene_keyframes_loop(ked, (Scene *)data, key_ok, key_cb, fcu_cb, filterflag);
+ return scene_keyframes_loop(ked, ads, (Scene *)data, key_ok, key_cb, fcu_cb);
case ALE_ALL: /* 'all' (DopeSheet summary) */
- return summary_keyframes_loop(ked, (bAnimContext *)data, key_ok, key_cb, fcu_cb, filterflag);
+ return summary_keyframes_loop(ked, (bAnimContext *)data, key_ok, key_cb, fcu_cb);
}
return 0;