mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-30 06:15:32 +00:00
Implement auto-adjusting of particle emit rate
This makes ashcloud.nif and blightcloud.nif work properly.
This commit is contained in:
parent
1d46ac19ff
commit
30be59c029
2 changed files with 14 additions and 2 deletions
|
@ -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…
Reference in a new issue