X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fanimation.cpp;h=a8d9e9698625b027997586745cd71b9c73c1d305;hb=47bfbdc8cf844aa079995fca34a3b906b49a4f66;hp=37f583d5ec53b43324e67f7fcd1237a25bbefa80;hpb=b0dfcfb5cdd73e7515170c0598d6b061d33446a7;p=libs%2Fgl.git diff --git a/source/animation.cpp b/source/animation.cpp index 37f583d5..a8d9e969 100644 --- a/source/animation.cpp +++ b/source/animation.cpp @@ -18,9 +18,11 @@ Animation::Animation(): looping(false) { } -// Avoid synthesizing ~RefPtr in files including animation.h Animation::~Animation() -{ } +{ + for(vector::iterator i=curves.begin(); i!=curves.end(); ++i) + delete *i; +} void Animation::set_armature(const Armature &a) { @@ -265,6 +267,14 @@ void Animation::create_curve(CurveTarget target, int component, const T &extract while(n_control--) knots.pop_back(); + if(knots.size()==1) + { + knots.push_back(knots.back()); + knots.push_back(knots.back()); + knots.back().x += 1; + knots.push_back(knots.back()); + } + curves.push_back(new ValueCurve(target, component, knots)); } @@ -334,12 +344,18 @@ void Animation::ValueCurve<1>::apply(float x, Matrix &matrix) const float value = spline(x); if(target==POSITION || target==SCALE) { - Vector3 vec; - vec[component] = value; if(target==POSITION) + { + Vector3 vec; + vec[component] = value; matrix.translate(vec); + } else + { + Vector3 vec(1.0f, 1.0f, 1.0f); + vec[component] = value; matrix.scale(vec); + } } else if(target==EULER) { @@ -375,7 +391,7 @@ void Animation::ValueCurve::apply(float x, KeyFrame::AnimatedUniform &uni) co uni.size = N; typename Interpolate::Spline::Value value = spline(x); for(unsigned i=0; i::get(value, i); + uni.values[i] = Interpolate::SplineValue::get(value, i); }