Minor fix to particle system AutoPlay flag handling

The previous commit broke some magic effects (e.g. shield). The controller's emit start/stop times should control the emitter, while the absence of the ParticleSystem's autoplay flag should freeze the whole particle system if no valid controller source gets assigned. This revised version works for both the Shield effect and the "dagoth ur death sparkles" effect.
This commit is contained in:
scrawl 2016-05-14 22:55:14 +02:00
parent 7202072196
commit 62018e802b
2 changed files with 6 additions and 3 deletions

View file

@ -439,12 +439,15 @@ ParticleSystemController::ParticleSystemController(const ParticleSystemControlle
void ParticleSystemController::operator() (osg::Node* node, osg::NodeVisitor* nv)
{
osgParticle::ParticleProcessor* emitter = static_cast<osgParticle::ParticleProcessor*>(node);
if (hasInput())
{
osgParticle::ParticleSystem* partsys = static_cast<osgParticle::ParticleSystem*>(node);
float time = getInputValue(nv);
partsys->setFrozen(!(time >= mEmitStart && time < mEmitStop));
emitter->getParticleSystem()->setFrozen(false);
emitter->setEnabled(time >= mEmitStart && time < mEmitStop);
}
else
emitter->getParticleSystem()->setFrozen(true);
traverse(node, nv);
}

View file

@ -994,7 +994,7 @@ namespace NifOsg
osg::ref_ptr<ParticleSystemController> callback(new ParticleSystemController(partctrl));
setupParticleController(partctrl, callback, particleflags);
partsys->setUpdateCallback(callback);
emitter->setUpdateCallback(callback);
if (!(particleflags & Nif::NiNode::ParticleFlag_AutoPlay))
{