{
for(ObjectMap::iterator i=objects.begin(); i!=objects.end(); )
{
- bool keep = false;
if(i->second.stacked)
- keep = tick_stacked(i->second, dt);
+ tick_stacked(i->second, dt);
else
- keep = tick_single(i->second, dt);
+ tick_single(i->second, dt);
- if(!keep)
+ if(i->second.animations.empty())
objects.erase(i++);
else
++i;
}
}
-bool AnimationPlayer::tick_single(Target &target, const Time::TimeDelta &dt)
+void AnimationPlayer::tick_single(Target &target, const Time::TimeDelta &dt)
{
PlayingAnimation &anim = target.animations.front();
anim.iterator += dt;
target.object.set_pose_matrix(i, anim.iterator.get_pose_matrix(i));
}
- return !anim.iterator.is_end();
+ if(!anim.iterator.is_end())
+ target.animations.clear();
}
-bool AnimationPlayer::tick_stacked(Target &target, const Time::TimeDelta &dt)
+void AnimationPlayer::tick_stacked(Target &target, const Time::TimeDelta &dt)
{
Matrix matrix = target.base_matrix;
for(vector<PlayingAnimation>::iterator i=target.animations.begin(); i!=target.animations.end(); ++i)
++i;
}
- return !target.animations.empty();
+ if(target.animations.empty())
+ target.stacked = false;
}
void AnimationPlayer::set_object_uniform(AnimatedObject &obj, const string &name, const KeyFrame::AnimatedUniform &uni)
void tick(const Time::TimeDelta &);
private:
- bool tick_single(Target &, const Time::TimeDelta &);
- bool tick_stacked(Target &, const Time::TimeDelta &);
+ void tick_single(Target &, const Time::TimeDelta &);
+ void tick_stacked(Target &, const Time::TimeDelta &);
static void set_object_uniform(AnimatedObject &, const std::string &, const KeyFrame::AnimatedUniform &);
};