]> git.tdb.fi Git - libs/gl.git/commitdiff
Don't link keyframes with zero interval
authorMikko Rasa <tdb@tdb.fi>
Mon, 2 Jul 2018 11:44:23 +0000 (14:44 +0300)
committerMikko Rasa <tdb@tdb.fi>
Mon, 2 Jul 2018 11:44:23 +0000 (14:44 +0300)
Fixes an issue where a lone instant keyframe at the end of the animation
would produce bad values as the iterator tries to divide by zero.

source/animation.cpp

index 1cfb533f94eb3cd901ecba9dc501d28433224a15..e82a92a87ce4811b3e465b345e6f5477d1c61f27 100644 (file)
@@ -78,9 +78,10 @@ void Animation::add_keyframe(const Time::TimeDelta &t, const RefPtr<const KeyFra
        if(realloc)
        {
                for(unsigned i=1; i<keyframes.size(); ++i)
-                       keyframes[i].prev = &keyframes[i-1];
+                       if(keyframes[i].prev)
+                               keyframes[i].prev = &keyframes[i-1];
        }
-       else if(keyframes.size()>1)
+       if(keyframes.size()>1 && t>(&tkf-1)->time)
                tkf.prev = &tkf-1;
 
        prepare_keyframe(tkf);