X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Fanimation.cpp;h=ab9d6e6085c35a36d1f430b652586411e7849047;hp=f0e2630a502f6f43339ef7cbd1be8bcbe3aed7a3;hb=4e4a3514961d130045619ea74d0bbab71580838c;hpb=332352298ef41b8ac3a4c57b467dd146c0b05e0b diff --git a/source/animation.cpp b/source/animation.cpp index f0e2630a..ab9d6e60 100644 --- a/source/animation.cpp +++ b/source/animation.cpp @@ -1,7 +1,6 @@ #include #include #include -#include #include "animation.h" #include "animationeventobserver.h" #include "armature.h" @@ -61,6 +60,8 @@ void Animation::add_keyframe(const Time::TimeDelta &t, const KeyFrame &kf, float void Animation::add_keyframe(const Time::TimeDelta &t, const RefPtr &kf, float ss, float es) { + if(keyframes.empty() && t!=Time::zero) + throw invalid_argument("Animation::add_keyframe"); if(!keyframes.empty() && t1) + if(keyframes.size()>1 && t>(&tkf-1)->time) tkf.prev = &tkf-1; prepare_keyframe(tkf); @@ -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; @@ -262,7 +272,10 @@ Animation::Iterator::Iterator(const Animation &a): event_iter(animation->events.begin()), x(0), end(false) -{ } +{ + if(iter==animation->keyframes.end()) + throw invalid_argument("Animation::Iterator::Iterator"); +} Animation::Iterator &Animation::Iterator::operator+=(const Time::TimeDelta &t) {