mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-21 09:39:56 +00:00
pass only lights with visible geometry
This commit is contained in:
parent
327b8ecdcb
commit
8146b05c92
@ -1156,6 +1156,8 @@ namespace SceneUtil
|
||||
{
|
||||
for (const auto& bound : it->second)
|
||||
{
|
||||
if (bound.mLightSource->getEmpty())
|
||||
continue;
|
||||
const auto* light = bound.mLightSource->getLight(frameNum);
|
||||
if (light->getDiffuse().x() >= 0.f)
|
||||
mPPLightBuffer->setLight(frameNum, light, bound.mLightSource->getRadius());
|
||||
|
@ -118,6 +118,8 @@ namespace SceneUtil
|
||||
|
||||
unsigned int mLastAppliedFrame;
|
||||
|
||||
bool mEmpty = false;
|
||||
|
||||
public:
|
||||
|
||||
META_Node(SceneUtil, LightSource)
|
||||
@ -147,6 +149,16 @@ namespace SceneUtil
|
||||
return mActorFade;
|
||||
}
|
||||
|
||||
void setEmpty(bool empty)
|
||||
{
|
||||
mEmpty = empty;
|
||||
}
|
||||
|
||||
bool getEmpty() const
|
||||
{
|
||||
return mEmpty;
|
||||
}
|
||||
|
||||
/// Get the osg::Light safe for modification in the given frame.
|
||||
/// @par May be used externally to animate the light's color/attenuation properties,
|
||||
/// and is used internally to synchronize the light's position with the position of the LightSource.
|
||||
|
@ -3,6 +3,8 @@
|
||||
#include <osg/Light>
|
||||
#include <osg/Group>
|
||||
|
||||
#include <osgParticle/ParticleSystem>
|
||||
|
||||
#include <components/esm3/loadligh.hpp>
|
||||
#include <components/fallback/fallback.hpp>
|
||||
|
||||
@ -11,6 +13,33 @@
|
||||
#include "util.hpp"
|
||||
#include "visitor.hpp"
|
||||
|
||||
namespace
|
||||
{
|
||||
class CheckEmptyLightVisitor : public osg::NodeVisitor
|
||||
{
|
||||
public:
|
||||
CheckEmptyLightVisitor() : osg::NodeVisitor(TRAVERSE_ALL_CHILDREN) {}
|
||||
|
||||
void apply(osg::Drawable& drawable) override
|
||||
{
|
||||
if (!mEmpty)
|
||||
return;
|
||||
|
||||
if (dynamic_cast<const osgParticle::ParticleSystem*>(&drawable))
|
||||
mEmpty = false;
|
||||
else
|
||||
traverse(drawable);
|
||||
}
|
||||
|
||||
void apply(osg::Geometry& geometry) override
|
||||
{
|
||||
mEmpty = false;
|
||||
}
|
||||
|
||||
bool mEmpty = true;
|
||||
};
|
||||
}
|
||||
|
||||
namespace SceneUtil
|
||||
{
|
||||
|
||||
@ -64,6 +93,12 @@ namespace SceneUtil
|
||||
osg::Group* attachTo = visitor.mFoundNode ? visitor.mFoundNode : node;
|
||||
osg::ref_ptr<LightSource> lightSource = createLightSource(esmLight, lightMask, isExterior, osg::Vec4f(0,0,0,1));
|
||||
attachTo->addChild(lightSource);
|
||||
|
||||
CheckEmptyLightVisitor emptyVisitor;
|
||||
node->accept(emptyVisitor);
|
||||
|
||||
lightSource->setEmpty(emptyVisitor.mEmpty);
|
||||
|
||||
return lightSource;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user