diff --git a/components/nifosg/nifloader.cpp b/components/nifosg/nifloader.cpp index 4c77c1ce4..a51153c3a 100644 --- a/components/nifosg/nifloader.cpp +++ b/components/nifosg/nifloader.cpp @@ -356,7 +356,7 @@ namespace NifOsg osg::ref_ptr textkeys (new TextKeyMapHolder); - osg::ref_ptr created = handleNode(nifNode, NULL, imageManager, std::vector(), 0, 0, false, &textkeys->mTextKeys); + osg::ref_ptr created = handleNode(nifNode, NULL, imageManager, std::vector(), 0, false, &textkeys->mTextKeys); if (nif->getUseSkinning()) { @@ -404,15 +404,6 @@ 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 @@ -547,7 +538,7 @@ namespace NifOsg } osg::ref_ptr handleNode(const Nif::Node* nifNode, osg::Group* parentNode, Resource::ImageManager* imageManager, - std::vector boundTextures, int animflags, int particleflags, bool skipMeshes, TextKeyMap* textKeys, osg::Node* rootNode=NULL) + std::vector boundTextures, int animflags, bool skipMeshes, TextKeyMap* textKeys, osg::Node* rootNode=NULL) { osg::ref_ptr node = new osg::MatrixTransform(nifNode->trafo.toMatrix()); @@ -617,10 +608,8 @@ namespace NifOsg } } - if (nifNode->recType == Nif::RC_NiBSAnimationNode) + if (nifNode->recType == Nif::RC_NiBSAnimationNode || nifNode->recType == Nif::RC_NiBSParticleNode) animflags |= nifNode->flags; - if (nifNode->recType == Nif::RC_NiBSParticleNode) - particleflags |= nifNode->flags; // Hide collision shapes, but don't skip the subgraph // We still need to animate the hidden bones so the physics system can access them @@ -663,7 +652,7 @@ namespace NifOsg } if(nifNode->recType == Nif::RC_NiAutoNormalParticles || nifNode->recType == Nif::RC_NiRotatingParticles) - handleParticleSystem(nifNode, node, composite, animflags, particleflags, rootNode); + handleParticleSystem(nifNode, node, composite, animflags, rootNode); if (composite->getNumControllers() > 0) node->addUpdateCallback(composite); @@ -700,7 +689,7 @@ namespace NifOsg for(size_t i = 0;i < children.length();++i) { if(!children[i].empty()) - handleNode(children[i].getPtr(), node, imageManager, boundTextures, animflags, particleflags, skipMeshes, textKeys, rootNode); + handleNode(children[i].getPtr(), node, imageManager, boundTextures, animflags, skipMeshes, textKeys, rootNode); } } @@ -965,7 +954,7 @@ namespace NifOsg return emitter; } - void handleParticleSystem(const Nif::Node *nifNode, osg::Group *parentNode, SceneUtil::CompositeStateSetUpdater* composite, int animflags, int particleflags, osg::Node* rootNode) + void handleParticleSystem(const Nif::Node *nifNode, osg::Group *parentNode, SceneUtil::CompositeStateSetUpdater* composite, int animflags, osg::Node* rootNode) { osg::ref_ptr partsys (new ParticleSystem); partsys->setSortMode(osgParticle::ParticleSystem::SORT_BACK_TO_FRONT); @@ -986,7 +975,7 @@ namespace NifOsg return; } - osgParticle::ParticleProcessor::ReferenceFrame rf = (particleflags & Nif::NiNode::ParticleFlag_LocalSpace) + osgParticle::ParticleProcessor::ReferenceFrame rf = (animflags & Nif::NiNode::ParticleFlag_LocalSpace) ? osgParticle::ParticleProcessor::RELATIVE_RF : osgParticle::ParticleProcessor::ABSOLUTE_RF; @@ -1032,10 +1021,10 @@ namespace NifOsg emitterNode->addChild(emitter); osg::ref_ptr callback(new ParticleSystemController(partctrl)); - setupParticleController(partctrl, callback, particleflags); + setupController(partctrl, callback, animflags); emitter->setUpdateCallback(callback); - if (!(particleflags & Nif::NiNode::ParticleFlag_AutoPlay)) + if (!(animflags & Nif::NiNode::ParticleFlag_AutoPlay)) { partsys->setFrozen(true); // HACK: particle system will not render in Frozen state if there was no update