From 0568c93b39d2b08713caa327021938994213a016 Mon Sep 17 00:00:00 2001 From: AnyOldName3 Date: Tue, 3 Oct 2017 03:40:23 +0100 Subject: [PATCH] Add specific shadow source files to MWRender --- apps/openmw/CMakeLists.txt | 1 + apps/openmw/mwrender/renderingmanager.cpp | 8 ++----- apps/openmw/mwrender/shadow.cpp | 11 +++++++++ apps/openmw/mwrender/shadow.hpp | 27 +++++++++++++++++++++++ 4 files changed, 41 insertions(+), 6 deletions(-) create mode 100644 apps/openmw/mwrender/shadow.cpp create mode 100644 apps/openmw/mwrender/shadow.hpp diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt index 47a30f9a01..97744d4dd0 100644 --- a/apps/openmw/CMakeLists.txt +++ b/apps/openmw/CMakeLists.txt @@ -24,6 +24,7 @@ add_openmw_dir (mwrender creatureanimation effectmanager util renderinginterface pathgrid rendermode weaponanimation bulletdebugdraw globalmap characterpreview camera localmap water terrainstorage ripplesimulation renderbin actoranimation landmanager + shadow ) add_openmw_dir (mwinput diff --git a/apps/openmw/mwrender/renderingmanager.cpp b/apps/openmw/mwrender/renderingmanager.cpp index 04c3355cab..e670eaebc0 100644 --- a/apps/openmw/mwrender/renderingmanager.cpp +++ b/apps/openmw/mwrender/renderingmanager.cpp @@ -14,11 +14,6 @@ #include #include -#include -#include -#include -#include -#include #include #include @@ -57,6 +52,7 @@ #include "water.hpp" #include "terrainstorage.hpp" #include "util.hpp" +#include "shadow.hpp" namespace MWRender { @@ -228,7 +224,7 @@ namespace MWRender int mapres = 2048; settings->setTextureSize(osg::Vec2s(mapres,mapres)); - osgShadow::MinimalShadowMap* tech = new osgShadow::LightSpacePerspectiveShadowMapDB(); + MWShadow* tech = new MWShadow(); shadowedScene->setShadowTechnique(tech); tech->setMaxFarPlane(0); diff --git a/apps/openmw/mwrender/shadow.cpp b/apps/openmw/mwrender/shadow.cpp new file mode 100644 index 0000000000..17cc5156bb --- /dev/null +++ b/apps/openmw/mwrender/shadow.cpp @@ -0,0 +1,11 @@ +#include "shadow.hpp" + +namespace MWRender +{ + void MWShadow::ViewData::init(MWShadow * st, osgUtil::CullVisitor * cv) + { + LightSpacePerspectiveShadowMapDB::ViewData::init(st, cv); + osg::StateSet * stateset = _camera->getOrCreateStateSet(); + stateset->removeAttribute(osg::StateAttribute::CULLFACE); + } +} diff --git a/apps/openmw/mwrender/shadow.hpp b/apps/openmw/mwrender/shadow.hpp new file mode 100644 index 0000000000..51338c5bf8 --- /dev/null +++ b/apps/openmw/mwrender/shadow.hpp @@ -0,0 +1,27 @@ +#ifndef OPENMW_MWRENDER_SHADOW_H +#define OPENMW_MWRENDER_SHADOW_H + +#include + +namespace MWRender +{ + class MWShadow : public osgShadow::LightSpacePerspectiveShadowMapDB + { + protected: + struct ViewData : public LightSpacePerspectiveShadowMapDB::ViewData + { + virtual void init(MWShadow * st, osgUtil::CullVisitor * cv); + }; + + virtual ViewDependentShadowTechnique::ViewData * initViewDependentData(osgUtil::CullVisitor *cv, ViewDependentShadowTechnique::ViewData * vd) + { + MWShadow::ViewData* td = dynamic_cast(vd); + if (!td) + td = new MWShadow::ViewData; + td->init(this, cv); + return td; + } + }; +} + +#endif //OPENMW_MWRENDER_SHADOW_H