]> git.tdb.fi Git - libs/gl.git/commitdiff
Provide a getter for the number of active animations
authorMikko Rasa <tdb@tdb.fi>
Wed, 15 Jul 2015 20:38:13 +0000 (23:38 +0300)
committerMikko Rasa <tdb@tdb.fi>
Wed, 15 Jul 2015 20:38:13 +0000 (23:38 +0300)
source/animationplayer.cpp
source/animationplayer.h

index eb18f0f94b42e43cf49ad8dfa6bbe95232b3a200..6148ed006bd0ebdfe0e27b15c0971b2bc7f56ac9 100644 (file)
@@ -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);
index cc34e16a513f411f1c427364f91eee18bda10b11..db338ffb25b24684975078544bbfa66b2435d6c5 100644 (file)
@@ -37,7 +37,7 @@ private:
                ObjectSlot(AnimatedObject &);
        };
 
-       typedef std::map<AnimatedObject *, ObjectSlot> ObjectMap;
+       typedef std::map<const AnimatedObject *, ObjectSlot> 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 &);