From 9d1b7c4a303bf5d6ba29f16cfdb15f761dddcbe7 Mon Sep 17 00:00:00 2001 From: elsid Date: Thu, 2 Sep 2021 01:12:47 +0200 Subject: [PATCH] Use type alias to avoid long type names and length redefinition for array --- components/sceneutil/shadowsbin.cpp | 4 ++-- components/sceneutil/shadowsbin.hpp | 23 ++++++++++++++--------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/components/sceneutil/shadowsbin.cpp b/components/sceneutil/shadowsbin.cpp index af62b581c9..a6275a60e2 100644 --- a/components/sceneutil/shadowsbin.cpp +++ b/components/sceneutil/shadowsbin.cpp @@ -42,7 +42,7 @@ namespace namespace SceneUtil { -std::array, 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, GL_ALWAYS - GL_NEVER + 1>& castingPrograms) +void ShadowsBin::addPrototype(const std::string & name, const CastingPrograms& castingPrograms) { sCastingPrograms = castingPrograms; osg::ref_ptr bin(new ShadowsBin); diff --git a/components/sceneutil/shadowsbin.hpp b/components/sceneutil/shadowsbin.hpp index 8775dc3139..67343c67f5 100644 --- a/components/sceneutil/shadowsbin.hpp +++ b/components/sceneutil/shadowsbin.hpp @@ -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, GL_ALWAYS - GL_NEVER + 1> sCastingPrograms; - - osg::ref_ptr mNoTestStateSet; - osg::ref_ptr mShaderAlphaTestStateSet; - - std::array, GL_ALWAYS - GL_NEVER + 1> mAlphaFuncShaders; public: + template + using Array = std::array; + + using CastingPrograms = Array>; + 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& uninteresting, bool cullFaceOverridden); - static void addPrototype(const std::string& name, const std::array, GL_ALWAYS - GL_NEVER + 1>& castingPrograms); + static void addPrototype(const std::string& name, const CastingPrograms& castingPrograms); + + private: + static CastingPrograms sCastingPrograms; + + osg::ref_ptr mNoTestStateSet; + osg::ref_ptr mShaderAlphaTestStateSet; + + Array> mAlphaFuncShaders; }; }