void Animation::add_keyframe(const Time::TimeDelta &t, const KeyFrame &kf)
{
- RefPtr<const KeyFrame> kfr(&kf);
- kfr.keep();
- add_keyframe(t, kfr, false);
+ add_keyframe(t, &kf, false, false);
create_curves();
}
if(keyframes.empty())
throw invalid_operation("Animation::add_control_keyframe");
- RefPtr<const KeyFrame> kfr(&kf);
- kfr.keep();
- add_keyframe(keyframes.back().time, kfr, true);
+ add_keyframe(keyframes.back().time, &kf, true, false);
}
-void Animation::add_keyframe(const Time::TimeDelta &t, const RefPtr<const KeyFrame> &kf, bool c)
+void Animation::add_keyframe(const Time::TimeDelta &t, const KeyFrame *kf, bool c, bool owned)
{
if(c && keyframes.empty())
throw invalid_argument("Animation::add_keyframe");
TimedKeyFrame tkf;
tkf.time = t;
tkf.keyframe = kf;
+ if(!owned)
+ tkf.keyframe.keep();
tkf.control = c;
keyframes.push_back(tkf);
void Animation::Loader::load_kf(const string &n, bool c)
{
- obj.add_keyframe(current_time, get_collection().get<KeyFrame>(n), c);
+ obj.add_keyframe(current_time, &get_collection().get<KeyFrame>(n), c, false);
}
void Animation::Loader::load_kf_inline(bool c)
else
load_sub(*kf);
- obj.add_keyframe(current_time, kf, c);
+ obj.add_keyframe(current_time, *kf, c, true);
+ kf.release();
}
void Animation::Loader::control_keyframe(const string &n)
void add_keyframe(const Time::TimeDelta &, const KeyFrame &, float, float);
void add_control_keyframe(const KeyFrame &);
private:
- void add_keyframe(const Time::TimeDelta &, const RefPtr<const KeyFrame> &, bool);
+ void add_keyframe(const Time::TimeDelta &, const KeyFrame *, bool, bool);
void prepare_keyframe(TimedKeyFrame &);
void create_curves();
template<unsigned N, typename T>