forked from mirror/openmw-tes3mp
Disable freezeOnCull for weather particles
This commit is contained in:
parent
5ca0ae5232
commit
fd1ccd21ff
4 changed files with 52 additions and 31 deletions
|
@ -1111,25 +1111,6 @@ namespace MWRender
|
|||
attachTo->addChild(lightSource);
|
||||
}
|
||||
|
||||
class DisableFreezeOnCullVisitor : public osg::NodeVisitor
|
||||
{
|
||||
public:
|
||||
DisableFreezeOnCullVisitor()
|
||||
: osg::NodeVisitor(TRAVERSE_ALL_CHILDREN)
|
||||
{
|
||||
}
|
||||
|
||||
virtual void apply(osg::Geode &geode)
|
||||
{
|
||||
for (unsigned int i=0; i<geode.getNumDrawables(); ++i)
|
||||
{
|
||||
osg::Drawable* drw = geode.getDrawable(i);
|
||||
if (osgParticle::ParticleSystem* partsys = dynamic_cast<osgParticle::ParticleSystem*>(drw))
|
||||
partsys->setFreezeOnCull(false);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
void Animation::addEffect (const std::string& model, int effectId, bool loop, const std::string& bonename, std::string texture)
|
||||
{
|
||||
if (!mObjectRoot.get())
|
||||
|
@ -1163,7 +1144,7 @@ namespace MWRender
|
|||
node->accept(findMaxLengthVisitor);
|
||||
|
||||
// FreezeOnCull doesn't work so well with effect particles, that tend to have moving emitters
|
||||
DisableFreezeOnCullVisitor disableFreezeOnCullVisitor;
|
||||
SceneUtil::DisableFreezeOnCullVisitor disableFreezeOnCullVisitor;
|
||||
node->accept(disableFreezeOnCullVisitor);
|
||||
|
||||
params.mMaxControllerLength = findMaxLengthVisitor.getMaxLength();
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include <components/sceneutil/util.hpp>
|
||||
#include <components/sceneutil/statesetupdater.hpp>
|
||||
#include <components/sceneutil/controller.hpp>
|
||||
#include <components/sceneutil/visitor.hpp>
|
||||
|
||||
#include "../mwbase/environment.hpp"
|
||||
#include "../mwbase/world.hpp"
|
||||
|
@ -1468,6 +1469,9 @@ void SkyManager::setWeather(const WeatherResult& weather)
|
|||
AlphaFader::SetupVisitor alphaFaderSetupVisitor;
|
||||
mParticleEffect->accept(alphaFaderSetupVisitor);
|
||||
mParticleFaders = alphaFaderSetupVisitor.getAlphaFaders();
|
||||
|
||||
SceneUtil::DisableFreezeOnCullVisitor disableFreezeOnCullVisitor;
|
||||
mParticleEffect->accept(disableFreezeOnCullVisitor);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
32
components/sceneutil/visitor.cpp
Normal file
32
components/sceneutil/visitor.cpp
Normal file
|
@ -0,0 +1,32 @@
|
|||
#include "visitor.hpp"
|
||||
|
||||
#include <osg/Geode>
|
||||
|
||||
#include <osgParticle/ParticleSystem>
|
||||
|
||||
#include <components/misc/stringops.hpp>
|
||||
|
||||
namespace SceneUtil
|
||||
{
|
||||
|
||||
void FindByNameVisitor::apply(osg::Group &group)
|
||||
{
|
||||
if (Misc::StringUtils::ciEqual(group.getName(), mNameToFind))
|
||||
{
|
||||
mFoundNode = &group;
|
||||
return;
|
||||
}
|
||||
traverse(group);
|
||||
}
|
||||
|
||||
void DisableFreezeOnCullVisitor::apply(osg::Geode &geode)
|
||||
{
|
||||
for (unsigned int i=0; i<geode.getNumDrawables(); ++i)
|
||||
{
|
||||
osg::Drawable* drw = geode.getDrawable(i);
|
||||
if (osgParticle::ParticleSystem* partsys = dynamic_cast<osgParticle::ParticleSystem*>(drw))
|
||||
partsys->setFreezeOnCull(false);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -3,12 +3,12 @@
|
|||
|
||||
#include <osg/NodeVisitor>
|
||||
|
||||
#include <components/misc/stringops.hpp>
|
||||
|
||||
// Commonly used scene graph visitors
|
||||
namespace SceneUtil
|
||||
{
|
||||
|
||||
// Find a Group by name, case-insensitive
|
||||
// If not found, mFoundNode will be NULL
|
||||
class FindByNameVisitor : public osg::NodeVisitor
|
||||
{
|
||||
public:
|
||||
|
@ -19,20 +19,24 @@ namespace SceneUtil
|
|||
{
|
||||
}
|
||||
|
||||
virtual void apply(osg::Group& group)
|
||||
{
|
||||
if (Misc::StringUtils::ciEqual(group.getName(), mNameToFind))
|
||||
{
|
||||
mFoundNode = &group;
|
||||
return;
|
||||
}
|
||||
traverse(group);
|
||||
}
|
||||
virtual void apply(osg::Group& group);
|
||||
|
||||
std::string mNameToFind;
|
||||
osg::Group* mFoundNode;
|
||||
};
|
||||
|
||||
// Disable freezeOnCull for all visited particlesystems
|
||||
class DisableFreezeOnCullVisitor : public osg::NodeVisitor
|
||||
{
|
||||
public:
|
||||
DisableFreezeOnCullVisitor()
|
||||
: osg::NodeVisitor(TRAVERSE_ALL_CHILDREN)
|
||||
{
|
||||
}
|
||||
|
||||
virtual void apply(osg::Geode &geode);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue