From 62018e802b3a0cd38e0f4d6deb44fcb6608bb476 Mon Sep 17 00:00:00 2001 From: scrawl Date: Sat, 14 May 2016 22:55:14 +0200 Subject: [PATCH] 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. --- components/nifosg/controller.cpp | 7 +++++-- components/nifosg/nifloader.cpp | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/components/nifosg/controller.cpp b/components/nifosg/controller.cpp index ce6ab2c48..5a3a7ac59 100644 --- a/components/nifosg/controller.cpp +++ b/components/nifosg/controller.cpp @@ -439,12 +439,15 @@ ParticleSystemController::ParticleSystemController(const ParticleSystemControlle void ParticleSystemController::operator() (osg::Node* node, osg::NodeVisitor* nv) { + osgParticle::ParticleProcessor* emitter = static_cast(node); if (hasInput()) { - osgParticle::ParticleSystem* partsys = static_cast(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); } diff --git a/components/nifosg/nifloader.cpp b/components/nifosg/nifloader.cpp index 324c7796d..172d92abe 100644 --- a/components/nifosg/nifloader.cpp +++ b/components/nifosg/nifloader.cpp @@ -994,7 +994,7 @@ namespace NifOsg osg::ref_ptr callback(new ParticleSystemController(partctrl)); setupParticleController(partctrl, callback, particleflags); - partsys->setUpdateCallback(callback); + emitter->setUpdateCallback(callback); if (!(particleflags & Nif::NiNode::ParticleFlag_AutoPlay)) {