diff options
Diffstat (limited to 'source/blender/editors/animation')
-rw-r--r-- | source/blender/editors/animation/anim_channels_edit.c | 4 | ||||
-rw-r--r-- | source/blender/editors/animation/anim_filter.c | 40 | ||||
-rw-r--r-- | source/blender/editors/animation/keyframes_draw.c | 189 | ||||
-rw-r--r-- | source/blender/editors/animation/keyframes_edit.c | 211 |
4 files changed, 163 insertions, 281 deletions
diff --git a/source/blender/editors/animation/anim_channels_edit.c b/source/blender/editors/animation/anim_channels_edit.c index 5b37c8071cd..f66e3a23bbf 100644 --- a/source/blender/editors/animation/anim_channels_edit.c +++ b/source/blender/editors/animation/anim_channels_edit.c @@ -1405,10 +1405,6 @@ static EnumPropertyItem prop_animchannel_settings_types[] = { /* ------------------- */ -/* macro to be used in setflag_anim_channels */ -#define ASUBCHANNEL_SEL_OK(ale) ( (onlysel == 0) || \ - ((ale->id) && (GS(ale->id->name)==ID_OB) && (((Object *)ale->id)->flag & SELECT)) ) - /* Set/clear a particular flag (setting) for all selected + visible channels * setting: the setting to modify * mode: eAnimChannels_SetFlag diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c index a7117af2151..b7264ae9a3e 100644 --- a/source/blender/editors/animation/anim_filter.c +++ b/source/blender/editors/animation/anim_filter.c @@ -127,6 +127,9 @@ static Key *actedit_get_shapekeys (bAnimContext *ac) /* Get data being edited in Action Editor (depending on current 'mode') */ static short actedit_get_context (bAnimContext *ac, SpaceAction *saction) { + /* get dopesheet */ + ac->ads = &saction->ads; + /* sync settings with current view status, then return appropriate data */ switch (saction->mode) { case SACTCONT_ACTION: /* 'Action Editor' */ @@ -190,6 +193,7 @@ static short graphedit_get_context (bAnimContext *ac, SpaceIpo *sipo) sipo->ads= MEM_callocN(sizeof(bDopeSheet), "GraphEdit DopeSheet"); sipo->ads->source= (ID *)ac->scene; } + ac->ads = sipo->ads; /* set settings for Graph Editor - "Selected = Editable" */ if (sipo->flag & SIPO_SELCUVERTSONLY) @@ -238,6 +242,7 @@ static short nlaedit_get_context (bAnimContext *ac, SpaceNla *snla) /* init dopesheet data if non-existant (i.e. for old files) */ if (snla->ads == NULL) snla->ads= MEM_callocN(sizeof(bDopeSheet), "NlaEdit DopeSheet"); + ac->ads = snla->ads; /* sync settings with current view status, then return appropriate data */ /* update scene-pointer (no need to check for pinning yet, as not implemented) */ @@ -2038,6 +2043,32 @@ static short animdata_filter_dopesheet_summary (bAnimContext *ac, ListBase *anim return 1; } +/* ......................... */ + +/* filter data associated with a channel - usually for handling summary-channels in DopeSheet */ +static size_t animdata_filter_animchan (bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, bAnimListElem *channel, int filter_mode) +{ + size_t items = 0; + + /* data to filter depends on channel type */ + // XXX: only common channel-types have been handled for now + switch (channel->type) { + case ANIMTYPE_SUMMARY: + items += animdata_filter_dopesheet(ac, anim_data, ads, filter_mode); + break; + + case ANIMTYPE_SCENE: + items += animdata_filter_dopesheet_scene(ac, anim_data, ads, channel->data, filter_mode); + break; + + case ANIMTYPE_OBJECT: + items += animdata_filter_dopesheet_ob(ac, anim_data, ads, channel->data, filter_mode); + break; + } + + return items; +} + /* ----------- Cleanup API --------------- */ /* Remove entries with invalid types in animation channel list */ @@ -2157,6 +2188,15 @@ size_t ANIM_animdata_filter (bAnimContext *ac, ListBase *anim_data, int filter_m items = animdata_filter_dopesheet(ac, anim_data, data, filter_mode); } break; + + case ANIMCONT_CHANNEL: /* animation channel */ + { + bDopeSheet *ads = ac->ads; + + /* based on the channel type, filter relevant data for this */ + items = animdata_filter_animchan(ac, anim_data, ads, data, filter_mode); + } + break; } /* remove any 'weedy' entries */ diff --git a/source/blender/editors/animation/keyframes_draw.c b/source/blender/editors/animation/keyframes_draw.c index 453027632eb..b774bc947e4 100644 --- a/source/blender/editors/animation/keyframes_draw.c +++ b/source/blender/editors/animation/keyframes_draw.c @@ -786,150 +786,71 @@ void summary_to_keylist(bAnimContext *ac, DLRBT_Tree *keys, DLRBT_Tree *blocks) void scene_to_keylist(bDopeSheet *ads, Scene *sce, DLRBT_Tree *keys, DLRBT_Tree *blocks) { - if (sce) { - AnimData *adt; - int filterflag; - - /* get filterflag */ - if (ads) - filterflag= ads->filterflag; - else - filterflag= 0; - - /* scene animdata */ - if ((sce->adt) && !(filterflag & ADS_FILTER_NOSCE)) { - adt= sce->adt; - - if (adt->action) - action_to_keylist(adt, adt->action, keys, blocks); - } - - /* world animdata */ - if ((sce->world) && (sce->world->adt) && !(filterflag & ADS_FILTER_NOWOR)) { - adt= sce->world->adt; - - if (adt->action) - action_to_keylist(adt, adt->action, keys, blocks); - } - - /* nodetree animdata */ - if ((sce->nodetree) && (sce->nodetree->adt) && !(filterflag & ADS_FILTER_NONTREE)) { - adt= sce->nodetree->adt; - - if (adt->action) - action_to_keylist(adt, adt->action, keys, blocks); - } - } + bAnimContext ac = {NULL}; + ListBase anim_data = {NULL, NULL}; + bAnimListElem *ale; + int filter; + + bAnimListElem dummychan = {0}; + + if (sce == NULL) + return; + + /* create a dummy wrapper data to work with */ + dummychan.type = ANIMTYPE_SCENE; + dummychan.data = sce; + dummychan.id = &sce->id; + dummychan.adt = sce->adt; + + 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, grabbing the keyframes */ + for (ale= anim_data.first; ale; ale= ale->next) + fcurve_to_keylist(ale->adt, ale->data, keys, blocks); + + BLI_freelistN(&anim_data); } void ob_to_keylist(bDopeSheet *ads, Object *ob, DLRBT_Tree *keys, DLRBT_Tree *blocks) -{ - Key *key= ob_get_key(ob); - int filterflag= (ads)? ads->filterflag : 0; +{ + bAnimContext ac = {NULL}; + ListBase anim_data = {NULL, NULL}; + bAnimListElem *ale; + int filter; + + bAnimListElem dummychan = {0}; + Base dummybase = {0}; - /* sanity check */ if (ob == NULL) return; - - /* Add action keyframes */ - if (ob->adt && ob->adt->action) - action_to_keylist(ob->adt, ob->adt->action, keys, blocks); - /* Add shapekey keyframes (only if dopesheet allows, if it is available) */ - if ((key && key->adt && key->adt->action) && !(filterflag & ADS_FILTER_NOSHAPEKEYS)) - action_to_keylist(key->adt, key->adt->action, keys, blocks); + /* create a dummy wrapper data to work with */ + dummybase.object = ob; - /* 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 */ - action_to_keylist(ma->adt, ma->adt->action, keys, blocks); - - // TODO: textures... - } - } + 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)) - action_to_keylist(ca->adt, ca->adt->action, keys, blocks); - } - break; - case OB_LAMP: /* ---------- Lamp ----------- */ - { - Lamp *la= (Lamp *)ob->data; - - if ((la->adt) && !(filterflag & ADS_FILTER_NOLAM)) - action_to_keylist(la->adt, la->adt->action, keys, blocks); - } - 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)) - action_to_keylist(cu->adt, cu->adt->action, keys, blocks); - } - break; - case OB_MBALL: /* ------- MetaBall ---------- */ - { - MetaBall *mb= (MetaBall *)ob->data; - - if ((mb->adt) && !(filterflag & ADS_FILTER_NOMBA)) - action_to_keylist(mb->adt, mb->adt->action, keys, blocks); - } - break; - case OB_ARMATURE: /* ------- Armature ---------- */ - { - bArmature *arm= (bArmature *)ob->data; - - if ((arm->adt) && !(filterflag & ADS_FILTER_NOARM)) - action_to_keylist(arm->adt, arm->adt->action, keys, blocks); - } - break; - case OB_MESH: /* ------- Mesh ---------- */ - { - Mesh *me= (Mesh *)ob->data; - - if ((me->adt) && !(filterflag & ADS_FILTER_NOMESH)) - action_to_keylist(me->adt, me->adt->action, keys, blocks); - } - break; - case OB_LATTICE: /* ------- Lattice ---------- */ - { - Lattice *lt= (Lattice *)ob->data; - - if ((lt->adt) && !(filterflag & ADS_FILTER_NOLAT)) - action_to_keylist(lt->adt, lt->adt->action, keys, blocks); - } - break; - } + ac.ads = ads; + ac.data = &dummychan; + ac.datatype = ANIMCONT_CHANNEL; - /* 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; - else - action_to_keylist(psys->part->adt, psys->part->adt->action, keys, blocks); - } - } + /* 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, grabbing the keyframes */ + for (ale= anim_data.first; ale; ale= ale->next) + fcurve_to_keylist(ale->adt, ale->data, keys, blocks); + + BLI_freelistN(&anim_data); } void fcurve_to_keylist(AnimData *adt, FCurve *fcu, DLRBT_Tree *keys, DLRBT_Tree *blocks) 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; |