]> git.tdb.fi Git - libs/gl.git/blobdiff - source/animation/animation.cpp
Add inline data items to the collection
[libs/gl.git] / source / animation / animation.cpp
index a8d9e9698625b027997586745cd71b9c73c1d305..b62f5dd9c74e035ed7fe0ab39ef69c46b3cbf714 100644 (file)
@@ -1,7 +1,9 @@
 #include <cmath>
 #include <msp/core/maputils.h>
 #include <msp/datafile/collection.h>
+#include <msp/fs/utils.h>
 #include <msp/interpolate/bezierspline.h>
+#include <msp/strings/format.h>
 #include "animation.h"
 #include "animationeventobserver.h"
 #include "armature.h"
@@ -20,6 +22,9 @@ Animation::Animation():
 
 Animation::~Animation()
 {
+       for(vector<TimedKeyFrame>::iterator i=keyframes.begin(); i!=keyframes.end(); ++i)
+               if(i->owned)
+                       delete i->keyframe;
        for(vector<Curve *>::iterator i=curves.begin(); i!=curves.end(); ++i)
                delete *i;
 }
@@ -155,9 +160,8 @@ void Animation::add_keyframe(const Time::TimeDelta &t, const KeyFrame *kf, bool
        TimedKeyFrame tkf;
        tkf.time = t;
        tkf.keyframe = kf;
-       if(!owned)
-               tkf.keyframe.keep();
        tkf.control = c;
+       tkf.owned = owned;
 
        keyframes.push_back(tkf);
 
@@ -553,7 +557,11 @@ void Animation::Loader::load_kf_inline(bool c)
 {
        RefPtr<KeyFrame> kf = new KeyFrame;
        if(coll)
-               load_sub(*kf, get_collection());
+       {
+               KeyFrame::Loader ldr(*kf, get_collection());
+               ldr.set_inline_base_name(format("%s/%d.kframe", FS::basename(get_source()), obj.keyframes.size()));
+               load_sub_with(ldr);
+       }
        else
                load_sub(*kf);