Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3974 in orxonox.OLD


Ignore:
Timestamp:
Apr 26, 2005, 1:56:50 AM (20 years ago)
Author:
bensch
Message:

orxonox/branches/particleEngine: small speedUp, when creating many particles

File:
1 edited

Legend:

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

    r3958 r3974  
    128128    PRINTF(5)("emitting %f particles, saving %f seconds for the next round\n", count, this->saveTime);
    129129   
    130     for (int i = 0; i < count; i++)
    131       // emmits from EMITTER_DOT,
     130    if (likely(count > 0))
    132131      {
    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()*velocity + (this->getVelocity() * system->inheritSpeed);
    137 
    138         system->addParticle(this->getAbsCoor(), randDir);
     132        Vector inheritVelocity = this->getVelocity() * system->inheritSpeed;
     133        for (int i = 0; i < count; i++)
     134          // emmits from EMITTER_DOT,
     135          {
     136            Vector randDir = Vector(random()-RAND_MAX/2, random()-RAND_MAX/2, random()-RAND_MAX/2);
     137            randDir.normalize();
     138            randDir = (this->getAbsDir()*Quaternion(angle + randomAngle *((float)random()/RAND_MAX -.5), randDir)).apply(this->direction);
     139            randDir = randDir.getNormalized()*velocity + inheritVelocity;
     140           
     141            system->addParticle(this->getAbsCoor(), randDir);
     142          }
    139143      }
    140144  }
Note: See TracChangeset for help on using the changeset viewer.