From: Mikko Rasa Date: Wed, 15 Jul 2015 20:38:13 +0000 (+0300) Subject: Provide a getter for the number of active animations X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=cd7dff6e8cf6a7b678b359e1cf02695ad688468f;p=libs%2Fgl.git Provide a getter for the number of active animations --- diff --git a/source/animationplayer.cpp b/source/animationplayer.cpp index eb18f0f9..6148ed00 100644 --- a/source/animationplayer.cpp +++ b/source/animationplayer.cpp @@ -37,6 +37,12 @@ void AnimationPlayer::play_stacked(AnimatedObject &obj, const Animation &anim) obj_slot.animations.push_back(AnimationSlot(anim)); } +unsigned AnimationPlayer::get_n_active_animations(const AnimatedObject &obj) const +{ + ObjectMap::const_iterator i = objects.find(&obj); + return (i!=objects.end() ? i->second.animations.size() : 0); +} + void AnimationPlayer::stop(AnimatedObject &obj) { objects.erase(&obj); diff --git a/source/animationplayer.h b/source/animationplayer.h index cc34e16a..db338ffb 100644 --- a/source/animationplayer.h +++ b/source/animationplayer.h @@ -37,7 +37,7 @@ private: ObjectSlot(AnimatedObject &); }; - typedef std::map ObjectMap; + typedef std::map ObjectMap; ObjectMap objects; @@ -52,6 +52,9 @@ public: playing yet, the object's current matrix is used as the base. */ void play_stacked(AnimatedObject &, const Animation &); + /// Returns the number of animations currently affecting an object. + unsigned get_n_active_animations(const AnimatedObject &) const; + /// Stops any animations affecting an object. void stop(AnimatedObject &);