From: Mikko Rasa Date: Sun, 23 Jun 2019 19:37:22 +0000 (+0300) Subject: Add public functions for adding owned keyframes to Animation X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=f88bce7df357cf12ce20b7dc8c7d179d2ae95920;p=libs%2Fgl.git Add public functions for adding owned keyframes to Animation This is useful when constructing animations in code, to avoid the need of storing pointers to the keyframes. --- diff --git a/source/animation.cpp b/source/animation.cpp index 0d0ce75e..0e4bd3e6 100644 --- a/source/animation.cpp +++ b/source/animation.cpp @@ -50,6 +50,12 @@ void Animation::add_keyframe(const Time::TimeDelta &t, const KeyFrame &kf) create_curves(); } +void Animation::add_keyframe_owned(const Time::TimeDelta &t, const KeyFrame *kf) +{ + add_keyframe(t, kf, false, true); + create_curves(); +} + void Animation::add_keyframe(const Time::TimeDelta &t, const KeyFrame &kf, float slope) { add_keyframe(t, &kf, slope, slope, false); @@ -70,6 +76,14 @@ void Animation::add_control_keyframe(const KeyFrame &kf) add_keyframe(keyframes.back().time, &kf, true, false); } +void Animation::add_control_keyframe_owned(const KeyFrame *kf) +{ + if(keyframes.empty()) + throw invalid_operation("Animation::add_control_keyframe_owned"); + + add_keyframe(keyframes.back().time, kf, true, true); +} + void Animation::add_keyframe(const Time::TimeDelta &t, const KeyFrame *kf, float ss, float es, bool owned) { if(keyframes.empty()) diff --git a/source/animation.h b/source/animation.h index 616d0e74..d053ee90 100644 --- a/source/animation.h +++ b/source/animation.h @@ -182,9 +182,11 @@ public: const std::string &get_uniform_name(unsigned) const; void add_keyframe(const Time::TimeDelta &, const KeyFrame &); + void add_keyframe_owned(const Time::TimeDelta &, const KeyFrame *); DEPRECATED void add_keyframe(const Time::TimeDelta &, const KeyFrame &, float); DEPRECATED void add_keyframe(const Time::TimeDelta &, const KeyFrame &, float, float); void add_control_keyframe(const KeyFrame &); + void add_control_keyframe_owned(const KeyFrame *); private: void add_keyframe(const Time::TimeDelta &, const KeyFrame *, float, float, bool); void add_keyframe(const Time::TimeDelta &, const KeyFrame *, bool, bool);