Fix T102690: Object can be animated with a single keyframe

Remove some assumptions that an FCurve with a single keyframe always is
extrapolated in constant fashion. There's no reason for the Beziér handles
to be ignored in such a case.

FCurve evaluation already worked properly, it was just the drawing in the
graph editor and the selectability of the handles that needed adjustments.
This commit is contained in:
Sybren A. Stüvel 2023-02-02 16:00:58 +01:00
parent c1b85103fe
commit c2c6707919
Notes: blender-bot 2023-03-24 15:15:45 +01:00
Referenced by issue #102690, Object can be animated with a single keyframe
Referenced by issue #106095, Regression: Disabling "Show Extrapolation" stops curve drawing in Graph Editor
Referenced by commit d5d8246441, Fix #106095: FCurves not drawn when Extrapolation is disabled
2 changed files with 8 additions and 10 deletions

View File

@ -389,10 +389,7 @@ static bool draw_fcurve_handles_check(SpaceGraph *sipo, FCurve *fcu)
(fcu->flag & FCURVE_INT_VALUES) ||
#endif
/* group that curve belongs to is not editable */
((fcu->grp) && (fcu->grp->flag & AGRP_PROTECTED)) ||
/* Do not show handles if there is only 1 keyframe,
* otherwise they all clump together in an ugly ball. */
(fcu->totvert <= 1)) {
((fcu->grp) && (fcu->grp->flag & AGRP_PROTECTED))) {
return false;
}
return true;
@ -707,7 +704,7 @@ static void draw_fcurve_curve_samples(bAnimContext *ac,
const uint shdr_pos,
const bool draw_extrapolation)
{
if (!draw_extrapolation && fcu->totvert == 1) {
if (!draw_extrapolation) {
return;
}
@ -820,7 +817,7 @@ static bool fcurve_can_use_simple_bezt_drawing(FCurve *fcu)
static void draw_fcurve_curve_bezts(
bAnimContext *ac, ID *id, FCurve *fcu, View2D *v2d, uint pos, const bool draw_extrapolation)
{
if (!draw_extrapolation && fcu->totvert == 1) {
if (!draw_extrapolation) {
return;
}
@ -852,7 +849,7 @@ static void draw_fcurve_curve_bezts(
/* y-value depends on the interpolation */
if ((fcu->extend == FCURVE_EXTRAPOLATE_CONSTANT) || (prevbezt->ipo == BEZT_IPO_CONST) ||
(fcu->totvert == 1)) {
(prevbezt->ipo == BEZT_IPO_LIN && fcu->totvert == 1)) {
/* just extend across the first keyframe's value */
v1[1] = prevbezt->vec[1][1];
}
@ -971,7 +968,8 @@ static void draw_fcurve_curve_bezts(
/* y-value depends on the interpolation */
if ((fcu->extend == FCURVE_EXTRAPOLATE_CONSTANT) || (fcu->flag & FCURVE_INT_VALUES) ||
(prevbezt->ipo == BEZT_IPO_CONST) || (fcu->totvert == 1)) {
(prevbezt->ipo == BEZT_IPO_CONST) ||
(prevbezt->ipo == BEZT_IPO_LIN && fcu->totvert == 1)) {
/* based on last keyframe's value */
v1[1] = prevbezt->vec[1][1];
}

View File

@ -210,8 +210,8 @@ static void get_nearest_fcurve_verts_list(bAnimContext *ac, const int mval[2], L
unit_scale,
offset);
/* handles - only do them if they're visible */
if (fcurve_handle_sel_check(sipo, bezt1) && (fcu->totvert > 1)) {
/* Handles. */
if (fcurve_handle_sel_check(sipo, bezt1)) {
/* first handle only visible if previous segment had handles */
if ((!prevbezt && (bezt1->ipo == BEZT_IPO_BEZ)) ||
(prevbezt && (prevbezt->ipo == BEZT_IPO_BEZ))) {