Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Leung <aligorith@gmail.com>2010-03-18 16:04:46 +0300
committerJoshua Leung <aligorith@gmail.com>2010-03-18 16:04:46 +0300
commit618b459e8b3630eea747523febec666889a364f7 (patch)
tree481c530e96e9e77ae09029f35a436475921bea39 /source/blender/editors/space_graph/graph_edit.c
parent148985edf03814b26f99bf4ae883c83db216ccf3 (diff)
F-Modifier Goodies (as requested by @ndy):
* Copy/Paste operators for F-Modifiers Available in Graph and NLA Editors. Use the Copy/Paste buttons beside the 'Add Modifier' buttons. Copy copies all the modifiers of the ACTIVE F-Curve or Strip depending on the editor. Paste pastes modifiers from the buffer to all the selected F-Curves or Strips, adding the new modifiers to the ends of each list. * 'Stepped Interpolation' F-Modifier This modifier holds each interpolated value from the F-Curve for several frames without changing the timing. This allows to preview motions 'on-twos' for example without altering the timing, or having to go through setting heaps of keyframes. In this case, Andy wanted to use this for CG <-> StopMo.
Diffstat (limited to 'source/blender/editors/space_graph/graph_edit.c')
-rw-r--r--source/blender/editors/space_graph/graph_edit.c117
1 files changed, 116 insertions, 1 deletions
diff --git a/source/blender/editors/space_graph/graph_edit.c b/source/blender/editors/space_graph/graph_edit.c
index 485c9ab8bf4..d23bafbc001 100644
--- a/source/blender/editors/space_graph/graph_edit.c
+++ b/source/blender/editors/space_graph/graph_edit.c
@@ -1971,7 +1971,7 @@ static int graph_fmodifier_add_exec(bContext *C, wmOperator *op)
filter |= (ANIMFILTER_SEL|ANIMFILTER_CURVEVISIBLE);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
- /* smooth keyframes */
+ /* add f-modifier to each curve */
for (ale= anim_data.first; ale; ale= ale->next) {
FCurve *fcu= (FCurve *)ale->data;
FModifier *fcm;
@@ -2017,4 +2017,119 @@ void GRAPH_OT_fmodifier_add (wmOperatorType *ot)
RNA_def_boolean(ot->srna, "only_active", 1, "Only Active", "Only add F-Modifier to active F-Curve.");
}
+/* ******************** Copy F-Modifiers Operator *********************** */
+
+static int graph_fmodifier_copy_exec(bContext *C, wmOperator *op)
+{
+ bAnimContext ac;
+ bAnimListElem *ale;
+ short ok = 0;
+
+ /* get editor data */
+ if (ANIM_animdata_get_context(C, &ac) == 0)
+ return OPERATOR_CANCELLED;
+
+ /* clear buffer first */
+ free_fmodifiers_copybuf();
+
+ /* get the active F-Curve */
+ ale= get_active_fcurve_channel(&ac);
+
+ /* if this exists, call the copy F-Modifiers API function */
+ if (ale && ale->data) {
+ FCurve *fcu= (FCurve *)ale->data;
+
+ // TODO: when 'active' vs 'all' boolean is added, change last param!
+ ok= ANIM_fmodifiers_copy_to_buf(&fcu->modifiers, 0);
+
+ /* free temp data now */
+ MEM_freeN(ale);
+ }
+
+ /* successful or not? */
+ if (ok == 0) {
+ BKE_report(op->reports, RPT_ERROR, "No F-Modifiers available to be copied");
+ return OPERATOR_CANCELLED;
+ }
+ else
+ return OPERATOR_FINISHED;
+}
+
+void GRAPH_OT_fmodifier_copy (wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name= "Copy F-Modifiers";
+ ot->idname= "GRAPH_OT_fmodifier_copy";
+ ot->description= "Copy the F-Modifier(s) of the active F-Curve.";
+
+ /* api callbacks */
+ ot->exec= graph_fmodifier_copy_exec;
+ ot->poll= graphop_active_fcurve_poll;
+
+ /* flags */
+ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+
+ /* id-props */
+ //ot->prop = RNA_def_boolean(ot->srna, "all", 1, "All F-Modifiers", "Copy all the F-Modifiers, instead of just the active one");
+}
+
+/* ******************** Paste F-Modifiers Operator *********************** */
+
+static int graph_fmodifier_paste_exec(bContext *C, wmOperator *op)
+{
+ bAnimContext ac;
+ ListBase anim_data = {NULL, NULL};
+ bAnimListElem *ale;
+ int filter, ok=0;
+
+ /* get editor data */
+ if (ANIM_animdata_get_context(C, &ac) == 0)
+ return OPERATOR_CANCELLED;
+
+ /* filter data */
+ filter= (ANIMFILTER_VISIBLE | ANIMFILTER_CURVEVISIBLE | ANIMFILTER_SEL | ANIMFILTER_FOREDIT | ANIMFILTER_CURVESONLY);
+ ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
+
+ /* paste modifiers */
+ for (ale = anim_data.first; ale; ale = ale->next) {
+ FCurve *fcu= (FCurve *)ale->data;
+
+ // TODO: do we want to replace existing modifiers? add user pref for that!
+ ok += ANIM_fmodifiers_paste_from_buf(&fcu->modifiers, 0);
+ }
+
+ /* clean up */
+ BLI_freelistN(&anim_data);
+
+ /* successful or not? */
+ if (ok) {
+ /* validate keyframes after editing */
+ ANIM_editkeyframes_refresh(&ac);
+
+ /* set notifier that keyframes have changed */
+ WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME_EDIT, NULL);
+
+ return OPERATOR_FINISHED;
+ }
+ else {
+ BKE_report(op->reports, RPT_ERROR, "No F-Modifiers to paste");
+ return OPERATOR_CANCELLED;
+ }
+}
+
+void GRAPH_OT_fmodifier_paste (wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name= "Paste F-Modifiers";
+ ot->idname= "GRAPH_OT_fmodifier_paste";
+ ot->description= "Add copied F-Modifiers to the selected F-Curves";
+
+ /* api callbacks */
+ ot->exec= graph_fmodifier_paste_exec;
+ ot->poll= graphop_editable_keyframes_poll;
+
+ /* flags */
+ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
/* ************************************************************************** */