diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index 582172bff..e2e09bdec 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -41,6 +41,8 @@ #include "mwworld/player.hpp" #include "mwworld/worldimp.hpp" +#include "mwrender/vismask.hpp" + #include "mwclass/classes.hpp" #include "mwdialogue/dialoguemanagerimp.hpp" @@ -339,6 +341,7 @@ void OMW::Engine::prepareEngine (Settings::Manager & settings) std::string myguiResources = (mResDir / "mygui").string(); osg::ref_ptr guiRoot = new osg::Group; + guiRoot->setNodeMask(MWRender::Mask_GUI); rootNode->addChild(guiRoot); MWGui::WindowManager* window = new MWGui::WindowManager(mViewer, guiRoot, mResourceSystem->getTextureManager(), mCfgMgr.getLogPath().string() + std::string("/"), myguiResources, diff --git a/apps/openmw/mwgui/myguirendermanager.cpp b/apps/openmw/mwgui/myguirendermanager.cpp index 06e404d88..f218d9ff0 100644 --- a/apps/openmw/mwgui/myguirendermanager.cpp +++ b/apps/openmw/mwgui/myguirendermanager.cpp @@ -466,7 +466,7 @@ void RenderManager::initialise() camera->addChild(geode.get()); mGuiRoot = camera; - //mSceneRoot->addChild(mGuiRoot.get()); + mSceneRoot->addChild(mGuiRoot.get()); mViewer->addEventHandler(new ResizeHandler(this)); osg::ref_ptr vp = mViewer->getCamera()->getViewport(); diff --git a/apps/openmw/mwrender/renderingmanager.cpp b/apps/openmw/mwrender/renderingmanager.cpp index d68620f8a..8689935d0 100644 --- a/apps/openmw/mwrender/renderingmanager.cpp +++ b/apps/openmw/mwrender/renderingmanager.cpp @@ -23,6 +23,7 @@ #include "sky.hpp" #include "effectmanager.hpp" +#include "vismask.hpp" namespace MWRender { @@ -87,8 +88,6 @@ namespace MWRender mObjects.reset(new Objects(mResourceSystem, lightRoot)); - mSky.reset(new SkyManager(mRootNode, resourceSystem->getSceneManager())); - mEffectManager.reset(new EffectManager(mRootNode, mResourceSystem)); mViewer.setLightingMode(osgViewer::View::NO_LIGHT); @@ -105,6 +104,10 @@ namespace MWRender lightRoot->getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::ON); lightRoot->getOrCreateStateSet()->setMode(GL_NORMALIZE, osg::StateAttribute::ON); + lightRoot->setNodeMask(Mask_Scene); + + mSky.reset(new SkyManager(lightRoot, resourceSystem->getSceneManager())); + source->setStateSetModes(*mRootNode->getOrCreateStateSet(), osg::StateAttribute::ON); mStateUpdater = new StateUpdater; @@ -128,6 +131,8 @@ namespace MWRender zNear = 5.f; zFar = mViewDistance; mViewer.getCamera()->setProjectionMatrixAsPerspective(fovy, aspect, zNear, zFar); + + mViewer.getCamera()->setCullMask(mViewer.getCamera()->getCullMask() & (~Mask_GUI)); } RenderingManager::~RenderingManager() diff --git a/apps/openmw/mwrender/sky.cpp b/apps/openmw/mwrender/sky.cpp index 97055ecae..4fd5b7e63 100644 --- a/apps/openmw/mwrender/sky.cpp +++ b/apps/openmw/mwrender/sky.cpp @@ -554,7 +554,6 @@ void SkyManager::create() depth->setWriteMask(false); mRootNode->getOrCreateStateSet()->setAttributeAndModes(depth, osg::StateAttribute::ON); mRootNode->getOrCreateStateSet()->setMode(GL_BLEND, osg::StateAttribute::ON); - mRootNode->getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::ON); mCreated = true; } @@ -562,6 +561,11 @@ void SkyManager::create() SkyManager::~SkyManager() { clearRain(); + if (mRootNode) + { + mRootNode->getParent(0)->removeChild(mRootNode); + mRootNode = NULL; + } } int SkyManager::getMasserPhase() const diff --git a/apps/openmw/mwrender/vismask.hpp b/apps/openmw/mwrender/vismask.hpp index 4a064b60f..48845c78c 100644 --- a/apps/openmw/mwrender/vismask.hpp +++ b/apps/openmw/mwrender/vismask.hpp @@ -9,7 +9,12 @@ namespace MWRender { Mask_UpdateVisitor = 0x1, // reserved for separating UpdateVisitors from CullVisitors - Mask_Effect = 0x2 + // child of Scene + Mask_Effect = 0x2, + + // top level masks + Mask_Scene = 0x10, + Mask_GUI = 0x20 }; }