]> git.tdb.fi Git - libs/gl.git/commitdiff
Produce a linear animation curve if there's only one keyframe
authorMikko Rasa <tdb@tdb.fi>
Mon, 26 Aug 2019 11:53:21 +0000 (14:53 +0300)
committerMikko Rasa <tdb@tdb.fi>
Mon, 26 Aug 2019 11:53:21 +0000 (14:53 +0300)
This can be useful for setting a constant value for the duration of an
animation, without needing to specify the value twice.

source/animation.cpp

index b1ae1157fac6eeb8bbc64c5431845eef04c4f5a0..94c96809214215aa890797a24a9c774ff0401f74 100644 (file)
@@ -267,6 +267,14 @@ void Animation::create_curve(CurveTarget target, int component, const T &extract
        while(n_control--)
                knots.pop_back();
 
+       if(knots.size()==1)
+       {
+               knots.push_back(knots.back());
+               knots.push_back(knots.back());
+               knots.back().x += 1;
+               knots.push_back(knots.back());
+       }
+
        curves.push_back(new ValueCurve<N>(target, component, knots));
 }