Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3950 in orxonox.OLD


Ignore:
Timestamp:
Apr 24, 2005, 11:32:48 PM (19 years ago)
Author:
bensch
Message:

orxonox/branches/particleEngine: timing is ok now when emitting small numbers/sec

Location:
orxonox/branches/particleEngine/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • orxonox/branches/particleEngine/src/lib/graphics/particles/particle_emitter.cc

    r3944 r3950  
    120120void ParticleEmitter::tick(float dt, ParticleSystem* system)
    121121{
    122   // saving the time
    123   float count = (dt+this->saveTime) * this->emissionRate;
    124   this->saveTime = modff(count, &count);
    125   this->saveTime /= this->emissionRate;
    126 
    127 
    128   for (int i = 0; i <= count; i++)
    129     // emmits from EMITTER_DOT,
    130     {
    131       Vector randDir = Vector(random()-RAND_MAX/2, random()-RAND_MAX/2, random()-RAND_MAX/2);
    132       randDir.normalize();
    133       randDir = (this->getAbsDir()*Quaternion(angle + randomAngle *((float)random()/RAND_MAX -.5), randDir)).apply(this->direction);
    134       randDir = *randDir.getNormalized() + (this->getVelocity() * system->inheritSpeed);
    135 
    136       system->addParticle(this->getAbsCoor(), randDir* velocity);
    137     }
     122  if (likely(dt > 0.0 && this->emissionRate > 0.0))
     123  {
     124    // saving the time
     125    float count = (dt+this->saveTime) * this->emissionRate;
     126    this->saveTime = modff(count, &count);
     127    this->saveTime /= this->emissionRate;
     128    PRINTF(5)("emitting %f particles, saving %f seconds for the next round\n", count, this->saveTime);
     129   
     130    for (int i = 0; i < count; i++)
     131      // emmits from EMITTER_DOT,
     132      {
     133        Vector randDir = Vector(random()-RAND_MAX/2, random()-RAND_MAX/2, random()-RAND_MAX/2);
     134        randDir.normalize();
     135        randDir = (this->getAbsDir()*Quaternion(angle + randomAngle *((float)random()/RAND_MAX -.5), randDir)).apply(this->direction);
     136        randDir = *randDir.getNormalized() + (this->getVelocity() * system->inheritSpeed);
     137       
     138        system->addParticle(this->getAbsCoor(), randDir* velocity);
     139      }
     140  }
    138141}
    139142
  • orxonox/branches/particleEngine/src/lib/graphics/particles/particle_emitter.h

    r3944 r3950  
    2222
    2323 public:
    24   ParticleEmitter(const Vector& direction, float angle = .5, float emissionRate = 1.0, 
     24  ParticleEmitter(const Vector& direction, float angle = .5, float emissionRate = 1.0,
    2525                  float velocity = 1.0);
    2626  virtual ~ParticleEmitter(void);
  • orxonox/branches/particleEngine/src/story_entities/world.cc

    r3949 r3950  
    380380            ParticleEmitter* testEmitter,* testEmitter2;
    381381            ParticleSystem* testSystem;
    382             testEmitter = new ParticleEmitter(Vector(-1,0,0), .4, 120.0, .5);
     382            testEmitter = new ParticleEmitter(Vector(-1,0,0), .4, 60.0, 0);
    383383            testEmitter->setParent(localPlayer);
    384384            testEmitter->setRelCoor(Vector(-3, 0, 0));
     
    390390            */
    391391            testSystem = new ParticleSystem(10000);
    392             testSystem->setLifeSpan(.3, .2);
     392            testSystem->setLifeSpan(1, .2);
    393393            testSystem->setRadius(3.0, 0.0, .5);
    394394            testSystem->setConserve(.8);
Note: See TracChangeset for help on using the changeset viewer.