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);
|
return endpoint_bezt->vec[1][1] - (fac * dx);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Calculate F-Curve value for 'evaltime' using BezTriple keyframes */
|
static float fcurve_eval_keyframes_interpolate(FCurve *fcu, BezTriple *bezts, float evaltime)
|
||||||
static float fcurve_eval_keyframes(FCurve *fcu, BezTriple *bezts, float evaltime)
|
|
||||||
{
|
{
|
||||||
const float eps = 1.e-8f;
|
const float eps = 1.e-8f;
|
||||||
BezTriple *bezt, *prevbezt, *lastbezt;
|
BezTriple *bezt, *prevbezt;
|
||||||
float v1[2], v2[2], v3[2], v4[2], opl[32];
|
float v1[2], v2[2], v3[2], v4[2], opl[32];
|
||||||
unsigned int a;
|
unsigned int a;
|
||||||
int b;
|
int b;
|
||||||
@@ -1476,16 +1475,7 @@ static float fcurve_eval_keyframes(FCurve *fcu, BezTriple *bezts, float evaltime
|
|||||||
a = fcu->totvert - 1;
|
a = fcu->totvert - 1;
|
||||||
prevbezt = bezts;
|
prevbezt = bezts;
|
||||||
bezt = prevbezt + 1;
|
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 */
|
/* evaltime occurs somewhere in the middle of the curve */
|
||||||
bool exact = false;
|
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);
|
cvalue = BLI_easing_back_ease_out(time, begin, change, duration, prevbezt->back);
|
||||||
break;
|
break;
|
||||||
case BEZT_IPO_EASE_IN_OUT:
|
case BEZT_IPO_EASE_IN_OUT:
|
||||||
cvalue = BLI_easing_back_ease_in_out(
|
cvalue = BLI_easing_back_ease_in_out(time, begin, change, duration, prevbezt->back);
|
||||||
time, begin, change, duration, prevbezt->back);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default: /* default/auto: same as ease out */
|
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));
|
fabsf(bezt->vec[1][0] - evaltime));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return cvalue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* return value */
|
/* Calculate F-Curve value for 'evaltime' using BezTriple keyframes */
|
||||||
return cvalue;
|
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 */
|
/* Calculate F-Curve value for 'evaltime' using FPoint samples */
|
||||||
|
Reference in New Issue
Block a user