Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5777 in orxonox.OLD for trunk/src/util/animation/animation_player.cc


Ignore:
Timestamp:
Nov 25, 2005, 3:37:11 AM (20 years ago)
Author:
bensch
Message:

orxonox/trunk: stl::list in AnimationPlayer

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/util/animation/animation_player.cc

    r5115 r5777  
    3131  this->setName("AnimationPlayer");
    3232
    33   this->animationList = new tList<Animation>();
    3433  this->play();
    3534}
     
    5251  // deleting the Animation List AND all the elements of the List
    5352  this->flush();
    54   delete this->animationList;
    5553
    5654  AnimationPlayer::singletonRef = NULL;
     
    6765void AnimationPlayer::addAnimation(Animation* animation)
    6866{
    69   this->animationList->add(animation);
     67  this->animationList.push_back(animation);
    7068}
    7169
     
    7674void AnimationPlayer::removeAnimation(Animation* animation)
    7775{
    78   this->animationList->remove(animation);
     76  this->animationList.remove(animation);
    7977}
    8078
     
    8583{
    8684  // deleting the Animation List AND all the elements of the List
    87   tIterator<Animation>* animIt = this->animationList->getIterator();
    88   Animation* anim = animIt->firstElement();
    89   while( anim != NULL)
    90     {
    91       delete anim;
    92       this->animationList->remove(anim);
    93       anim = animIt->nextElement();
    94     }
    95   delete animIt;
    96 
    97   delete this->animationList;
    98   this->animationList = new tList<Animation>();
     85  while(this->animationList.size() > 0)
     86  {
     87    Animation* anim = this->animationList.front();
     88    this->animationList.pop_front();
     89    delete anim;
     90  }
    9991}
    10092
     
    10294 *  Ticks all the animations in animationList
    10395 * @param timePassed the time passed since the last tick.
    104 */
     96 */
    10597void AnimationPlayer::tick(float timePassed)
    10698{
    10799  if (this->bRunning)
     100  {
     101      // iterate through all the animations and tick them.
     102    list<Animation*>::iterator anim;
     103    for (anim = this->animationList.begin(); anim != this->animationList.end(); anim++)
    108104    {
    109       // iterate through all the animations and tick them.
    110       tIterator<Animation>* animIt = this->animationList->getIterator();
    111       Animation* anim = animIt->firstElement();
    112       while( anim != NULL)
    113         {
    114           anim->tick(timePassed);
    115           if(unlikely(anim->ifDelete()))
    116           {
    117             this->animationList->remove(anim);
    118             delete anim;
    119           }
    120           anim = animIt->nextElement();
    121         }
    122       delete animIt;
     105      (*anim)->tick(timePassed);
     106      if(unlikely((*anim)->ifDelete()))
     107      {
     108        this->animationList.remove(*anim);
     109        delete *anim;
     110      }
    123111    }
     112  }
    124113}
    125114/**
    126115 *  starts playing the AnimationPlayer
    127 */
     116 */
    128117void AnimationPlayer::play()
    129118{
     
    133122/**
    134123 *  pauses playing of the AnimationPlayer
    135 */
     124 */
    136125void AnimationPlayer::pause()
    137126{
     
    146135Animation* AnimationPlayer::getAnimationFromBaseObject(const BaseObject* baseObject) const
    147136{
    148   tIterator<Animation>* animIt = this->animationList->getIterator();
    149   Animation* anim = animIt->firstElement();
    150   while( anim != NULL)
    151     {
    152       if(anim->getBaseObject() == baseObject)
    153         {
    154           delete animIt;
    155           return anim;
    156         }
    157       anim = animIt->nextElement();
    158     }
    159   delete animIt;
     137  list<Animation*>::const_iterator anim;
     138  for (anim = this->animationList.begin(); anim != this->animationList.end(); anim++)
     139    if((*anim)->getBaseObject() == baseObject)
     140      return *anim;
    160141  return NULL;
    161142}
     
    172153  PRINT(0)("+------------------------------------+\n");
    173154  PRINT(0)("| Reference: %p\n", this);
    174   PRINT(0)("| CountOfAnims %d\n", this->animationList->getSize());
     155  PRINT(0)("| CountOfAnims %d\n", this->animationList.size());
    175156  PRINT(0)("-Animation Information---------------+\n");
    176157  // Per ANIMATION DEBUG
    177   tIterator<Animation>* animIt = this->animationList->getIterator();
    178   Animation* anim = animIt->firstElement();
    179   while( anim != NULL)
     158  list<Animation*>::iterator anim;
     159  for (anim = this->animationList.begin(); anim != this->animationList.end(); anim++)
    180160    {
    181161      //      anim->debug();
    182       anim = animIt->nextElement();
    183162    }
    184   delete animIt;
    185 
    186163  PRINT(0)("+--------------------------------AP--+\n");
    187164}
Note: See TracChangeset for help on using the changeset viewer.