1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-03-14 10:21:09 +00:00

Use type alias to avoid long type names and length redefinition for array

This commit is contained in:
elsid 2021-09-02 01:12:47 +02:00
parent 6cfabe252d
commit 9d1b7c4a30
No known key found for this signature in database
GPG Key ID: B845CB9FEE18AB40
2 changed files with 16 additions and 11 deletions

View File

@ -42,7 +42,7 @@ namespace
namespace SceneUtil
{
std::array<osg::ref_ptr<osg::Program>, GL_ALWAYS - GL_NEVER + 1> ShadowsBin::sCastingPrograms = {
ShadowsBin::CastingPrograms ShadowsBin::sCastingPrograms = {
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr
};
@ -150,7 +150,7 @@ StateGraph* ShadowsBin::cullStateGraph(StateGraph* sg, StateGraph* root, std::un
return sg;
}
void ShadowsBin::addPrototype(const std::string & name, const std::array<osg::ref_ptr<osg::Program>, GL_ALWAYS - GL_NEVER + 1>& castingPrograms)
void ShadowsBin::addPrototype(const std::string & name, const CastingPrograms& castingPrograms)
{
sCastingPrograms = castingPrograms;
osg::ref_ptr<osgUtil::RenderBin> bin(new ShadowsBin);

View File

@ -12,18 +12,15 @@ namespace osg
namespace SceneUtil
{
/// renderbin which culls redundant state for shadow map rendering
class ShadowsBin : public osgUtil::RenderBin
{
private:
static std::array<osg::ref_ptr<osg::Program>, GL_ALWAYS - GL_NEVER + 1> sCastingPrograms;
osg::ref_ptr<osg::StateSet> mNoTestStateSet;
osg::ref_ptr<osg::StateSet> mShaderAlphaTestStateSet;
std::array<osg::ref_ptr<osg::StateSet>, GL_ALWAYS - GL_NEVER + 1> mAlphaFuncShaders;
public:
template <class T>
using Array = std::array<T, GL_ALWAYS - GL_NEVER + 1>;
using CastingPrograms = Array<osg::ref_ptr<osg::Program>>;
META_Object(SceneUtil, ShadowsBin)
ShadowsBin();
ShadowsBin(const ShadowsBin& rhs, const osg::CopyOp& copyop)
@ -65,7 +62,15 @@ namespace SceneUtil
osgUtil::StateGraph* cullStateGraph(osgUtil::StateGraph* sg, osgUtil::StateGraph* root, std::unordered_set<osgUtil::StateGraph*>& uninteresting, bool cullFaceOverridden);
static void addPrototype(const std::string& name, const std::array<osg::ref_ptr<osg::Program>, GL_ALWAYS - GL_NEVER + 1>& castingPrograms);
static void addPrototype(const std::string& name, const CastingPrograms& castingPrograms);
private:
static CastingPrograms sCastingPrograms;
osg::ref_ptr<osg::StateSet> mNoTestStateSet;
osg::ref_ptr<osg::StateSet> mShaderAlphaTestStateSet;
Array<osg::ref_ptr<osg::StateSet>> mAlphaFuncShaders;
};
}