Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 14, 2009, 12:51:34 AM (14 years ago)
Author:
rgrieder
Message:

Overriding preDestroy() in AmbientSound to make them fade out when the level unloads.
@Kevin: this should also prevent the random bug you showed me when reloading a level with ambient sound.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentation2/src/orxonox/sound/SoundManager.cc

    r6332 r6349  
    314314    {
    315315        if (oldAmbient == NULL || ambientSounds_.empty())
    316         {
    317316            return;
    318         }
     317
    319318        if (this->ambientSounds_.front().first == oldAmbient)
    320319        {
     
    468467   
    469468
    470     void SoundManager::fadeIn(AmbientSound* sound)
     469    void SoundManager::fadeIn(const SmartPtr<AmbientSound>& sound)
    471470    {
    472471        // If we're already fading out --> remove that
    473         for (std::list<AmbientSound*>::iterator it = this->fadeOutList_.begin(); it != this->fadeOutList_.end(); it++)
     472        for (std::list<SmartPtr<AmbientSound> >::iterator it = this->fadeOutList_.begin(); it != this->fadeOutList_.end(); it++)
    474473        {
    475474            if (*it == sound)
     
    484483    }
    485484
    486     void SoundManager::fadeOut(AmbientSound* sound)
     485    void SoundManager::fadeOut(const SmartPtr<AmbientSound>& sound)
    487486    {
    488487        // If we're already fading in --> remove that
    489         for (std::list<AmbientSound*>::iterator it = this->fadeInList_.begin(); it != this->fadeInList_.end(); it++)
     488        for (std::list<SmartPtr<AmbientSound> >::iterator it = this->fadeInList_.begin(); it != this->fadeInList_.end(); it++)
    490489        {
    491490            if (*it == sound)
     
    510509       
    511510        // FADE IN
    512         for (std::list<AmbientSound*>::iterator it= this->fadeInList_.begin(); it != this->fadeInList_.end(); )
     511        for (std::list<SmartPtr<AmbientSound> >::iterator it= this->fadeInList_.begin(); it != this->fadeInList_.end(); )
    513512        {
    514513            if ((*it)->getVolume() + this->crossFadeStep_*dt > 1.0f)
     
    525524
    526525        // FADE OUT
    527         for (std::list<AmbientSound*>::iterator it = this->fadeOutList_.begin(); it != this->fadeOutList_.end(); )
     526        for (std::list<SmartPtr<AmbientSound> >::iterator it = this->fadeOutList_.begin(); it != this->fadeOutList_.end(); )
    528527        {
    529528            if ((*it)->getVolume() - this->crossFadeStep_*dt < 0.0f)
Note: See TracChangeset for help on using the changeset viewer.