diff options
author | Joshua Leung <aligorith@gmail.com> | 2009-03-15 13:39:02 +0300 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2009-03-15 13:39:02 +0300 |
commit | 329aa658c97470a6ac2861c0c9b8108ff0c48182 (patch) | |
tree | 7ed0dac0fb21860dfaab04c4c5269ed6057249eb /source/blender/editors/space_graph/graph_edit.c | |
parent | 6508ad460fa91d605de2f62320711b19a319e2cb (diff) |
F-Curve Modifiers: Groundwork for getting these working
- Completed cleaning up the drawing code so that F-Curves with modifiers now get drawn to reflect this.
- Added a temporary operator to add modifiers (hotkey Ctrl-Shift-M)
Diffstat (limited to 'source/blender/editors/space_graph/graph_edit.c')
-rw-r--r-- | source/blender/editors/space_graph/graph_edit.c | 120 |
1 files changed, 117 insertions, 3 deletions
diff --git a/source/blender/editors/space_graph/graph_edit.c b/source/blender/editors/space_graph/graph_edit.c index d98ed38da9c..43a3b3628ad 100644 --- a/source/blender/editors/space_graph/graph_edit.c +++ b/source/blender/editors/space_graph/graph_edit.c @@ -1018,12 +1018,25 @@ void GRAPHEDIT_OT_keyframes_handletype (wmOperatorType *ot) * of values to -180 degrees to 180 degrees. */ +#if 0 // XXX this is not ready for the primetime yet + +/* set of three euler-rotation F-Curves */ +typedef struct tEulerFilter { + ID *id; /* ID-block which owns the channels */ + FCurve *fcu1, *fcu2, *fcu3; /* x,y,z rotation curves */ + int i1, i2, i3; /* current index for each curve */ +} tEulerFilter; + static int graphkeys_euler_filter_exec (bContext *C, wmOperator *op) { bAnimContext ac; - //ListBase anim_data= {NULL, NULL}; - //bAnimListElem *ale; - //int filter; + + ListBase anim_data= {NULL, NULL}; + bAnimListElem *ale; + int filter; + + ListBase eulers = {NULL, NULL}; + tEulerFilter *euf= NULL; /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) @@ -1035,7 +1048,33 @@ static int graphkeys_euler_filter_exec (bContext *C, wmOperator *op) * 2) Each set of three F-Curves is processed for each keyframe, with the values being * processed according to one of several ways. */ + + /* step 1: extract only the rotation f-curves */ + filter= (ANIMFILTER_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_CURVEVISIBLE | ANIMFILTER_CURVESONLY); + ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); + for (ale= anim_data.first; ale; ale= ale->next) { + FCurve *fcu = (FCurve *)ale->data; + + /* check if this is an appropriate F-Curve + * - only rotation curves + * - for pchan curves, make sure we're only using the euler curves + */ + if (ELEM(0, fcu->rna_path, strstr(fcu->rna_path, "rotation"))) + continue; + if (strstr(fcu->rna_path, "pose.pose_channels")) { + if (strstr(fcu->rna_path, "euler_rotation") == 0) + continue; + } + + /* check if current set of 3-curves is suitable to add this curve to + * - things like whether the current set of curves is 'full' should be checked later only + * - first check if id-blocks are compatible + */ + if ((euf) && (ale->id != euf->id)) { + + } + } // XXX for now return OPERATOR_CANCELLED; @@ -1055,6 +1094,8 @@ void GRAPHEDIT_OT_keyframes_euler_filter (wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; } +#endif // XXX this is not ready for the primetime yet + /* ***************** Snap Current Frame Operator *********************** */ /* helper callback for graphkeys_cfrasnap_exec() -> used to help get the average time of all selected beztriples */ @@ -1376,3 +1417,76 @@ void GRAPHEDIT_OT_keyframes_smooth (wmOperatorType *ot) } /* ************************************************************************** */ +/* F-CURVE MODIFIERS */ + +/* ******************** Add F-Curve Modifier Operator *********************** */ + +/* F-Modifier types - duplicate of existing codes... */ + // XXX how can we have this list from the RNA definitions instead? +EnumPropertyItem prop_fmodifier_types[] = { + {FMODIFIER_TYPE_GENERATOR, "GENERATOR", "Generator", ""}, + {FMODIFIER_TYPE_ENVELOPE, "ENVELOPE", "Envelope", ""}, + {FMODIFIER_TYPE_CYCLES, "CYCLES", "Cycles", ""}, + {FMODIFIER_TYPE_NOISE, "NOISE", "Noise", ""}, + {FMODIFIER_TYPE_FILTER, "FILTER", "Filter", ""}, + {FMODIFIER_TYPE_PYTHON, "PYTHON", "Python", ""}, + {0, NULL, NULL, NULL} +}; + +static int graph_fmodifier_add_exec(bContext *C, wmOperator *op) +{ + bAnimContext ac; + bAnimListElem *ale; + FCurve *fcu; + short type; + + /* get editor data */ + if (ANIM_animdata_get_context(C, &ac) == 0) + return OPERATOR_CANCELLED; + + // xxx call the raw methods here instead? + ale= get_active_fcurve_channel(&ac); + if (ale == NULL) + return OPERATOR_CANCELLED; + + fcu= (FCurve *)ale->data; + MEM_freeN(ale); + if (fcu == NULL) + return OPERATOR_CANCELLED; + + + /* get type of modifier to add */ + type= RNA_enum_get(op->ptr, "type"); + + /* add F-Modifier of specified type to active F-Curve */ + fcurve_add_modifier(fcu, type); + + + /* validate keyframes after editing */ + ANIM_editkeyframes_refresh(&ac); + + /* set notifier that things have changed */ + ANIM_animdata_send_notifiers(C, &ac, ANIM_CHANGED_BOTH); + + return OPERATOR_FINISHED; +} + +void GRAPHEDIT_OT_fmodifier_add (wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Add F-Curve Modifier"; + ot->idname= "GRAPHEDIT_OT_fmodifier_add"; + + /* api callbacks */ + ot->invoke= WM_menu_invoke; + ot->exec= graph_fmodifier_add_exec; + ot->poll= ED_operator_areaactive; // XXX need active F-Curve + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + + /* id-props */ + RNA_def_enum(ot->srna, "type", prop_fmodifier_types, 0, "Type", ""); +} + +/* ************************************************************************** */ |