1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-03-01 09:09:42 +00:00

Remove redundant ShadowsBin::sCastingPrograms

This variable is only used in ShadowsBin constructor and it's initialized each
time before constructor call so required value can be just passed into
ShadowsBin ctor.

Make ShadowsBin default constructor private because it is required by osg even
it's not actually called.
This commit is contained in:
elsid 2021-09-02 21:31:11 +02:00
parent 9d1b7c4a30
commit 590a340e6e
No known key found for this signature in database
GPG key ID: B845CB9FEE18AB40
2 changed files with 6 additions and 11 deletions

View file

@ -42,11 +42,7 @@ namespace
namespace SceneUtil
{
ShadowsBin::CastingPrograms ShadowsBin::sCastingPrograms = {
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr
};
ShadowsBin::ShadowsBin()
ShadowsBin::ShadowsBin(const CastingPrograms& castingPrograms)
{
mNoTestStateSet = new osg::StateSet;
mNoTestStateSet->addUniform(new osg::Uniform("useDiffuseMapForShadowAlpha", false));
@ -57,10 +53,10 @@ ShadowsBin::ShadowsBin()
mShaderAlphaTestStateSet->addUniform(new osg::Uniform("useDiffuseMapForShadowAlpha", true));
mShaderAlphaTestStateSet->setMode(GL_BLEND, osg::StateAttribute::OFF | osg::StateAttribute::PROTECTED | osg::StateAttribute::OVERRIDE);
for (size_t i = 0; i < sCastingPrograms.size(); ++i)
for (size_t i = 0; i < castingPrograms.size(); ++i)
{
mAlphaFuncShaders[i] = new osg::StateSet;
mAlphaFuncShaders[i]->setAttribute(sCastingPrograms[i], osg::StateAttribute::ON | osg::StateAttribute::PROTECTED | osg::StateAttribute::OVERRIDE);
mAlphaFuncShaders[i]->setAttribute(castingPrograms[i], osg::StateAttribute::ON | osg::StateAttribute::PROTECTED | osg::StateAttribute::OVERRIDE);
}
}
@ -152,8 +148,7 @@ StateGraph* ShadowsBin::cullStateGraph(StateGraph* sg, StateGraph* root, std::un
void ShadowsBin::addPrototype(const std::string & name, const CastingPrograms& castingPrograms)
{
sCastingPrograms = castingPrograms;
osg::ref_ptr<osgUtil::RenderBin> bin(new ShadowsBin);
osg::ref_ptr<osgUtil::RenderBin> bin(new ShadowsBin(castingPrograms));
osgUtil::RenderBin::addRenderBinPrototype(name, bin);
}

View file

@ -22,7 +22,7 @@ namespace SceneUtil
using CastingPrograms = Array<osg::ref_ptr<osg::Program>>;
META_Object(SceneUtil, ShadowsBin)
ShadowsBin();
ShadowsBin(const CastingPrograms& castingPrograms);
ShadowsBin(const ShadowsBin& rhs, const osg::CopyOp& copyop)
: osgUtil::RenderBin(rhs, copyop)
, mNoTestStateSet(rhs.mNoTestStateSet)
@ -65,7 +65,7 @@ namespace SceneUtil
static void addPrototype(const std::string& name, const CastingPrograms& castingPrograms);
private:
static CastingPrograms sCastingPrograms;
ShadowsBin() {}
osg::ref_ptr<osg::StateSet> mNoTestStateSet;
osg::ref_ptr<osg::StateSet> mShaderAlphaTestStateSet;