mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-04 05:45:35 +00:00
Disable FreezeOnCull for effect particles
This commit is contained in:
parent
1ed4e33815
commit
f5c50aa581
1 changed files with 25 additions and 0 deletions
|
@ -10,6 +10,8 @@
|
||||||
#include <osg/MatrixTransform>
|
#include <osg/MatrixTransform>
|
||||||
#include <osg/Geode>
|
#include <osg/Geode>
|
||||||
|
|
||||||
|
#include <osgParticle/ParticleSystem>
|
||||||
|
|
||||||
#include <components/nifosg/nifloader.hpp>
|
#include <components/nifosg/nifloader.hpp>
|
||||||
|
|
||||||
#include <components/resource/resourcesystem.hpp>
|
#include <components/resource/resourcesystem.hpp>
|
||||||
|
@ -1067,6 +1069,25 @@ namespace MWRender
|
||||||
attachTo->addChild(lightSource);
|
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)
|
void Animation::addEffect (const std::string& model, int effectId, bool loop, const std::string& bonename, std::string texture)
|
||||||
{
|
{
|
||||||
if (!mObjectRoot.get())
|
if (!mObjectRoot.get())
|
||||||
|
@ -1099,6 +1120,10 @@ namespace MWRender
|
||||||
SceneUtil::FindMaxControllerLengthVisitor findMaxLengthVisitor;
|
SceneUtil::FindMaxControllerLengthVisitor findMaxLengthVisitor;
|
||||||
node->accept(findMaxLengthVisitor);
|
node->accept(findMaxLengthVisitor);
|
||||||
|
|
||||||
|
// FreezeOnCull doesn't work so well with effect particles, that tend to have moving emitters
|
||||||
|
DisableFreezeOnCullVisitor disableFreezeOnCullVisitor;
|
||||||
|
node->accept(disableFreezeOnCullVisitor);
|
||||||
|
|
||||||
params.mMaxControllerLength = findMaxLengthVisitor.getMaxLength();
|
params.mMaxControllerLength = findMaxLengthVisitor.getMaxLength();
|
||||||
|
|
||||||
node->setNodeMask(Mask_Effect);
|
node->setNodeMask(Mask_Effect);
|
||||||
|
|
Loading…
Reference in a new issue