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.
pull/945/head
scrawl 9 years ago
parent 7202072196
commit 62018e802b

@ -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);
}

@ -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))
{

Loading…
Cancel
Save