]> git.tdb.fi Git - libs/gl.git/blobdiff - source/animation.cpp
Require the first keyframe of an animation to be at zero offset
[libs/gl.git] / source / animation.cpp
index f0e2630a502f6f43339ef7cbd1be8bcbe3aed7a3..02a2d371c71c1d32baff99aa3a120429d8c90d91 100644 (file)
@@ -61,6 +61,8 @@ void Animation::add_keyframe(const Time::TimeDelta &t, const KeyFrame &kf, float
 
 void Animation::add_keyframe(const Time::TimeDelta &t, const RefPtr<const KeyFrame> &kf, float ss, float es)
 {
+       if(keyframes.empty() && t!=Time::zero)
+               throw invalid_argument("Animation::add_keyframe");
        if(!keyframes.empty() && t<keyframes.back().time)
                throw invalid_argument("Animation::add_keyframe");
 
@@ -114,6 +116,14 @@ void Animation::add_event(const Time::TimeDelta &t, const string &n, const Varia
        events.push_back(event);
 }
 
+const Time::TimeDelta &Animation::get_duration() const
+{
+       if(keyframes.empty())
+               return Time::zero;
+
+       return keyframes.back().time;
+}
+
 void Animation::set_looping(bool l)
 {
        looping = l;