Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 11, 2008, 3:06:33 AM (16 years ago)
Author:
landauf
Message:

Added TimeFactorListener to properly handle changes of the global time factor (makes the game faster or slower). Currently supported in Backlight, ParticleInterface and Timer, which were all critical classes I could think of (all other classes are already covered by the adjustment of dt in tick(dt)). It seems to work well, both with small values (0.1, 0.01) and great values (10, 100). Even pausing the game (0) works fine.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/objecthierarchy2/src/orxonox/tools/ParticleInterface.cc

    r2171 r2406  
    5252    ParticleInterface::ParticleInterface(Ogre::SceneManager* scenemanager, const std::string& templateName, LODParticle::LOD detaillevel)
    5353    {
    54         RegisterRootObject(ParticleInterface);
     54        RegisterObject(ParticleInterface);
    5555
    5656        assert(scenemanager);
     
    6969            {
    7070                this->particleSystem_ = this->scenemanager_->createParticleSystem("particles" + getConvertedValue<unsigned int, std::string>(ParticleInterface::counter_s++), templateName);
    71                 this->particleSystem_->setSpeedFactor(1.0f);
    72 //                this->particleSystem_->setSpeedFactor(Orxonox::getInstance().getTimeFactor());
     71                this->setSpeedFactor(1.0f);
    7372            }
    7473            catch (...)
     
    224223    void ParticleInterface::setSpeedFactor(float factor)
    225224    {
    226         if (this->particleSystem_)
    227         {
    228 //            this->particleSystem_->setSpeedFactor(Orxonox::getInstance().getTimeFactor() * factor);
    229             this->particleSystem_->setSpeedFactor(1.0f * factor);
    230         }
    231     }
    232     float ParticleInterface::getSpeedFactor() const
    233     {
    234         if (this->particleSystem_)
    235         {
    236 //            return (this->particleSystem_->getSpeedFactor() / Orxonox::getInstance().getTimeFactor());
    237             return (this->particleSystem_->getSpeedFactor() / 1.0f);
    238         }
    239         else
    240             return 1.0f;
     225        this->speedFactor_ = factor;
     226
     227        if (this->particleSystem_)
     228            this->particleSystem_->setSpeedFactor(factor * this->getTimeFactor());
     229    }
     230    void ParticleInterface::changedTimeFactor(float factor_new, float factor_old)
     231    {
     232        this->setSpeedFactor(this->speedFactor_);
    241233    }
    242234
Note: See TracChangeset for help on using the changeset viewer.