mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-01 15:15:33 +00:00
Move RemoveParticlesVisitor to animation.cpp
This commit is contained in:
parent
0efbdb25ee
commit
a9561f738a
2 changed files with 46 additions and 56 deletions
|
@ -10,6 +10,7 @@
|
||||||
#include <osg/Material>
|
#include <osg/Material>
|
||||||
|
|
||||||
#include <osgParticle/ParticleSystem>
|
#include <osgParticle/ParticleSystem>
|
||||||
|
#include <osgParticle/ParticleProcessor>
|
||||||
|
|
||||||
#include <components/nifosg/nifloader.hpp>
|
#include <components/nifosg/nifloader.hpp>
|
||||||
|
|
||||||
|
@ -47,6 +48,44 @@
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/// Removes all particle systems and related nodes in a subgraph.
|
||||||
|
class RemoveParticlesVisitor : public osg::NodeVisitor
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
RemoveParticlesVisitor()
|
||||||
|
: osg::NodeVisitor(TRAVERSE_ALL_CHILDREN)
|
||||||
|
{ }
|
||||||
|
|
||||||
|
virtual void apply(osg::Node &node)
|
||||||
|
{
|
||||||
|
if (dynamic_cast<osgParticle::ParticleProcessor*>(&node))
|
||||||
|
mToRemove.push_back(&node);
|
||||||
|
|
||||||
|
traverse(node);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void apply(osg::Drawable& drw)
|
||||||
|
{
|
||||||
|
if (osgParticle::ParticleSystem* partsys = dynamic_cast<osgParticle::ParticleSystem*>(&drw))
|
||||||
|
mToRemove.push_back(partsys);
|
||||||
|
}
|
||||||
|
|
||||||
|
void remove()
|
||||||
|
{
|
||||||
|
for (std::vector<osg::ref_ptr<osg::Node> >::iterator it = mToRemove.begin(); it != mToRemove.end(); ++it)
|
||||||
|
{
|
||||||
|
// FIXME: a Drawable might have more than one parent
|
||||||
|
osg::Node* node = *it;
|
||||||
|
if (node->getNumParents())
|
||||||
|
node->getParent(0)->removeChild(node);
|
||||||
|
}
|
||||||
|
mToRemove.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::vector<osg::ref_ptr<osg::Node> > mToRemove;
|
||||||
|
};
|
||||||
|
|
||||||
class GlowUpdater : public SceneUtil::StateSetUpdater
|
class GlowUpdater : public SceneUtil::StateSetUpdater
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -1439,6 +1478,13 @@ namespace MWRender
|
||||||
}
|
}
|
||||||
if (ptr.getTypeName() == typeid(ESM::Light).name() && allowLight)
|
if (ptr.getTypeName() == typeid(ESM::Light).name() && allowLight)
|
||||||
addExtraLight(getOrCreateObjectRoot(), ptr.get<ESM::Light>()->mBase);
|
addExtraLight(getOrCreateObjectRoot(), ptr.get<ESM::Light>()->mBase);
|
||||||
|
|
||||||
|
if (!allowLight)
|
||||||
|
{
|
||||||
|
RemoveParticlesVisitor visitor;
|
||||||
|
mObjectRoot->accept(visitor);
|
||||||
|
visitor.remove();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Animation::AnimState::~AnimState()
|
Animation::AnimState::~AnimState()
|
||||||
|
|
|
@ -5,12 +5,6 @@
|
||||||
#include <osg/Group>
|
#include <osg/Group>
|
||||||
#include <osg/UserDataContainer>
|
#include <osg/UserDataContainer>
|
||||||
|
|
||||||
#include <osgParticle/ParticleSystem>
|
|
||||||
#include <osgParticle/ParticleProcessor>
|
|
||||||
|
|
||||||
#include <components/resource/scenemanager.hpp>
|
|
||||||
|
|
||||||
#include <components/sceneutil/visitor.hpp>
|
|
||||||
#include <components/sceneutil/positionattitudetransform.hpp>
|
#include <components/sceneutil/positionattitudetransform.hpp>
|
||||||
#include <components/sceneutil/unrefqueue.hpp>
|
#include <components/sceneutil/unrefqueue.hpp>
|
||||||
|
|
||||||
|
@ -22,49 +16,6 @@
|
||||||
#include "creatureanimation.hpp"
|
#include "creatureanimation.hpp"
|
||||||
#include "vismask.hpp"
|
#include "vismask.hpp"
|
||||||
|
|
||||||
namespace
|
|
||||||
{
|
|
||||||
|
|
||||||
/// Removes all particle systems and related nodes in a subgraph.
|
|
||||||
class RemoveParticlesVisitor : public osg::NodeVisitor
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
RemoveParticlesVisitor()
|
|
||||||
: osg::NodeVisitor(TRAVERSE_ALL_CHILDREN)
|
|
||||||
{ }
|
|
||||||
|
|
||||||
virtual void apply(osg::Node &node)
|
|
||||||
{
|
|
||||||
if (dynamic_cast<osgParticle::ParticleProcessor*>(&node))
|
|
||||||
mToRemove.push_back(&node);
|
|
||||||
|
|
||||||
traverse(node);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void apply(osg::Drawable& drw)
|
|
||||||
{
|
|
||||||
if (osgParticle::ParticleSystem* partsys = dynamic_cast<osgParticle::ParticleSystem*>(&drw))
|
|
||||||
mToRemove.push_back(partsys);
|
|
||||||
}
|
|
||||||
|
|
||||||
void remove()
|
|
||||||
{
|
|
||||||
for (std::vector<osg::ref_ptr<osg::Node> >::iterator it = mToRemove.begin(); it != mToRemove.end(); ++it)
|
|
||||||
{
|
|
||||||
// FIXME: a Drawable might have more than one parent
|
|
||||||
osg::Node* node = *it;
|
|
||||||
if (node->getNumParents())
|
|
||||||
node->getParent(0)->removeChild(node);
|
|
||||||
}
|
|
||||||
mToRemove.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::vector<osg::ref_ptr<osg::Node> > mToRemove;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
namespace MWRender
|
namespace MWRender
|
||||||
{
|
{
|
||||||
|
@ -124,13 +75,6 @@ void Objects::insertModel(const MWWorld::Ptr &ptr, const std::string &mesh, bool
|
||||||
|
|
||||||
std::auto_ptr<ObjectAnimation> anim (new ObjectAnimation(ptr, mesh, mResourceSystem, animated, allowLight));
|
std::auto_ptr<ObjectAnimation> anim (new ObjectAnimation(ptr, mesh, mResourceSystem, animated, allowLight));
|
||||||
|
|
||||||
if (!allowLight)
|
|
||||||
{
|
|
||||||
RemoveParticlesVisitor visitor;
|
|
||||||
anim->getObjectRoot()->accept(visitor);
|
|
||||||
visitor.remove();
|
|
||||||
}
|
|
||||||
|
|
||||||
mObjects.insert(std::make_pair(ptr, anim.release()));
|
mObjects.insert(std::make_pair(ptr, anim.release()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue