From e30bb31a791eaeb403a5b7a0f0c29df316e30086 Mon Sep 17 00:00:00 2001 From: scrawl Date: Sat, 14 May 2016 22:35:34 +0200 Subject: [PATCH] Handle the particle node's AutoPlay flag (Bug #3390) --- components/nifosg/nifloader.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/components/nifosg/nifloader.cpp b/components/nifosg/nifloader.cpp index 9db672d9ef..874ca9eaa1 100644 --- a/components/nifosg/nifloader.cpp +++ b/components/nifosg/nifloader.cpp @@ -387,6 +387,15 @@ namespace NifOsg toSetup->setFunction(boost::shared_ptr(new ControllerFunction(ctrl))); } + void setupParticleController(const Nif::Controller* ctrl, SceneUtil::Controller* toSetup, int particleflags) + { + bool autoPlay = particleflags & Nif::NiNode::ParticleFlag_AutoPlay; + if (autoPlay) + toSetup->setSource(boost::shared_ptr(new SceneUtil::FrameTimeSource)); + + toSetup->setFunction(boost::shared_ptr(new ControllerFunction(ctrl))); + } + void optimize (const Nif::Node* nifNode, osg::Group* node, bool skipMeshes) { // For nodes with an identity transform, remove the redundant Transform node @@ -984,7 +993,7 @@ namespace NifOsg emitterNode->addChild(emitter); osg::ref_ptr callback(new ParticleSystemController(partctrl)); - setupController(partctrl, callback, animflags); + setupParticleController(partctrl, callback, particleflags); emitter->setUpdateCallback(callback); }