Example #1
0
/* 'Paste' the F-Modifier(s) from the buffer to the specified list 
 *	- replace: free all the existing modifiers to leave only the pasted ones 
 */
short ANIM_fmodifiers_paste_from_buf(ListBase *modifiers, short replace)
{
	FModifier *fcm;
	short ok = 0;
	
	/* sanity checks */
	if (modifiers == NULL)
		return 0;
		
	/* if replacing the list, free the existing modifiers */
	if (replace)
		free_fmodifiers(modifiers);
		
	/* now copy over all the modifiers in the buffer to the end of the list */
	for (fcm = fmodifier_copypaste_buf.first; fcm; fcm = fcm->next) {
		/* make a copy of it */
		FModifier *fcmN = copy_fmodifier(fcm);
		
		/* make sure the new one isn't active, otherwise the list may get several actives */
		fcmN->flag &= ~FMODIFIER_FLAG_ACTIVE;
		
		/* now add it to the end of the list */
		BLI_addtail(modifiers, fcmN);
		ok = 1;
	}
	
	/* did we succeed? */
	return ok;
}
Example #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;
}
Example #3
0
/* free the copy/paste buffer */
void free_fmodifiers_copybuf(void)
{
	/* just free the whole buffer */
	free_fmodifiers(&fmodifier_copypaste_buf);
}