diff options
4 files changed, 96 insertions, 63 deletions
diff --git a/source/blender/editors/animation/keyframes_draw.c b/source/blender/editors/animation/keyframes_draw.c index d67a40518e3..6e58efbe73b 100644 --- a/source/blender/editors/animation/keyframes_draw.c +++ b/source/blender/editors/animation/keyframes_draw.c @@ -449,8 +449,6 @@ void ob_to_keylist(Object *ob, ListBase *keys, ListBase *blocks, ActKeysInc *aki /* get filterflag */ if (ads) filterflag= ads->filterflag; - else if ((aki) && (aki->actmode == -1)) /* only set like this by NLA */ - filterflag= ADS_FILTER_NLADUMMY; else filterflag= 0; diff --git a/source/blender/editors/animation/keyframes_edit.c b/source/blender/editors/animation/keyframes_edit.c index 44814812c76..748f4de7122 100644 --- a/source/blender/editors/animation/keyframes_edit.c +++ b/source/blender/editors/animation/keyframes_edit.c @@ -36,12 +36,12 @@ #include "DNA_anim_types.h" #include "DNA_action_types.h" -#include "DNA_constraint_types.h" #include "DNA_curve_types.h" #include "DNA_key_types.h" #include "DNA_object_types.h" #include "DNA_space_types.h" #include "DNA_scene_types.h" +#include "DNA_world_types.h" #include "BKE_action.h" #include "BKE_fcurve.h" @@ -71,7 +71,7 @@ */ /* ************************************************************************** */ -/* IPO Editing Loops - Exposed API */ +/* Keyframe Editing Loops - Exposed API */ /* --------------------------- Base Functions ------------------------------------ */ @@ -121,14 +121,14 @@ short ANIM_fcurve_keys_bezier_loop(BeztEditData *bed, FCurve *fcu, BeztEditFunc return 0; } -/* -------------------------------- Further Abstracted ----------------------------- */ +/* -------------------------------- Further Abstracted (Not Exposed Directly) ----------------------------- */ /* This function is used to loop over the keyframe data in an Action Group */ static short agrp_keys_bezier_loop(BeztEditData *bed, bActionGroup *agrp, BeztEditFunc bezt_ok, BeztEditFunc bezt_cb, FcuEditFunc fcu_cb) { FCurve *fcu; - /* only iterate over the action-channels and their sub-channels that are in this group */ + /* only iterate over the F-Curves that are in this group */ for (fcu= agrp->channels.first; fcu && fcu->grp==agrp; fcu= fcu->next) { if (ANIM_fcurve_keys_bezier_loop(bed, fcu, bezt_ok, bezt_cb, fcu_cb)) return 1; @@ -144,17 +144,73 @@ static short act_keys_bezier_loop(BeztEditData *bed, bAction *act, BeztEditFunc /* just loop through all F-Curves */ for (fcu= act->curves.first; fcu; fcu= fcu->next) { - ANIM_fcurve_keys_bezier_loop(bed, fcu, bezt_ok, bezt_cb, fcu_cb); + if (ANIM_fcurve_keys_bezier_loop(bed, fcu, bezt_ok, bezt_cb, fcu_cb)) + return 1; } return 0; } -/* --- */ +/* This function is used to loop over the keyframe data of an AnimData block */ +static short adt_keys_bezier_loop(BeztEditData *bed, AnimData *adt, BeztEditFunc bezt_ok, BeztEditFunc bezt_cb, FcuEditFunc fcu_cb, int filterflag) +{ + /* drivers or actions? */ + if (filterflag & ADS_FILTER_ONLYDRIVERS) { + FCurve *fcu; + + /* just loop through all F-Curves acting as Drivers */ + for (fcu= adt->drivers.first; fcu; fcu= fcu->next) { + if (ANIM_fcurve_keys_bezier_loop(bed, fcu, bezt_ok, bezt_cb, fcu_cb)) + return 1; + } + } + else if (adt->action) { + /* call the function for actions */ + if (act_keys_bezier_loop(bed, adt->action, bezt_ok, bezt_cb, fcu_cb)) + return 1; + } + + return 0; +} + +/* This function is used to loop over the keyframe data in an Object */ +static short ob_keys_bezier_loop(BeztEditData *bed, Object *ob, BeztEditFunc bezt_ok, BeztEditFunc bezt_cb, FcuEditFunc fcu_cb, int filterflag) +{ + Key *key= ob_get_key(ob); + + /* firstly, Object's own AnimData */ + if (ob->adt) + adt_keys_bezier_loop(bed, ob->adt, bezt_ok, bezt_cb, fcu_cb, filterflag); + + /* shapekeys */ + if ((key && key->adt) && !(filterflag & ADS_FILTER_NOSHAPEKEYS)) + adt_keys_bezier_loop(bed, key->adt, bezt_ok, bezt_cb, fcu_cb, filterflag); + + // FIXME: add materials, etc. (but drawing code doesn't do it yet too! :) + + return 0; +} + +/* This function is used to loop over the keyframe data in a Scene */ +static short scene_keys_bezier_loop(BeztEditData *bed, Scene *sce, BeztEditFunc bezt_ok, BeztEditFunc bezt_cb, FcuEditFunc fcu_cb, int filterflag) +{ + World *wo= sce->world; + + /* Scene's own animation */ + if (sce->adt) + adt_keys_bezier_loop(bed, sce->adt, bezt_ok, bezt_cb, fcu_cb, filterflag); + + /* World */ + if (wo && wo->adt) + adt_keys_bezier_loop(bed, wo->adt, bezt_ok, bezt_cb, fcu_cb, filterflag); + + return 0; +} +/* --- */ /* This function is used to apply operation to all keyframes, regardless of the type */ -short ANIM_animchannel_keys_bezier_loop(BeztEditData *bed, bAnimListElem *ale, BeztEditFunc bezt_ok, BeztEditFunc bezt_cb, FcuEditFunc fcu_cb) +short ANIM_animchannel_keys_bezier_loop(BeztEditData *bed, bAnimListElem *ale, BeztEditFunc bezt_ok, BeztEditFunc bezt_cb, FcuEditFunc fcu_cb, int filterflag) { /* sanity checks */ if (ale == NULL) @@ -173,6 +229,11 @@ short ANIM_animchannel_keys_bezier_loop(BeztEditData *bed, bAnimListElem *ale, B return agrp_keys_bezier_loop(bed, (bActionGroup *)ale->data, bezt_ok, bezt_cb, fcu_cb); case ALE_ACT: /* action */ return act_keys_bezier_loop(bed, (bAction *)ale->data, bezt_ok, bezt_cb, fcu_cb); + + case ALE_OB: /* object */ + return ob_keys_bezier_loop(bed, (Object *)ale->data, bezt_ok, bezt_cb, fcu_cb, filterflag); + case ALE_SCE: /* scene */ + return scene_keys_bezier_loop(bed, (Scene *)ale->data, bezt_ok, bezt_cb, fcu_cb, filterflag); } return 0; diff --git a/source/blender/editors/include/ED_keyframes_edit.h b/source/blender/editors/include/ED_keyframes_edit.h index 1da1196a462..185e290a712 100644 --- a/source/blender/editors/include/ED_keyframes_edit.h +++ b/source/blender/editors/include/ED_keyframes_edit.h @@ -30,6 +30,7 @@ #define ED_KEYFRAMES_EDIT_H struct bAnimContext; +struct bAnimListElem; struct FCurve; struct BezTriple; struct Scene; @@ -107,7 +108,13 @@ typedef short (*BeztEditFunc)(BeztEditData *bed, struct BezTriple *bezt); /* ---------------- Looping API --------------------- */ /* functions for looping over keyframes */ -short ANIM_fcurve_keys_bezier_loop(BeztEditData *bed, struct FCurve *Fcu, BeztEditFunc bezt_ok, BeztEditFunc bezt_cb, FcuEditFunc fcu_cb); + /* function for working with F-Curve data only (i.e. when filters have been chosen to explicitly use this) */ +short ANIM_fcurve_keys_bezier_loop(BeztEditData *bed, struct FCurve *fcu, BeztEditFunc bezt_ok, BeztEditFunc bezt_cb, FcuEditFunc fcu_cb); + /* function for working with any type (i.e. one of the known types) of animation channel + * - filterflag is bDopeSheet->flag (DOPESHEET_FILTERFLAG) + */ +short ANIM_animchannel_keys_bezier_loop(BeztEditData *bed, struct bAnimListElem *ale, BeztEditFunc bezt_ok, BeztEditFunc bezt_cb, FcuEditFunc fcu_cb, int filterflag); + /* functions for making sure all keyframes are in good order */ void ANIM_editkeyframes_refresh(struct bAnimContext *ac); diff --git a/source/blender/editors/space_action/action_select.c b/source/blender/editors/space_action/action_select.c index 3bc57abe573..eb8866c6144 100644 --- a/source/blender/editors/space_action/action_select.c +++ b/source/blender/editors/space_action/action_select.c @@ -88,7 +88,6 @@ /* used only by mouse_action. It is used to find the location of the nearest * keyframe to where the mouse clicked, */ -// XXX port this to new listview code... // XXX just merge this into the existing code! static void *get_nearest_action_key (bAnimContext *ac, int mval[2], float *selx, short *sel, short *ret_type, bActionGroup **par) { @@ -129,8 +128,7 @@ static void *get_nearest_action_key (bAnimContext *ac, int mval[2], float *selx, BLI_freelistN(&anim_data); return NULL; } - - { + else { /* found match - must return here... */ Object *nob= ANIM_nla_mapping_get(ac, ale); ActKeysInc *aki= init_aki_data(ac, ale); @@ -779,8 +777,8 @@ static void mouse_action_keys (bAnimContext *ac, int mval[2], short selectmode) BeztEditData bed; BeztEditFunc select_cb, ok_cb; void *anim_channel; - short sel, chan_type = 0; - float selx = 0.0f, selxa; + short sel, chan_type = 0, key_type = 0; + float selx = 0.0f; /* determine what type of data we are operating on */ if (ac->datatype == ANIMCONT_ACTION) @@ -798,9 +796,11 @@ static void mouse_action_keys (bAnimContext *ac, int mval[2], short selectmode) switch (chan_type) { case ANIMTYPE_FCURVE: fcu= (FCurve *)anim_channel; + key_type= ALE_FCURVE; break; case ANIMTYPE_GROUP: agrp= (bActionGroup *)anim_channel; + key_type= ALE_GROUP; break; #if 0 // XXX fixme case ANIMTYPE_DSMAT: @@ -821,12 +821,15 @@ static void mouse_action_keys (bAnimContext *ac, int mval[2], short selectmode) #endif // XXX fixme case ANIMTYPE_FILLACTD: act= (bAction *)anim_channel; + key_type= ALE_ACT; break; case ANIMTYPE_OBJECT: ob= ((Base *)anim_channel)->object; + key_type= ALE_OB; break; case ANIMTYPE_SCENE: sce= (Scene *)anim_channel; + key_type= ALE_SCE; break; case ANIMTYPE_GPLAYER: gpl= (bGPDlayer *)anim_channel; @@ -874,58 +877,22 @@ static void mouse_action_keys (bAnimContext *ac, int mval[2], short selectmode) /* apply selection to keyframes */ // XXX use more generic code looper for this stuff... - if (fcu) - ANIM_fcurve_keys_bezier_loop(&bed, fcu, ok_cb, select_cb, NULL); - else if (agrp) { - for (fcu= agrp->channels.first; fcu && fcu->grp==agrp; fcu= fcu->next) - ANIM_fcurve_keys_bezier_loop(&bed, fcu, ok_cb, select_cb, NULL); - } - else if (act) { - for (fcu= act->curves.first; fcu; fcu= fcu->next) - ANIM_fcurve_keys_bezier_loop(&bed, fcu, ok_cb, select_cb, NULL); - } - else if (ob) { - AnimData *adt; - - /* Object's own animation */ - if (ob->adt && ob->adt->action) { - adt= ob->adt; - act= adt->action; - - selxa= get_action_frame(ob, selx); // xxx - bed.f1= selxa; - - for (fcu= act->curves.first; fcu; fcu= fcu->next) - ANIM_fcurve_keys_bezier_loop(&bed, fcu, ok_cb, select_cb, NULL); - } - - /* 'Sub-Object' animation data */ - // TODO... + if (gpl) { + /* grease pencil */ + //select_gpencil_frame(gpl, (int)selx, selectmode); } - else if (sce) { - World *wo= sce->world; - AnimData *adt; + else { + bAnimListElem ale = {0}; - /* Scene's own animation */ - if (sce->adt && sce->adt->action) { - adt= sce->adt; - act= adt->action; - - for (fcu= act->curves.first; fcu; fcu= fcu->next) - ANIM_fcurve_keys_bezier_loop(&bed, fcu, ok_cb, select_cb, NULL); - } + /* initialise just a few vars that the callback will use... */ + // FIXME: this method is a mess anyways... it needs a recode + ale.datatype= key_type; + ale.key_data= anim_channel; + ale.data= anim_channel; - /* World */ - if (wo && wo->adt && wo->adt->action) { - adt= wo->adt; - act= adt->action; - - for (fcu= act->curves.first; fcu; fcu= fcu->next) - ANIM_fcurve_keys_bezier_loop(&bed, fcu, ok_cb, select_cb, NULL); - } + /* loop over all the relevant channels */ + ANIM_animchannel_keys_bezier_loop(&bed, &ale, ok_cb, select_cb, NULL, ((ads) ? (ads->filterflag) : (0))); } - //else if (gpl) - // select_gpencil_frame(gpl, (int)selx, selectmode); } /* Option 2) Selects all the keyframes on either side of the current frame (depends on which side the mouse is on) */ |