diff options
author | Joshua Leung <aligorith@gmail.com> | 2009-08-26 04:38:43 +0400 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2009-08-26 04:38:43 +0400 |
commit | 4893cdc33855e566dade323fa2f8486536821018 (patch) | |
tree | 0b62b01f06d45085aa59e3f8b7d04269df651aa8 /source/blender/editors/animation | |
parent | 3f5a2a11944a2e983d62babe8bb02b03e14c805d (diff) |
2.5 - Warning cleanups (for mingw+scons)
Also, made the Outliner's horizontal scrollbar work better for keymaps view. It's still using an approximation of the width, but at least you can scroll now.
Diffstat (limited to 'source/blender/editors/animation')
-rw-r--r-- | source/blender/editors/animation/keyframes_general.c | 131 |
1 files changed, 65 insertions, 66 deletions
diff --git a/source/blender/editors/animation/keyframes_general.c b/source/blender/editors/animation/keyframes_general.c index fc67ee34a2e..ced3c117700 100644 --- a/source/blender/editors/animation/keyframes_general.c +++ b/source/blender/editors/animation/keyframes_general.c @@ -127,11 +127,11 @@ void duplicate_fcurve_keys(FCurve *fcu) { BezTriple *newbezt; int i; - - if (fcu == NULL) + + /* this can only work when there is an F-Curve, and also when there are some BezTriples */ + if ELEM(NULL, fcu, fcu->bezt) return; - // XXX this does not take into account sample data... for (i=0; i < fcu->totvert; i++) { /* If a key is selected */ if (fcu->bezt[i].f2 & SELECT) { @@ -160,7 +160,7 @@ void duplicate_fcurve_keys(FCurve *fcu) /* **************************************************** */ /* Various Tools */ -/* Basic IPO-Curve 'cleanup' function that removes 'double points' and unnecessary keyframes on linear-segments only */ +/* Basic F-Curve 'cleanup' function that removes 'double points' and unnecessary keyframes on linear-segments only */ void clean_fcurve(FCurve *fcu, float thresh) { BezTriple *old_bezts, *bezt, *beztn; @@ -285,74 +285,74 @@ void smooth_fcurve (FCurve *fcu) } } - /* if any points were selected, allocate tSmooth_Bezt points to work on */ - if (totSel >= 3) { - tSmooth_Bezt *tarray, *tsb; - - /* allocate memory in one go */ - tsb= tarray= MEM_callocN(totSel*sizeof(tSmooth_Bezt), "tSmooth_Bezt Array"); - - /* populate tarray with data of selected points */ - bezt= fcu->bezt; - for (i=0, x=0; (i < fcu->totvert) && (x < totSel); i++, bezt++) { - if (BEZSELECTED(bezt)) { - /* tsb simply needs pointer to vec, and index */ - tsb->h1 = &bezt->vec[0][1]; - tsb->h2 = &bezt->vec[1][1]; - tsb->h3 = &bezt->vec[2][1]; - - /* advance to the next tsb to populate */ - if (x < totSel- 1) - tsb++; - else - break; - } + /* if any points were selected, allocate tSmooth_Bezt points to work on */ + if (totSel >= 3) { + tSmooth_Bezt *tarray, *tsb; + + /* allocate memory in one go */ + tsb= tarray= MEM_callocN(totSel*sizeof(tSmooth_Bezt), "tSmooth_Bezt Array"); + + /* populate tarray with data of selected points */ + bezt= fcu->bezt; + for (i=0, x=0; (i < fcu->totvert) && (x < totSel); i++, bezt++) { + if (BEZSELECTED(bezt)) { + /* tsb simply needs pointer to vec, and index */ + tsb->h1 = &bezt->vec[0][1]; + tsb->h2 = &bezt->vec[1][1]; + tsb->h3 = &bezt->vec[2][1]; + + /* advance to the next tsb to populate */ + if (x < totSel- 1) + tsb++; + else + break; } + } - /* calculate the new smoothed F-Curve's with weighted averages: - * - this is done with two passes - * - uses 5 points for each operation (which stores in the relevant handles) - * - previous: w/a ratio = 3:5:2:1:1 - * - next: w/a ratio = 1:1:2:5:3 - */ - - /* round 1: calculate previous and next */ - tsb= tarray; - for (i=0; i < totSel; i++, tsb++) { - /* don't touch end points (otherwise, curves slowly explode) */ - if (ELEM(i, 0, (totSel-1)) == 0) { - const tSmooth_Bezt *tP1 = tsb - 1; - const tSmooth_Bezt *tP2 = (i-2 > 0) ? (tsb - 2) : (NULL); - const tSmooth_Bezt *tN1 = tsb + 1; - const tSmooth_Bezt *tN2 = (i+2 < totSel) ? (tsb + 2) : (NULL); - - const float p1 = *tP1->h2; - const float p2 = (tP2) ? (*tP2->h2) : (*tP1->h2); - const float c1 = *tsb->h2; - const float n1 = *tN1->h2; - const float n2 = (tN2) ? (*tN2->h2) : (*tN1->h2); + /* calculate the new smoothed F-Curve's with weighted averages: + * - this is done with two passes + * - uses 5 points for each operation (which stores in the relevant handles) + * - previous: w/a ratio = 3:5:2:1:1 + * - next: w/a ratio = 1:1:2:5:3 + */ + + /* round 1: calculate previous and next */ + tsb= tarray; + for (i=0; i < totSel; i++, tsb++) { + /* don't touch end points (otherwise, curves slowly explode) */ + if (ELEM(i, 0, (totSel-1)) == 0) { + const tSmooth_Bezt *tP1 = tsb - 1; + const tSmooth_Bezt *tP2 = (i-2 > 0) ? (tsb - 2) : (NULL); + const tSmooth_Bezt *tN1 = tsb + 1; + const tSmooth_Bezt *tN2 = (i+2 < totSel) ? (tsb + 2) : (NULL); + + const float p1 = *tP1->h2; + const float p2 = (tP2) ? (*tP2->h2) : (*tP1->h2); + const float c1 = *tsb->h2; + const float n1 = *tN1->h2; + const float n2 = (tN2) ? (*tN2->h2) : (*tN1->h2); + + /* calculate previous and next */ + *tsb->h1= (3*p2 + 5*p1 + 2*c1 + n1 + n2) / 12; + *tsb->h3= (p2 + p1 + 2*c1 + 5*n1 + 3*n2) / 12; + } + } + + /* round 2: calculate new values and reset handles */ + tsb= tarray; + for (i=0; i < totSel; i++, tsb++) { + /* calculate new position by averaging handles */ + *tsb->h2 = (*tsb->h1 + *tsb->h3) / 2; - /* calculate previous and next */ - *tsb->h1= (3*p2 + 5*p1 + 2*c1 + n1 + n2) / 12; - *tsb->h3= (p2 + p1 + 2*c1 + 5*n1 + 3*n2) / 12; + /* reset handles now */ + *tsb->h1 = *tsb->h2; + *tsb->h3 = *tsb->h2; } - } - - /* round 2: calculate new values and reset handles */ - tsb= tarray; - for (i=0; i < totSel; i++, tsb++) { - /* calculate new position by averaging handles */ - *tsb->h2 = (*tsb->h1 + *tsb->h3) / 2; - /* reset handles now */ - *tsb->h1 = *tsb->h2; - *tsb->h3 = *tsb->h2; + /* free memory required for tarray */ + MEM_freeN(tarray); } - /* free memory required for tarray */ - MEM_freeN(tarray); -} - /* recalculate handles */ calchandles_fcurve(fcu); } @@ -371,7 +371,6 @@ ListBase animcopybuf = {NULL, NULL}; static float animcopy_firstframe= 999999999.0f; /* datatype for use in copy/paste buffer */ -// XXX F-Curve editor should use this too typedef struct tAnimCopybufItem { struct tAnimCopybufItem *next, *prev; |