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:
Diffstat (limited to 'source/blender/editors/animation/keyframes_general.c')
-rw-r--r--source/blender/editors/animation/keyframes_general.c76
1 files changed, 74 insertions, 2 deletions
diff --git a/source/blender/editors/animation/keyframes_general.c b/source/blender/editors/animation/keyframes_general.c
index ced3c117700..f13d35c7d4a 100644
--- a/source/blender/editors/animation/keyframes_general.c
+++ b/source/blender/editors/animation/keyframes_general.c
@@ -357,6 +357,76 @@ void smooth_fcurve (FCurve *fcu)
calchandles_fcurve(fcu);
}
+/* ---------------- */
+
+/* little cache for values... */
+typedef struct tempFrameValCache {
+ float frame, val;
+} tempFrameValCache;
+
+
+/* Evaluates the curves between each selected keyframe on each frame, and keys the value */
+void sample_fcurve (FCurve *fcu)
+{
+ BezTriple *bezt, *start=NULL, *end=NULL;
+ tempFrameValCache *value_cache, *fp;
+ int sfra, range;
+ int i, n, nIndex;
+
+ /* find selected keyframes... once pair has been found, add keyframes */
+ for (i=0, bezt=fcu->bezt; i < fcu->totvert; i++, bezt++) {
+ /* check if selected, and which end this is */
+ if (BEZSELECTED(bezt)) {
+ if (start) {
+ /* set end */
+ end= bezt;
+
+ /* cache values then add keyframes using these values, as adding
+ * keyframes while sampling will affect the outcome...
+ * - only start sampling+adding from index=1, so that we don't overwrite original keyframe
+ */
+ range= (int)( ceil(end->vec[1][0] - start->vec[1][0]) );
+ sfra= (int)( floor(start->vec[1][0]) );
+
+ if (range) {
+ value_cache= MEM_callocN(sizeof(tempFrameValCache)*range, "IcuFrameValCache");
+
+ /* sample values */
+ for (n=1, fp=value_cache; n<range && fp; n++, fp++) {
+ fp->frame= (float)(sfra + n);
+ fp->val= evaluate_fcurve(fcu, fp->frame);
+ }
+
+ /* add keyframes with these, tagging as 'breakdowns' */
+ for (n=1, fp=value_cache; n<range && fp; n++, fp++) {
+ nIndex= insert_vert_fcurve(fcu, fp->frame, fp->val, 1);
+ BEZKEYTYPE(fcu->bezt + nIndex)= BEZT_KEYTYPE_BREAKDOWN;
+ }
+
+ /* free temp cache */
+ MEM_freeN(value_cache);
+
+ /* as we added keyframes, we need to compensate so that bezt is at the right place */
+ bezt = fcu->bezt + i + range - 1;
+ i += (range - 1);
+ }
+
+ /* bezt was selected, so it now marks the start of a whole new chain to search */
+ start= bezt;
+ end= NULL;
+ }
+ else {
+ /* just set start keyframe */
+ start= bezt;
+ end= NULL;
+ }
+ }
+ }
+
+ /* recalculate channel's handles? */
+ calchandles_fcurve(fcu);
+}
+
/* **************************************************** */
/* Copy/Paste Tools */
/* - The copy/paste buffer currently stores a set of temporary F-Curves containing only the keyframes
@@ -529,8 +599,10 @@ short paste_animedit_keys (bAnimContext *ac, ListBase *anim_data)
bezt->vec[1][0] += offset;
bezt->vec[2][0] += offset;
- /* insert the keyframe */
- insert_bezt_fcurve(fcu, bezt);
+ /* insert the keyframe
+ * NOTE: no special flags here for now
+ */
+ insert_bezt_fcurve(fcu, bezt, 0);
/* un-apply offset from src beztriple after copying */
bezt->vec[0][0] -= offset;