Changeset View
Changeset View
Standalone View
Standalone View
source/blender/makesrna/intern/rna_fcurve_api.c
| Show First 20 Lines • Show All 71 Lines • ▼ Show 20 Lines | static void rna_FCurve_convert_to_keyframes(FCurve *fcu, ReportList *reports, int start, int end) | ||||
| } | } | ||||
| else if (fcu->bezt) { | else if (fcu->bezt) { | ||||
| BKE_report(reports, RPT_WARNING, "FCurve has already keyframes"); | BKE_report(reports, RPT_WARNING, "FCurve has already keyframes"); | ||||
| } | } | ||||
| else if (!fcu->fpt) { | else if (!fcu->fpt) { | ||||
| BKE_report(reports, RPT_WARNING, "FCurve has no sample points"); | BKE_report(reports, RPT_WARNING, "FCurve has no sample points"); | ||||
| } | } | ||||
| else { | else { | ||||
| BezTriple *bezt; | fcurve_samples_to_keyframes(fcu, start, end); | ||||
| 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); | |||||
| WM_main_add_notifier(NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); | WM_main_add_notifier(NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); | ||||
| } | } | ||||
| } | } | ||||
| #else | #else | ||||
| void RNA_api_fcurves(StructRNA *srna) | void RNA_api_fcurves(StructRNA *srna) | ||||
| { | { | ||||
| Show All 33 Lines | |||||