static void rna_FCurve_convert_to_samples(FCurve *fcu, ReportList *reports, int start, int end)
{
	/* XXX fcurve_store_samples uses end frame included, which is not consistent with usual behavior in Blender,
	 * nor python slices, etc. Let have public py API be consistent here at least. */
	end--;
	if (start > end) {
		BKE_reportf(reports, RPT_ERROR, "Invalid frame range (%d - %d)", start, end + 1);
	}
	else if (fcu->fpt) {
		BKE_report(reports, RPT_WARNING, "FCurve has already sample points");
	}
	else if (!fcu->bezt) {
		BKE_report(reports, RPT_WARNING, "FCurve has no keyframes");
	}
	else {
		fcurve_store_samples(fcu, NULL, start, end, fcurve_samplingcb_evalcurve);
		WM_main_add_notifier(NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
	}
}
Exemple #2
0
/* Bake modifiers for given F-Curve to curve sample data, in the frame range defined
 * by start and end (inclusive).
 */
void fcurve_bake_modifiers(FCurve *fcu, int start, int end)
{
	ChannelDriver *driver;
	
	/* sanity checks */
	// TODO: make these tests report errors using reports not printf's
	if (ELEM(NULL, fcu, fcu->modifiers.first)) {
		printf("Error: No F-Curve with F-Curve Modifiers to Bake\n");
		return;
	}
	
	/* temporarily, disable driver while we sample, so that they don't influence the outcome */
	driver = fcu->driver;
	fcu->driver = NULL;
	
	/* bake the modifiers, by sampling the curve at each frame */
	fcurve_store_samples(fcu, NULL, start, end, fcurve_samplingcb_evalcurve);
	
	/* free the modifiers now */
	free_fmodifiers(&fcu->modifiers);
	
	/* restore driver */
	fcu->driver = driver;
}