- const KeyFrame::UniformMap &kf_uniforms = i->keyframe->get_uniforms();
- const KeyFrame::UniformMap::const_iterator j = kf_uniforms.find(name);
- if(j!=kf_uniforms.end())
- knots.push_back(Knot(i->time/Time::sec, Interpolate::SplineValue<float, N>::make(j->second.values)));
+ if(i->control && knots.empty())
+ continue;
+
+ typename Interpolate::SplineValue<float, N>::Type value;
+ if(extract(*i->keyframe, value))
+ {
+ float x = i->time/Time::sec;
+ if(i->control)
+ {
+ ++n_control;
+ if(n_control>2)
+ throw logic_error("too many control keyframes");
+ }
+ else
+ {
+ if(n_control==1)
+ {
+ typename Knot::Value cv = knots.back().y;
+ knots.back().y = (knots[knots.size()-2].y+cv*2.0f)/3.0f;
+ knots.push_back(Knot(x, (value+cv*2.0f)/3.0f));
+ }
+ else if(n_control==0 && !knots.empty())
+ {
+ typename Knot::Value prev = knots.back().y;
+ knots.push_back(Knot(knots.back().x, (prev*2.0f+value)/3.0f));
+ knots.push_back(Knot(x, (prev+value*2.0f)/3.0f));
+ }
+ n_control = 0;
+ }
+ knots.push_back(Knot(x, value));
+ }