Cleanup: Animation, split FCurve interpolation into separate function
This commit is contained in:
@@ -1462,11 +1462,10 @@ static float fcurve_eval_keyframes_extrapolate(
|
||||
return endpoint_bezt->vec[1][1] - (fac * dx);
|
||||
}
|
||||
|
||||
/* Calculate F-Curve value for 'evaltime' using BezTriple keyframes */
|
||||
static float fcurve_eval_keyframes(FCurve *fcu, BezTriple *bezts, float evaltime)
|
||||
static float fcurve_eval_keyframes_interpolate(FCurve *fcu, BezTriple *bezts, float evaltime)
|
||||
{
|
||||
const float eps = 1.e-8f;
|
||||
BezTriple *bezt, *prevbezt, *lastbezt;
|
||||
BezTriple *bezt, *prevbezt;
|
||||
float v1[2], v2[2], v3[2], v4[2], opl[32];
|
||||
unsigned int a;
|
||||
int b;
|
||||
@@ -1476,16 +1475,7 @@ static float fcurve_eval_keyframes(FCurve *fcu, BezTriple *bezts, float evaltime
|
||||
a = fcu->totvert - 1;
|
||||
prevbezt = bezts;
|
||||
bezt = prevbezt + 1;
|
||||
lastbezt = prevbezt + a;
|
||||
|
||||
/* evaluation time at or past endpoints? */
|
||||
if (prevbezt->vec[1][0] >= evaltime) {
|
||||
cvalue = fcurve_eval_keyframes_extrapolate(fcu, bezts, evaltime, 0, +1);
|
||||
}
|
||||
else if (lastbezt->vec[1][0] <= evaltime) {
|
||||
cvalue = fcurve_eval_keyframes_extrapolate(fcu, bezts, evaltime, fcu->totvert - 1, -1);
|
||||
}
|
||||
else {
|
||||
/* evaltime occurs somewhere in the middle of the curve */
|
||||
bool exact = false;
|
||||
|
||||
@@ -1602,8 +1592,7 @@ static float fcurve_eval_keyframes(FCurve *fcu, BezTriple *bezts, float evaltime
|
||||
cvalue = BLI_easing_back_ease_out(time, begin, change, duration, prevbezt->back);
|
||||
break;
|
||||
case BEZT_IPO_EASE_IN_OUT:
|
||||
cvalue = BLI_easing_back_ease_in_out(
|
||||
time, begin, change, duration, prevbezt->back);
|
||||
cvalue = BLI_easing_back_ease_in_out(time, begin, change, duration, prevbezt->back);
|
||||
break;
|
||||
|
||||
default: /* default/auto: same as ease out */
|
||||
@@ -1793,10 +1782,23 @@ static float fcurve_eval_keyframes(FCurve *fcu, BezTriple *bezts, float evaltime
|
||||
fabsf(bezt->vec[1][0] - evaltime));
|
||||
}
|
||||
}
|
||||
|
||||
return cvalue;
|
||||
}
|
||||
|
||||
/* return value */
|
||||
return cvalue;
|
||||
/* Calculate F-Curve value for 'evaltime' using BezTriple keyframes */
|
||||
static float fcurve_eval_keyframes(FCurve *fcu, BezTriple *bezts, float evaltime)
|
||||
{
|
||||
if (evaltime <= bezts->vec[1][0]) {
|
||||
return fcurve_eval_keyframes_extrapolate(fcu, bezts, evaltime, 0, +1);
|
||||
}
|
||||
|
||||
BezTriple *lastbezt = bezts + fcu->totvert - 1;
|
||||
if (lastbezt->vec[1][0] <= evaltime) {
|
||||
return fcurve_eval_keyframes_extrapolate(fcu, bezts, evaltime, fcu->totvert - 1, -1);
|
||||
}
|
||||
|
||||
return fcurve_eval_keyframes_interpolate(fcu, bezts, evaltime);
|
||||
}
|
||||
|
||||
/* Calculate F-Curve value for 'evaltime' using FPoint samples */
|
||||
|
Reference in New Issue
Block a user