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>2009-03-01 14:27:31 +0300
committerJoshua Leung <aligorith@gmail.com>2009-03-01 14:27:31 +0300
commitd9c9108a6e62894d6ab696235af9a0af25693c76 (patch)
tree1261d026d7e7f873bea23d449d7fe9523805a366 /source/blender/editors/space_graph/graph_edit.c
parentdb472a3d14f81086ea1b472d4da6dded0879d84c (diff)
Graph Editor: Added operator to 'bake' keyframe-based F-Curves to be composed of samples.
This operator can be activated using the 'Alt-C' hotkey for now, and operates on selected + editable F-Curves. This is currently still highly experimental, and does crash I've implemented this as a way to test out the FPoints/samples code, which will be used to provide better support of the dense F-Curves which result from importing Mocap/BVH data. These should use considerably less memory + have a few additional benefits over keyframes when they're working in a stable fashion.
Diffstat (limited to 'source/blender/editors/space_graph/graph_edit.c')
-rw-r--r--source/blender/editors/space_graph/graph_edit.c83
1 files changed, 83 insertions, 0 deletions
diff --git a/source/blender/editors/space_graph/graph_edit.c b/source/blender/editors/space_graph/graph_edit.c
index ab6dff36909..932b22c0a6e 100644
--- a/source/blender/editors/space_graph/graph_edit.c
+++ b/source/blender/editors/space_graph/graph_edit.c
@@ -554,7 +554,90 @@ void GRAPHEDIT_OT_keyframes_clean (wmOperatorType *ot)
RNA_def_float(ot->srna, "threshold", 0.001f, 0.0f, FLT_MAX, "Threshold", "", 0.0f, 1000.0f);
}
+/* ******************** Bake F-Curve Operator *********************** */
+/* This operator bakes the data of the selected F-Curves to F-Points */
+
+/* Bake each F-Curve into a set of samples */
+static void bake_graph_curves (bAnimContext *ac, int start, int end)
+{
+ ListBase anim_data = {NULL, NULL};
+ bAnimListElem *ale;
+ int filter;
+
+ /* filter data */
+ filter= (ANIMFILTER_VISIBLE | ANIMFILTER_CURVEVISIBLE | ANIMFILTER_SEL | ANIMFILTER_FOREDIT | ANIMFILTER_CURVESONLY);
+ ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
+
+ /* loop through filtered data and add keys between selected keyframes on every frame */
+ for (ale= anim_data.first; ale; ale= ale->next) {
+ FCurve *fcu= (FCurve *)ale->key_data;
+ ChannelDriver *driver= fcu->driver;
+
+ /* disable driver so that it don't muck up the sampling process */
+ fcu->driver= NULL;
+
+ /* create samples */
+ fcurve_store_samples(fcu, NULL, start, end, fcurve_samplingcb_evalcurve);
+
+ /* restore driver */
+ fcu->driver= driver;
+ }
+
+ /* admin and redraws */
+ BLI_freelistN(&anim_data);
+}
+
+/* ------------------- */
+
+static int graphkeys_bake_exec(bContext *C, wmOperator *op)
+{
+ bAnimContext ac;
+ Scene *scene= NULL;
+ int start, end;
+
+ /* get editor data */
+ if (ANIM_animdata_get_context(C, &ac) == 0)
+ return OPERATOR_CANCELLED;
+
+ /* for now, init start/end from preview-range extents */
+ // TODO: add properties for this
+ scene= ac.scene;
+ start= PSFRA;
+ end= PEFRA;
+
+ /* bake keyframes */
+ bake_graph_curves(&ac, start, end);
+
+ /* validate keyframes after editing */
+ ANIM_editkeyframes_refresh(&ac);
+
+ /* set notifier tha things have changed */
+ ANIM_animdata_send_notifiers(C, &ac, ANIM_CHANGED_KEYFRAMES_VALUES);
+
+ return OPERATOR_FINISHED;
+}
+
+void GRAPHEDIT_OT_keyframes_bake (wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name= "Bake Curve";
+ ot->idname= "GRAPHEDIT_OT_keyframes_bake";
+
+ /* api callbacks */
+ ot->invoke= WM_operator_confirm; // FIXME...
+ ot->exec= graphkeys_bake_exec;
+ ot->poll= ED_operator_areaactive;
+
+ /* flags */
+ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+
+ // todo: add props for start/end frames
+}
+
/* ******************** Sample Keyframes Operator *********************** */
+/* This operator 'bakes' the values of the curve into new keyframes between pairs
+ * of selected keyframes. It is useful for creating keyframes for tweaking overlap.
+ */
// XXX some of the common parts (with DopeSheet) should be unified in animation module...