/* Remove all of a given F-Curve's modifiers */ void free_fmodifiers(ListBase *modifiers) { FModifier *fcm, *fmn; /* sanity check */ if (modifiers == NULL) return; /* free each modifier in order - modifier is unlinked from list and freed */ for (fcm = modifiers->first; fcm; fcm = fmn) { fmn = fcm->next; remove_fmodifier(modifiers, fcm); } }
/* callback to remove the given modifier */ static void delete_fmodifier_cb(bContext *C, void *fmods_v, void *fcm_v) { ListBase *modifiers = (ListBase *)fmods_v; FModifier *fcm = (FModifier *)fcm_v; /* remove the given F-Modifier from the active modifier-stack */ remove_fmodifier(modifiers, fcm); ED_undo_push(C, "Delete F-Curve Modifier"); /* send notifiers */ // XXX for now, this is the only way to get updates in all the right places... but would be nice to have a special one in this case WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); }
/* this function is responsible for setting extrapolation mode for keyframes */ static void setexpo_action_keys(bAnimContext *ac, short mode) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; /* filter data */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_SEL /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* loop through setting mode per F-Curve */ for (ale = anim_data.first; ale; ale = ale->next) { FCurve *fcu = (FCurve *)ale->data; if (mode >= 0) { /* just set mode setting */ fcu->extend = mode; } else { /* shortcuts for managing Cycles F-Modifiers to make it easier to toggle cyclic animation * without having to go through FModifier UI in Graph Editor to do so */ if (mode == MAKE_CYCLIC_EXPO) { /* only add if one doesn't exist */ if (list_has_suitable_fmodifier(&fcu->modifiers, FMODIFIER_TYPE_CYCLES, -1) == 0) { /* TODO: add some more preset versions which set different extrapolation options? */ add_fmodifier(&fcu->modifiers, FMODIFIER_TYPE_CYCLES); } } else if (mode == CLEAR_CYCLIC_EXPO) { /* remove all the modifiers fitting this description */ FModifier *fcm, *fcn = NULL; for (fcm = fcu->modifiers.first; fcm; fcm = fcn) { fcn = fcm->next; if (fcm->type == FMODIFIER_TYPE_CYCLES) remove_fmodifier(&fcu->modifiers, fcm); } } } ale->update |= ANIM_UPDATE_DEFAULT; } ANIM_animdata_update(ac, &anim_data); ANIM_animdata_freelist(&anim_data); }