Jump to content
  • Advertisement
Sign in to follow this  
DaveMS

Ogre AnimationState iterator

This topic is 3462 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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...
while(it->second->getEnabledAnimationStateIterator().hasMoreElements())
   it->second->getEnabledAnimationStateIterator().getNext()->addTime(0.3f);

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?

Share this post


Link to post
Share on other sites
Advertisement
No worries, I've found the problem.


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);



Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!