while(it->second->getEnabledAnimationStateIterator().hasMoreElements())
it->second->getEnabledAnimationStateIterator().getNext()->addTime(0.3f);
Ogre AnimationState iterator
Hi,
I using Ogre, and want to iterate through the enabled AnimationStates in a AnimationStateSet, and add time to them.
Seems simple enough, but i'm doing it as so...
it->second is pointing to an AnimationStateSet.
I grab an iterator to iterate through all the enabled AnimationStates, check if there are more elements, and grab the next element. I then add time to it, and check if there is a next one, and so on...
I'm getting stuck in an infinite loop though, so i'm guessing the .hasMoreElements() method of the iterator doesn't stop when it reaches the end of the AnimationStateSet, but loops around to the beginning and starts again.
Anyone got any ideas how to iterate through all the AnimationStates of an AnimationStateSet until the last one is reached?
No worries, I've found the problem.
getEnabledAnimationStateIterator() will obviously get a new iterator starting from the beginning of the set.
So, i've been getting a new iterator from the beginning every time I request it.
I needed to keep hold of the iterator, and now it's working fine.
while(it->second->getEnabledAnimationStateIterator().hasMoreElements()) it->second->getEnabledAnimationStateIterator().getNext()->addTime(0.3f);
getEnabledAnimationStateIterator() will obviously get a new iterator starting from the beginning of the set.
So, i've been getting a new iterator from the beginning every time I request it.
I needed to keep hold of the iterator, and now it's working fine.
Ogre::ConstEnabledAnimationStateIterator asit = it->second->getEnabledAnimationStateIterator(); while(asit.hasMoreElements()) asit.getNext()->addTime(0.3f);
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement