|
|
|
@ -923,15 +923,18 @@ namespace NifOsg
|
|
|
|
|
osg::BoundingBox box;
|
|
|
|
|
|
|
|
|
|
int i=0;
|
|
|
|
|
for (std::vector<Nif::NiParticleSystemController::Particle>::const_iterator it = partctrl->particles.begin();
|
|
|
|
|
i<particledata->activeCount && it != partctrl->particles.end(); ++it, ++i)
|
|
|
|
|
for (const auto& particle : partctrl->particles)
|
|
|
|
|
{
|
|
|
|
|
const Nif::NiParticleSystemController::Particle& particle = *it;
|
|
|
|
|
if (i++ >= particledata->activeCount)
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
if (particle.lifespan <= 0)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
ParticleAgeSetter particletemplate(std::max(0.f, particle.lifetime));
|
|
|
|
|
|
|
|
|
|
osgParticle::Particle* created = partsys->createParticle(&particletemplate);
|
|
|
|
|
created->setLifeTime(std::max(0.f, particle.lifespan));
|
|
|
|
|
created->setLifeTime(particle.lifespan);
|
|
|
|
|
|
|
|
|
|
// Note this position and velocity is not correct for a particle system with absolute reference frame,
|
|
|
|
|
// which can not be done in this loader since we are not attached to the scene yet. Will be fixed up post-load in the SceneManager.
|
|
|
|
@ -970,6 +973,8 @@ namespace NifOsg
|
|
|
|
|
osgParticle::ConstantRateCounter* counter = new osgParticle::ConstantRateCounter;
|
|
|
|
|
if (partctrl->emitFlags & Nif::NiParticleSystemController::NoAutoAdjust)
|
|
|
|
|
counter->setNumberOfParticlesPerSecondToCreate(partctrl->emitRate);
|
|
|
|
|
else if (partctrl->lifetime == 0 && partctrl->lifetimeRandom == 0)
|
|
|
|
|
counter->setNumberOfParticlesPerSecondToCreate(0);
|
|
|
|
|
else
|
|
|
|
|
counter->setNumberOfParticlesPerSecondToCreate(partctrl->numParticles / (partctrl->lifetime + partctrl->lifetimeRandom/2));
|
|
|
|
|
|
|
|
|
|