Next dgough
@@ -172,6 +172,18 @@ void Animation::pause(const char * clipId)
}
+bool Animation::targets(AnimationTarget* target) const
+{
+ for (std::vector<Animation::Channel*>::const_iterator itr = _channels.begin(); itr != _channels.end(); ++itr)
+ {
+ if ((*itr)->_target == target)
+ return true;
+ }
+ return false;
+}
+
void Animation::createDefaultClip()
{
_defaultClip = new AnimationClip("default_clip", this, 0.0f, _duration);
@@ -89,6 +89,11 @@ public:
*/
void pause(const char* clipId = NULL);
+ /**
+ * Returns true if this animation targets the given AnimationTarget.
+ */
+ bool targets(AnimationTarget* target) const;
private:
/**
@@ -112,6 +112,22 @@ Animation* AnimationController::getAnimation(const char* id) const
return NULL;
+Animation* AnimationController::getAnimation(AnimationTarget* target) const
+ if (!target)
+ return NULL;
+ const unsigned int animationCount = _animations.size();
+ for (unsigned int i = 0; i < animationCount; ++i)
+ Animation* animation = _animations[i];
+ if (animation->targets(target))
+ return animation;
void AnimationController::stopAllAnimations()
std::list<AnimationClip*>::iterator clipIter = _runningClips.begin();
@@ -106,6 +106,11 @@ public:
Animation* getAnimation(const char* id) const;
+ * Returns the first animation that targets the given AnimationTarget.
+ Animation* getAnimation(AnimationTarget* target) const;
* Stops all AnimationClips currently playing on the AnimationController.