[Bf-blender-cvs] [53cbbcb] gooseberry: Keep interpolation type of keyframes when cleaning

Antony Riakiotakis noreply at git.blender.org
Wed May 20 16:24:35 CEST 2015


Commit: 53cbbcbb21fde90a5c7a6ff860a3d11443213145
Author: Antony Riakiotakis
Date:   Wed May 20 16:23:55 2015 +0200
Branches: gooseberry
https://developer.blender.org/rB53cbbcbb21fde90a5c7a6ff860a3d11443213145

Keep interpolation type of keyframes when cleaning

Not sure how well that will work in practice, but there's a
whole studio of people ready to test.

===================================================================

M	source/blender/editors/animation/keyframes_general.c

===================================================================

diff --git a/source/blender/editors/animation/keyframes_general.c b/source/blender/editors/animation/keyframes_general.c
index 19e32b5..abfbbe5 100644
--- a/source/blender/editors/animation/keyframes_general.c
+++ b/source/blender/editors/animation/keyframes_general.c
@@ -179,6 +179,17 @@ void duplicate_fcurve_keys(FCurve *fcu)
 /* **************************************************** */
 /* Various Tools */
 
+static void copy_bezt_ipo(BezTriple *bezdst, BezTriple *bezsrc)
+{
+	bezdst->back = bezsrc->back;
+	bezdst->ipo = bezsrc->ipo;
+	bezdst->easing = bezsrc->easing;
+	bezdst->amplitude = bezsrc->amplitude;
+	bezdst->period = bezsrc->period;
+	bezdst->h1 = bezsrc->h1;
+	bezdst->h2 = bezsrc->h2;
+}
+
 /* Basic F-Curve 'cleanup' function that removes 'double points' and unnecessary keyframes on linear-segments only
  * optionally clears up curve if one keyframe with default value remains */
 void clean_fcurve(struct bAnimContext *ac, bAnimListElem *ale, float thresh, bool cleardefault)
@@ -232,7 +243,8 @@ void clean_fcurve(struct bAnimContext *ac, bAnimListElem *ale, float thresh, boo
 		cur[0] = bezt->vec[1][0]; cur[1] = bezt->vec[1][1];
 
 		if (!(bezt->f2 & SELECT)) {
-			insert_vert_fcurve(fcu, cur[0], cur[1], 0);
+			insert_vert_fcurve(fcu, cur[0], cur[1], INSERTKEY_FAST);
+			copy_bezt_ipo((fcu->bezt + (fcu->totvert - 1)), bezt);
 			lastb = (fcu->bezt + (fcu->totvert - 1));
 			lastb->f1 = lastb->f2 = lastb->f3 = 0;
 			continue;
@@ -251,7 +263,8 @@ void clean_fcurve(struct bAnimContext *ac, bAnimListElem *ale, float thresh, boo
 				if (cur[1] > next[1]) {
 					if (IS_EQT(cur[1], prev[1], thresh) == 0) {
 						/* add new keyframe */
-						insert_vert_fcurve(fcu, cur[0], cur[1], 0);
+						insert_vert_fcurve(fcu, cur[0], cur[1], INSERTKEY_FAST);
+						copy_bezt_ipo((fcu->bezt + (fcu->totvert - 1)), bezt);
 					}
 				}
 			}
@@ -259,7 +272,8 @@ void clean_fcurve(struct bAnimContext *ac, bAnimListElem *ale, float thresh, boo
 				/* only add if values are a considerable distance apart */
 				if (IS_EQT(cur[1], prev[1], thresh) == 0) {
 					/* add new keyframe */
-					insert_vert_fcurve(fcu, cur[0], cur[1], 0);
+					insert_vert_fcurve(fcu, cur[0], cur[1], INSERTKEY_FAST);
+					copy_bezt_ipo((fcu->bezt + (fcu->totvert - 1)), bezt);
 				}
 			}
 		}
@@ -269,22 +283,27 @@ void clean_fcurve(struct bAnimContext *ac, bAnimListElem *ale, float thresh, boo
 				/* does current have same value as previous and next? */
 				if (IS_EQT(cur[1], prev[1], thresh) == 0) {
 					/* add new keyframe*/
-					insert_vert_fcurve(fcu, cur[0], cur[1], 0);
+					insert_vert_fcurve(fcu, cur[0], cur[1], INSERTKEY_FAST);
+					copy_bezt_ipo((fcu->bezt + (fcu->totvert - 1)), bezt);
 				}
 				else if (IS_EQT(cur[1], next[1], thresh) == 0) {
 					/* add new keyframe */
-					insert_vert_fcurve(fcu, cur[0], cur[1], 0);
+					insert_vert_fcurve(fcu, cur[0], cur[1], INSERTKEY_FAST);
+					copy_bezt_ipo((fcu->bezt + (fcu->totvert - 1)), bezt);
 				}
 			}
 			else {
 				/* add if value doesn't equal that of previous */
 				if (IS_EQT(cur[1], prev[1], thresh) == 0) {
 					/* add new keyframe */
-					insert_vert_fcurve(fcu, cur[0], cur[1], 0);
+					insert_vert_fcurve(fcu, cur[0], cur[1], INSERTKEY_FAST);
+					copy_bezt_ipo((fcu->bezt + (fcu->totvert - 1)), bezt);
 				}
 			}
 		}
 	}
+
+	calchandles_fcurve(fcu);
 	
 	/* now free the memory used by the old BezTriples */
 	if (old_bezts)




More information about the Bf-blender-cvs mailing list