Implement auto-adjusting of particle emit rate

This makes ashcloud.nif and blightcloud.nif work properly.
deque
scrawl 11 years ago
parent 1d46ac19ff
commit 30be59c029

@ -89,7 +89,14 @@ public:
float lifetime;
float lifetimeRandom;
int emitFlags; // Bit 0: Emit Rate toggle bit (0 = auto adjust, 1 = use Emit Rate value)
enum EmitFlags
{
NoAutoAdjust = 0x1 // If this flag is set, we use the emitRate value. Otherwise,
// we calculate an emit rate so that the maximum number of particles
// in the system (numParticles) is never exceeded.
};
int emitFlags;
Ogre::Vector3 offsetRandom;
NodePtr emitter;

@ -756,7 +756,12 @@ class NIFObjectLoader
Ogre::ParticleEmitter *emitter = partsys->addEmitter("Nif");
emitter->setParticleVelocity(partctrl->velocity - partctrl->velocityRandom*0.5f,
partctrl->velocity + partctrl->velocityRandom*0.5f);
emitter->setEmissionRate(partctrl->emitRate);
if (partctrl->emitFlags & Nif::NiParticleSystemController::NoAutoAdjust)
emitter->setEmissionRate(partctrl->emitRate);
else
emitter->setEmissionRate(partctrl->numParticles / (partctrl->lifetime + partctrl->lifetimeRandom/2));
emitter->setTimeToLive(partctrl->lifetime,
partctrl->lifetime + partctrl->lifetimeRandom);
emitter->setParameter("width", Ogre::StringConverter::toString(partctrl->offsetRandom.x));

Loading…
Cancel
Save