X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;ds=sidebyside;f=source%2Fanimation.cpp;h=6c9e179dc749dc16642b5b755f6afd7e36fecf2b;hb=a9c375e17065bcc429b430bd8211a9ee845159a5;hp=b58a4ea77e0e0c3193c2eec31074aa91912b72c7;hpb=bfeb6c6404659fffb1222e084b0bd08cccb4e67d;p=libs%2Fgl.git diff --git a/source/animation.cpp b/source/animation.cpp index b58a4ea7..6c9e179d 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" @@ -24,6 +23,8 @@ Animation::~Animation() void Animation::set_armature(const Armature &a) { + if(!keyframes.empty() && &a!=armature) + throw invalid_operation("Animation::set_armature"); armature = &a; } @@ -61,11 +62,18 @@ 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() && tget_pose() && armature && kf->get_pose()->get_armature()!=armature) + throw invalid_argument("Animation::add_keyframe"); bool realloc = (keyframes.size()>=keyframes.capacity()); + if(kf->get_pose() && !armature) + armature = kf->get_pose()->get_armature(); + keyframes.push_back(TimedKeyFrame()); TimedKeyFrame &tkf = keyframes.back(); tkf.time = t; @@ -76,9 +84,10 @@ void Animation::add_keyframe(const Time::TimeDelta &t, const RefPtr1) + if(keyframes.size()>1 && t>(&tkf-1)->time) tkf.prev = &tkf-1; prepare_keyframe(tkf); @@ -270,7 +279,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) {