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:
Diffstat (limited to 'source/blender/editors/animation/keyframes_general.c')
-rw-r--r--source/blender/editors/animation/keyframes_general.c109
1 files changed, 18 insertions, 91 deletions
diff --git a/source/blender/editors/animation/keyframes_general.c b/source/blender/editors/animation/keyframes_general.c
index 00e2f221117..7723c221a40 100644
--- a/source/blender/editors/animation/keyframes_general.c
+++ b/source/blender/editors/animation/keyframes_general.c
@@ -47,77 +47,6 @@
/* **************************************************** */
-void delete_fcurve_key(FCurve *fcu, int index, bool do_recalc)
-{
- /* sanity check */
- if (fcu == NULL) {
- return;
- }
-
- /* verify the index:
- * 1) cannot be greater than the number of available keyframes
- * 2) negative indices are for specifying a value from the end of the array
- */
- if (abs(index) >= fcu->totvert) {
- return;
- }
- if (index < 0) {
- index += fcu->totvert;
- }
-
- /* Delete this keyframe */
- memmove(
- &fcu->bezt[index], &fcu->bezt[index + 1], sizeof(BezTriple) * (fcu->totvert - index - 1));
- fcu->totvert--;
-
- if (fcu->totvert == 0) {
- MEM_SAFE_FREE(fcu->bezt);
- }
-
- /* recalc handles - only if it won't cause problems */
- if (do_recalc) {
- calchandles_fcurve(fcu);
- }
-}
-
-bool delete_fcurve_keys(FCurve *fcu)
-{
- bool changed = false;
-
- if (fcu->bezt == NULL) { /* ignore baked curves */
- return false;
- }
-
- /* Delete selected BezTriples */
- for (int i = 0; i < fcu->totvert; i++) {
- if (fcu->bezt[i].f2 & SELECT) {
- if (i == fcu->active_keyframe_index) {
- BKE_fcurve_active_keyframe_set(fcu, NULL);
- }
- memmove(&fcu->bezt[i], &fcu->bezt[i + 1], sizeof(BezTriple) * (fcu->totvert - i - 1));
- fcu->totvert--;
- i--;
- changed = true;
- }
- }
-
- /* Free the array of BezTriples if there are not keyframes */
- if (fcu->totvert == 0) {
- clear_fcurve_keys(fcu);
- }
-
- return changed;
-}
-
-void clear_fcurve_keys(FCurve *fcu)
-{
- MEM_SAFE_FREE(fcu->bezt);
-
- fcu->totvert = 0;
-}
-
-/* ---------------- */
-
bool duplicate_fcurve_keys(FCurve *fcu)
{
bool changed = false;
@@ -282,7 +211,7 @@ void clean_fcurve(struct bAnimContext *ac, bAnimListElem *ale, float thresh, boo
}
if (fcu->bezt->vec[1][1] == default_value) {
- clear_fcurve_keys(fcu);
+ BKE_fcurve_delete_keys_all(fcu);
/* check if curve is really unused and if it is, return signal for deletion */
if (BKE_fcurve_is_empty(fcu)) {
@@ -679,7 +608,7 @@ void smooth_fcurve(FCurve *fcu)
}
/* recalculate handles */
- calchandles_fcurve(fcu);
+ BKE_fcurve_handles_recalc(fcu);
}
/* ---------------- */
@@ -762,7 +691,7 @@ void sample_fcurve(FCurve *fcu)
}
/* recalculate channel's handles? */
- calchandles_fcurve(fcu);
+ BKE_fcurve_handles_recalc(fcu);
}
/* **************************************************** */
@@ -921,7 +850,7 @@ short copy_animedit_keys(bAnimContext *ac, ListBase *anim_data)
}
/* in case 'relative' paste method is used */
- animcopy_cfra = CFRA;
+ animcopy_cfra = scene->r.cfra;
/* everything went fine */
return 0;
@@ -1121,7 +1050,7 @@ static void paste_animedit_keys_fcurve(
case KEYFRAME_PASTE_MERGE_OVER:
/* remove all keys */
- clear_fcurve_keys(fcu);
+ BKE_fcurve_delete_keys_all(fcu);
break;
case KEYFRAME_PASTE_MERGE_OVER_RANGE:
@@ -1148,7 +1077,7 @@ static void paste_animedit_keys_fcurve(
}
/* remove frames in the range */
- delete_fcurve_keys(fcu);
+ BKE_fcurve_delete_keys_selected(fcu);
}
break;
}
@@ -1182,7 +1111,7 @@ static void paste_animedit_keys_fcurve(
}
/* recalculate F-Curve's handles? */
- calchandles_fcurve(fcu);
+ BKE_fcurve_handles_recalc(fcu);
}
const EnumPropertyItem rna_enum_keyframe_paste_offset_items[] = {
@@ -1217,11 +1146,11 @@ const EnumPropertyItem rna_enum_keyframe_paste_merge_items[] = {
{0, NULL, 0, NULL, NULL},
};
-short paste_animedit_keys(bAnimContext *ac,
- ListBase *anim_data,
- const eKeyPasteOffset offset_mode,
- const eKeyMergeMode merge_mode,
- bool flip)
+eKeyPasteError paste_animedit_keys(bAnimContext *ac,
+ ListBase *anim_data,
+ const eKeyPasteOffset offset_mode,
+ const eKeyMergeMode merge_mode,
+ bool flip)
{
bAnimListElem *ale;
@@ -1235,25 +1164,23 @@ short paste_animedit_keys(bAnimContext *ac,
/* check if buffer is empty */
if (BLI_listbase_is_empty(&animcopybuf)) {
- BKE_report(ac->reports, RPT_ERROR, "No animation data in buffer to paste");
- return -1;
+ return KEYFRAME_PASTE_NOTHING_TO_PASTE;
}
if (BLI_listbase_is_empty(anim_data)) {
- BKE_report(ac->reports, RPT_ERROR, "No selected F-Curves to paste into");
- return -1;
+ return KEYFRAME_PASTE_NOWHERE_TO_PASTE;
}
/* methods of offset */
switch (offset_mode) {
case KEYFRAME_PASTE_OFFSET_CFRA_START:
- offset = (float)(CFRA - animcopy_firstframe);
+ offset = (float)(scene->r.cfra - animcopy_firstframe);
break;
case KEYFRAME_PASTE_OFFSET_CFRA_END:
- offset = (float)(CFRA - animcopy_lastframe);
+ offset = (float)(scene->r.cfra - animcopy_lastframe);
break;
case KEYFRAME_PASTE_OFFSET_CFRA_RELATIVE:
- offset = (float)(CFRA - animcopy_cfra);
+ offset = (float)(scene->r.cfra - animcopy_cfra);
break;
case KEYFRAME_PASTE_OFFSET_NONE:
offset = 0.0f;
@@ -1335,7 +1262,7 @@ short paste_animedit_keys(bAnimContext *ac,
ANIM_animdata_update(ac, anim_data);
- return 0;
+ return KEYFRAME_PASTE_OK;
}
/* **************************************************** */