From: Mikko Rasa Date: Tue, 4 Jun 2019 22:42:49 +0000 (+0300) Subject: Check for armature mismatches in Animation X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=commitdiff_plain;h=a9c375e17065bcc429b430bd8211a9ee845159a5 Check for armature mismatches in Animation Also set the armature if a keyframe with a pose is added and there is no armature yet. --- diff --git a/source/animation.cpp b/source/animation.cpp index ab9d6e60..6c9e179d 100644 --- a/source/animation.cpp +++ b/source/animation.cpp @@ -23,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; } @@ -64,9 +66,14 @@ void Animation::add_keyframe(const Time::TimeDelta &t, const RefPtrget_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; diff --git a/source/pose.h b/source/pose.h index 41fc3de5..cbd8137b 100644 --- a/source/pose.h +++ b/source/pose.h @@ -48,6 +48,7 @@ public: Pose(const Armature &); void set_armature(const Armature &); + const Armature *get_armature() const { return armature; } void rotate_link(unsigned, float, const Vector3 &); const Matrix &get_link_matrix(unsigned) const; };