From fb88d4eda8a807e79ecb100e82ac930250d871db Mon Sep 17 00:00:00 2001 From: Sebastian Parborg Date: Wed, 28 Oct 2020 11:45:24 +0100 Subject: Add a Un-Bake FCurves operator We already had the ability to bake fcurves but no way to convert the baked result back without using python. This patch adds and operator that is available now next to the bake operator in the drop down menu, Reviewed By: Sybren Differential Revision: http://developer.blender.org/D6379 --- source/blender/makesrna/intern/rna_fcurve_api.c | 47 +------------------------ 1 file changed, 1 insertion(+), 46 deletions(-) (limited to 'source/blender/makesrna/intern') diff --git a/source/blender/makesrna/intern/rna_fcurve_api.c b/source/blender/makesrna/intern/rna_fcurve_api.c index f7be65b4e75..5a720b91f87 100644 --- a/source/blender/makesrna/intern/rna_fcurve_api.c +++ b/source/blender/makesrna/intern/rna_fcurve_api.c @@ -76,52 +76,7 @@ static void rna_FCurve_convert_to_keyframes(FCurve *fcu, ReportList *reports, in BKE_report(reports, RPT_WARNING, "FCurve has no sample points"); } else { - BezTriple *bezt; - FPoint *fpt = fcu->fpt; - int tot_kf = end - start; - int tot_sp = fcu->totvert; - - bezt = fcu->bezt = MEM_callocN(sizeof(*fcu->bezt) * (size_t)tot_kf, __func__); - fcu->totvert = tot_kf; - - /* Get first sample point to 'copy' as keyframe. */ - for (; tot_sp && (fpt->vec[0] < (float)start); fpt++, tot_sp--) { - /* pass */ - } - - /* Add heading dummy flat points if needed. */ - for (; tot_kf && (fpt->vec[0] > (float)start); start++, bezt++, tot_kf--) { - /* Linear interpolation, of course. */ - bezt->f1 = bezt->f2 = bezt->f3 = SELECT; - bezt->ipo = BEZT_IPO_LIN; - bezt->h1 = bezt->h2 = HD_AUTO_ANIM; - bezt->vec[1][0] = (float)start; - bezt->vec[1][1] = fpt->vec[1]; - } - - /* Copy actual sample points. */ - for (; tot_kf && tot_sp; start++, bezt++, tot_kf--, fpt++, tot_sp--) { - /* Linear interpolation, of course. */ - bezt->f1 = bezt->f2 = bezt->f3 = SELECT; - bezt->ipo = BEZT_IPO_LIN; - bezt->h1 = bezt->h2 = HD_AUTO_ANIM; - copy_v2_v2(bezt->vec[1], fpt->vec); - } - - /* Add leading dummy flat points if needed. */ - for (fpt--; tot_kf; start++, bezt++, tot_kf--) { - /* Linear interpolation, of course. */ - bezt->f1 = bezt->f2 = bezt->f3 = SELECT; - bezt->ipo = BEZT_IPO_LIN; - bezt->h1 = bezt->h2 = HD_AUTO_ANIM; - bezt->vec[1][0] = (float)start; - bezt->vec[1][1] = fpt->vec[1]; - } - - MEM_SAFE_FREE(fcu->fpt); - - /* Not strictly needed since we use linear interpolation, but better be consistent here. */ - calchandles_fcurve(fcu); + fcurve_samples_to_keyframes(fcu, start, end); WM_main_add_notifier(NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); } } -- cgit v1.2.3