diff options
Diffstat (limited to 'source/blender/editors/space_action/action_edit.c')
-rw-r--r-- | source/blender/editors/space_action/action_edit.c | 138 |
1 files changed, 60 insertions, 78 deletions
diff --git a/source/blender/editors/space_action/action_edit.c b/source/blender/editors/space_action/action_edit.c index ba8e49e3789..0e2a7f690c5 100644 --- a/source/blender/editors/space_action/action_edit.c +++ b/source/blender/editors/space_action/action_edit.c @@ -32,31 +32,14 @@ #include <string.h> #include <float.h> -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" #include "BLI_math.h" #include "DNA_anim_types.h" -#include "DNA_action_types.h" -#include "DNA_armature_types.h" -#include "DNA_camera_types.h" -#include "DNA_curve_types.h" #include "DNA_object_types.h" -#include "DNA_screen_types.h" #include "DNA_scene_types.h" -#include "DNA_space_types.h" -#include "DNA_constraint_types.h" -#include "DNA_key_types.h" -#include "DNA_lamp_types.h" -#include "DNA_material_types.h" -#include "DNA_userdef_types.h" -#include "DNA_gpencil_types.h" -#include "DNA_windowmanager_types.h" #include "RNA_access.h" #include "RNA_define.h" @@ -77,10 +60,8 @@ #include "ED_anim_api.h" #include "ED_keyframing.h" -#include "ED_keyframes_draw.h" #include "ED_keyframes_edit.h" #include "ED_screen.h" -#include "ED_space_api.h" #include "ED_transform.h" #include "WM_api.h" @@ -118,7 +99,7 @@ static int act_new_exec(bContext *C, wmOperator *op) } /* set notifier that keyframes have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME_EDIT, NULL); + WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL); return OPERATOR_FINISHED; } @@ -152,7 +133,7 @@ static void get_keyframe_extents (bAnimContext *ac, float *min, float *max) int filter; /* get data to filter, from Action or Dopesheet */ - filter= (ANIMFILTER_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_CURVESONLY); + filter= (ANIMFILTER_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_CURVESONLY | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* set large values to try to override */ @@ -303,7 +284,7 @@ static short copy_action_keys (bAnimContext *ac) free_anim_copybuf(); /* filter data */ - filter= (ANIMFILTER_VISIBLE | ANIMFILTER_CURVESONLY); + filter= (ANIMFILTER_VISIBLE | ANIMFILTER_CURVESONLY | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* copy keyframes */ @@ -322,7 +303,7 @@ static short paste_action_keys (bAnimContext *ac) int filter, ok=0; /* filter data */ - filter= (ANIMFILTER_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_FOREDIT | ANIMFILTER_CURVESONLY); + filter= (ANIMFILTER_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_FOREDIT | ANIMFILTER_CURVESONLY | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* paste keyframes */ @@ -398,7 +379,7 @@ static int actkeys_paste_exec(bContext *C, wmOperator *op) ANIM_editkeyframes_refresh(&ac); /* set notifier that keyframes have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME_EDIT, NULL); + WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL); return OPERATOR_FINISHED; } @@ -440,7 +421,7 @@ static void insert_action_keys(bAnimContext *ac, short mode) short flag = 0; /* filter data */ - filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_CURVESONLY); + filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_CURVESONLY | ANIMFILTER_NODUPLIS); if (mode == 2) filter |= ANIMFILTER_SEL; else if (mode == 3) filter |= ANIMFILTER_ACTGROUPED; @@ -493,7 +474,7 @@ static int actkeys_insertkey_exec(bContext *C, wmOperator *op) ANIM_editkeyframes_refresh(&ac); /* set notifier that keyframes have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME_EDIT, NULL); + WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL); return OPERATOR_FINISHED; } @@ -527,9 +508,9 @@ static void duplicate_action_keys (bAnimContext *ac) /* filter data */ if (ac->datatype == ANIMCONT_GPENCIL) - filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT); + filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); else - filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_CURVESONLY); + filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_CURVESONLY | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* loop through filtered data and delete selected keys */ @@ -561,7 +542,7 @@ static int actkeys_duplicate_exec(bContext *C, wmOperator *op) ANIM_editkeyframes_refresh(&ac); /* set notifier that keyframes have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME_EDIT, NULL); + WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL); return OPERATOR_FINISHED; // xxx - start transform } @@ -605,9 +586,9 @@ static void delete_action_keys (bAnimContext *ac) /* filter data */ if (ac->datatype == ANIMCONT_GPENCIL) - filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT); + filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); else - filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_CURVESONLY); + filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_CURVESONLY | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* loop through filtered data and delete selected keys */ @@ -648,7 +629,7 @@ static int actkeys_delete_exec(bContext *C, wmOperator *op) ANIM_editkeyframes_refresh(&ac); /* set notifier that keyframes have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME_EDIT, NULL); + WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL); return OPERATOR_FINISHED; } @@ -678,7 +659,7 @@ static void clean_action_keys (bAnimContext *ac, float thresh) int filter; /* filter data */ - filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_SEL | ANIMFILTER_CURVESONLY); + filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_SEL | ANIMFILTER_CURVESONLY | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* loop through filtered data and clean curves */ @@ -712,7 +693,7 @@ static int actkeys_clean_exec(bContext *C, wmOperator *op) ANIM_editkeyframes_refresh(&ac); /* set notifier that keyframes have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME_EDIT, NULL); + WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL); return OPERATOR_FINISHED; } @@ -746,7 +727,7 @@ static void sample_action_keys (bAnimContext *ac) int filter; /* filter data */ - filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_CURVESONLY); + filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_CURVESONLY | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* loop through filtered data and add keys between selected keyframes on every frame */ @@ -776,7 +757,7 @@ static int actkeys_sample_exec(bContext *C, wmOperator *op) ANIM_editkeyframes_refresh(&ac); /* set notifier that keyframes have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME_EDIT, NULL); + WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL); return OPERATOR_FINISHED; } @@ -816,7 +797,7 @@ static void setexpo_action_keys(bAnimContext *ac, short mode) int filter; /* filter data */ - filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_CURVESONLY); + filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_CURVESONLY | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* loop through setting mode per F-Curve */ @@ -884,17 +865,17 @@ static void setipo_action_keys(bAnimContext *ac, short mode) ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - BeztEditFunc set_cb= ANIM_editkeyframes_ipo(mode); + KeyframeEditFunc set_cb= ANIM_editkeyframes_ipo(mode); /* filter data */ - filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_CURVESONLY); + filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_CURVESONLY | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* loop through setting BezTriple interpolation - * Note: we do not supply BeztEditData to the looper yet. Currently that's not necessary here... + * Note: we do not supply KeyframeEditData to the looper yet. Currently that's not necessary here... */ for (ale= anim_data.first; ale; ale= ale->next) - ANIM_fcurve_keys_bezier_loop(NULL, ale->key_data, NULL, set_cb, calchandles_fcurve); + ANIM_fcurve_keyframes_loop(NULL, ale->key_data, NULL, set_cb, calchandles_fcurve); /* cleanup */ BLI_freelistN(&anim_data); @@ -967,21 +948,21 @@ static void sethandles_action_keys(bAnimContext *ac, short mode) bAnimListElem *ale; int filter; - BeztEditFunc edit_cb= ANIM_editkeyframes_handles(mode); - BeztEditFunc sel_cb= ANIM_editkeyframes_ok(BEZT_OK_SELECTED); + KeyframeEditFunc edit_cb= ANIM_editkeyframes_handles(mode); + KeyframeEditFunc sel_cb= ANIM_editkeyframes_ok(BEZT_OK_SELECTED); /* filter data */ - filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_CURVESONLY); + filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_CURVESONLY | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* loop through setting flags for handles - * Note: we do not supply BeztEditData to the looper yet. Currently that's not necessary here... + * Note: we do not supply KeyframeEditData to the looper yet. Currently that's not necessary here... */ for (ale= anim_data.first; ale; ale= ale->next) { FCurve *fcu= (FCurve *)ale->key_data; /* any selected keyframes for editing? */ - if (ANIM_fcurve_keys_bezier_loop(NULL, fcu, NULL, sel_cb, NULL)) { + if (ANIM_fcurve_keyframes_loop(NULL, fcu, NULL, sel_cb, NULL)) { /* for auto/auto-clamped, toggle the auto-handles flag on the F-Curve */ if (mode == HD_AUTO_ANIM) fcu->flag |= FCURVE_AUTO_HANDLES; @@ -989,7 +970,7 @@ static void sethandles_action_keys(bAnimContext *ac, short mode) fcu->flag &= ~FCURVE_AUTO_HANDLES; /* change type of selected handles */ - ANIM_fcurve_keys_bezier_loop(NULL, fcu, NULL, edit_cb, calchandles_fcurve); + ANIM_fcurve_keyframes_loop(NULL, fcu, NULL, edit_cb, calchandles_fcurve); } } @@ -1052,17 +1033,17 @@ static void setkeytype_action_keys(bAnimContext *ac, short mode) ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - BeztEditFunc set_cb= ANIM_editkeyframes_keytype(mode); + KeyframeEditFunc set_cb= ANIM_editkeyframes_keytype(mode); /* filter data */ - filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_CURVESONLY); + filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_CURVESONLY | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* loop through setting BezTriple interpolation - * Note: we do not supply BeztEditData to the looper yet. Currently that's not necessary here... + * Note: we do not supply KeyframeEditData to the looper yet. Currently that's not necessary here... */ for (ale= anim_data.first; ale; ale= ale->next) - ANIM_fcurve_keys_bezier_loop(NULL, ale->key_data, NULL, set_cb, NULL); + ANIM_fcurve_keyframes_loop(NULL, ale->key_data, NULL, set_cb, NULL); /* cleanup */ BLI_freelistN(&anim_data); @@ -1127,36 +1108,37 @@ static int actkeys_framejump_exec(bContext *C, wmOperator *op) ListBase anim_data= {NULL, NULL}; bAnimListElem *ale; int filter; - BeztEditData bed; + KeyframeEditData ked; /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; /* init edit data */ - memset(&bed, 0, sizeof(BeztEditData)); + memset(&ked, 0, sizeof(KeyframeEditData)); /* loop over action data, averaging values */ - filter= (ANIMFILTER_VISIBLE | ANIMFILTER_CURVESONLY); + filter= (ANIMFILTER_VISIBLE | ANIMFILTER_CURVESONLY | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); for (ale= anim_data.first; ale; ale= ale->next) { AnimData *adt= ANIM_nla_mapping_get(&ac, ale); if (adt) { ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1); - ANIM_fcurve_keys_bezier_loop(&bed, ale->key_data, NULL, bezt_calc_average, NULL); + ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, bezt_calc_average, NULL); ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1); } else - ANIM_fcurve_keys_bezier_loop(&bed, ale->key_data, NULL, bezt_calc_average, NULL); + ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, bezt_calc_average, NULL); } BLI_freelistN(&anim_data); /* set the new current frame value, based on the average time */ - if (bed.i1) { + if (ked.i1) { Scene *scene= ac.scene; - CFRA= (int)floor((bed.f1 / bed.i1) + 0.5f); + CFRA= (int)floor((ked.f1 / ked.i1) + 0.5f); + SUBFRA= 0.f; } /* set notifier that things have changed */ @@ -1198,24 +1180,24 @@ static void snap_action_keys(bAnimContext *ac, short mode) bAnimListElem *ale; int filter; - BeztEditData bed; - BeztEditFunc edit_cb; + KeyframeEditData ked; + KeyframeEditFunc edit_cb; /* filter data */ if (ac->datatype == ANIMCONT_GPENCIL) filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT); else - filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_CURVESONLY); + filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_CURVESONLY | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* get beztriple editing callbacks */ edit_cb= ANIM_editkeyframes_snap(mode); - memset(&bed, 0, sizeof(BeztEditData)); - bed.scene= ac->scene; + memset(&ked, 0, sizeof(KeyframeEditData)); + ked.scene= ac->scene; if (mode == ACTKEYS_SNAP_NEAREST_MARKER) { - bed.list.first= (ac->markers) ? ac->markers->first : NULL; - bed.list.last= (ac->markers) ? ac->markers->last : NULL; + ked.list.first= (ac->markers) ? ac->markers->first : NULL; + ked.list.last= (ac->markers) ? ac->markers->last : NULL; } /* snap keyframes */ @@ -1224,13 +1206,13 @@ static void snap_action_keys(bAnimContext *ac, short mode) if (adt) { ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1); - ANIM_fcurve_keys_bezier_loop(&bed, ale->key_data, NULL, edit_cb, calchandles_fcurve); + ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, edit_cb, calchandles_fcurve); ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1); } //else if (ale->type == ACTTYPE_GPLAYER) // snap_gplayer_frames(ale->data, mode); else - ANIM_fcurve_keys_bezier_loop(&bed, ale->key_data, NULL, edit_cb, calchandles_fcurve); + ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, edit_cb, calchandles_fcurve); } BLI_freelistN(&anim_data); @@ -1257,7 +1239,7 @@ static int actkeys_snap_exec(bContext *C, wmOperator *op) ANIM_editkeyframes_refresh(&ac); /* set notifier that keyframes have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME_EDIT, NULL); + WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL); return OPERATOR_FINISHED; } @@ -1298,14 +1280,14 @@ static void mirror_action_keys(bAnimContext *ac, short mode) bAnimListElem *ale; int filter; - BeztEditData bed; - BeztEditFunc edit_cb; + KeyframeEditData ked; + KeyframeEditFunc edit_cb; /* get beztriple editing callbacks */ edit_cb= ANIM_editkeyframes_mirror(mode); - memset(&bed, 0, sizeof(BeztEditData)); - bed.scene= ac->scene; + memset(&ked, 0, sizeof(KeyframeEditData)); + ked.scene= ac->scene; /* for 'first selected marker' mode, need to find first selected marker first! */ // XXX should this be made into a helper func in the API? @@ -1323,16 +1305,16 @@ static void mirror_action_keys(bAnimContext *ac, short mode) /* store marker's time (if available) */ if (marker) - bed.f1= (float)marker->frame; + ked.f1= (float)marker->frame; else return; } /* filter data */ if (ac->datatype == ANIMCONT_GPENCIL) - filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT); + filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); else - filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_CURVESONLY); + filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_CURVESONLY | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* mirror keyframes */ @@ -1341,13 +1323,13 @@ static void mirror_action_keys(bAnimContext *ac, short mode) if (adt) { ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1); - ANIM_fcurve_keys_bezier_loop(&bed, ale->key_data, NULL, edit_cb, calchandles_fcurve); + ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, edit_cb, calchandles_fcurve); ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1); } //else if (ale->type == ACTTYPE_GPLAYER) // snap_gplayer_frames(ale->data, mode); else - ANIM_fcurve_keys_bezier_loop(&bed, ale->key_data, NULL, edit_cb, calchandles_fcurve); + ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, edit_cb, calchandles_fcurve); } BLI_freelistN(&anim_data); @@ -1374,7 +1356,7 @@ static int actkeys_mirror_exec(bContext *C, wmOperator *op) ANIM_editkeyframes_refresh(&ac); /* set notifier that keyframes have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME_EDIT, NULL); + WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL); return OPERATOR_FINISHED; } |