diff --git a/apps/opencs/view/render/cell.cpp b/apps/opencs/view/render/cell.cpp index 9ba5eeb01..5474d300b 100644 --- a/apps/opencs/view/render/cell.cpp +++ b/apps/opencs/view/render/cell.cpp @@ -107,7 +107,7 @@ CSVRender::Cell::Cell (CSMWorld::Data& data, osg::Group* rootNode, const std::st if (esmLand.getLandData (ESM::Land::DATA_VHGT)) { - mTerrain.reset(new Terrain::TerrainGrid(mCellNode, data.getResourceSystem().get(), NULL, new TerrainStorage(mData), Mask_Terrain)); + mTerrain.reset(new Terrain::TerrainGrid(mCellNode, mCellNode, data.getResourceSystem().get(), NULL, new TerrainStorage(mData), Mask_Terrain)); mTerrain->loadCell(esmLand.mX, esmLand.mY); diff --git a/apps/openmw/mwgui/loadingscreen.cpp b/apps/openmw/mwgui/loadingscreen.cpp index 35a825bcd..ca6a0b0a4 100644 --- a/apps/openmw/mwgui/loadingscreen.cpp +++ b/apps/openmw/mwgui/loadingscreen.cpp @@ -297,8 +297,8 @@ namespace MWGui // Turn off rendering except the GUI int oldUpdateMask = mViewer->getUpdateVisitor()->getTraversalMask(); int oldCullMask = mViewer->getCamera()->getCullMask(); - mViewer->getUpdateVisitor()->setTraversalMask(MWRender::Mask_GUI); - mViewer->getCamera()->setCullMask(MWRender::Mask_GUI); + mViewer->getUpdateVisitor()->setTraversalMask(MWRender::Mask_GUI|MWRender::Mask_PreCompile); + mViewer->getCamera()->setCullMask(MWRender::Mask_GUI|MWRender::Mask_PreCompile); MWBase::Environment::get().getInputManager()->update(0, true, true); diff --git a/apps/openmw/mwrender/renderingmanager.cpp b/apps/openmw/mwrender/renderingmanager.cpp index 469f5d63d..db5b77266 100644 --- a/apps/openmw/mwrender/renderingmanager.cpp +++ b/apps/openmw/mwrender/renderingmanager.cpp @@ -217,8 +217,8 @@ namespace MWRender mTerrainStorage = new TerrainStorage(mResourceSystem, Settings::Manager::getString("normal map pattern", "Shaders"), Settings::Manager::getString("normal height map pattern", "Shaders"), Settings::Manager::getBool("auto use terrain normal maps", "Shaders"), Settings::Manager::getString("terrain specular map pattern", "Shaders"), Settings::Manager::getBool("auto use terrain specular maps", "Shaders")); - mTerrain.reset(new Terrain::TerrainGrid(sceneRoot, mResourceSystem, mViewer->getIncrementalCompileOperation(), - mTerrainStorage, Mask_Terrain)); + mTerrain.reset(new Terrain::TerrainGrid(sceneRoot, mRootNode, mResourceSystem, mViewer->getIncrementalCompileOperation(), + mTerrainStorage, Mask_Terrain, Mask_PreCompile)); mCamera.reset(new Camera(mViewer->getCamera())); diff --git a/apps/openmw/mwrender/vismask.hpp b/apps/openmw/mwrender/vismask.hpp index c70bcc71b..d52c7c232 100644 --- a/apps/openmw/mwrender/vismask.hpp +++ b/apps/openmw/mwrender/vismask.hpp @@ -48,8 +48,10 @@ namespace MWRender // Set on cameras within the main scene graph Mask_RenderToTexture = (1<<15), + Mask_PreCompile = (1<<16), + // Set on a camera's cull mask to enable the LightManager - Mask_Lighting = (1<<16) + Mask_Lighting = (1<<17) }; } diff --git a/components/terrain/terraingrid.cpp b/components/terrain/terraingrid.cpp index c4e491d7a..ed18af74b 100644 --- a/components/terrain/terraingrid.cpp +++ b/components/terrain/terraingrid.cpp @@ -11,8 +11,8 @@ namespace Terrain { -TerrainGrid::TerrainGrid(osg::Group* parent, Resource::ResourceSystem* resourceSystem, osgUtil::IncrementalCompileOperation* ico, Storage* storage, int nodeMask) - : Terrain::World(parent, resourceSystem, ico, storage, nodeMask) +TerrainGrid::TerrainGrid(osg::Group* parent, osg::Group* compileRoot, Resource::ResourceSystem* resourceSystem, osgUtil::IncrementalCompileOperation* ico, Storage* storage, int nodeMask, int preCompileMask) + : Terrain::World(parent, compileRoot, resourceSystem, ico, storage, nodeMask, preCompileMask) , mNumSplits(4) { osg::ref_ptr material (new osg::Material); diff --git a/components/terrain/terraingrid.hpp b/components/terrain/terraingrid.hpp index 1b4d2de57..0bfc43075 100644 --- a/components/terrain/terraingrid.hpp +++ b/components/terrain/terraingrid.hpp @@ -19,7 +19,7 @@ namespace Terrain class TerrainGrid : public Terrain::World { public: - TerrainGrid(osg::Group* parent, Resource::ResourceSystem* resourceSystem, osgUtil::IncrementalCompileOperation* ico, Storage* storage, int nodeMask); + TerrainGrid(osg::Group* parent, osg::Group* compileRoot, Resource::ResourceSystem* resourceSystem, osgUtil::IncrementalCompileOperation* ico, Storage* storage, int nodeMask, int preCompileMask=~0); ~TerrainGrid(); /// Load a terrain cell and store it in cache for later use. diff --git a/components/terrain/world.cpp b/components/terrain/world.cpp index 29d3281e5..015270a43 100644 --- a/components/terrain/world.cpp +++ b/components/terrain/world.cpp @@ -13,8 +13,8 @@ namespace Terrain { -World::World(osg::Group* parent, Resource::ResourceSystem* resourceSystem, osgUtil::IncrementalCompileOperation* ico, - Storage* storage, int nodeMask) +World::World(osg::Group* parent, osg::Group* compileRoot, Resource::ResourceSystem* resourceSystem, osgUtil::IncrementalCompileOperation* ico, + Storage* storage, int nodeMask, int preCompileMask) : mStorage(storage) , mParent(parent) , mResourceSystem(resourceSystem) @@ -26,7 +26,9 @@ World::World(osg::Group* parent, Resource::ResourceSystem* resourceSystem, osgUt mTerrainRoot->setName("Terrain Root"); osg::ref_ptr renderer (new CompositeMapRenderer); - mTerrainRoot->addChild(renderer); + renderer->setNodeMask(preCompileMask); + compileRoot->addChild(renderer); + mCompositeMapRenderer = renderer; mParent->addChild(mTerrainRoot); @@ -43,6 +45,7 @@ World::~World() mResourceSystem->removeResourceManager(mTextureManager.get()); mParent->removeChild(mTerrainRoot); + mCompositeMapRenderer->getParent(0)->removeChild(mCompositeMapRenderer); delete mStorage; } diff --git a/components/terrain/world.hpp b/components/terrain/world.hpp index a8cc0f0db..f5cb10c37 100644 --- a/components/terrain/world.hpp +++ b/components/terrain/world.hpp @@ -42,8 +42,8 @@ namespace Terrain /// @note takes ownership of \a storage /// @param storage Storage instance to get terrain data from (heights, normals, colors, textures..) /// @param nodeMask mask for the terrain root - World(osg::Group* parent, Resource::ResourceSystem* resourceSystem, osgUtil::IncrementalCompileOperation* ico, - Storage* storage, int nodeMask); + World(osg::Group* parent, osg::Group* compileRoot, Resource::ResourceSystem* resourceSystem, osgUtil::IncrementalCompileOperation* ico, + Storage* storage, int nodeMask, int preCompileMask); virtual ~World(); virtual void updateTextureFiltering() {} @@ -63,6 +63,7 @@ namespace Terrain osg::ref_ptr mParent; osg::ref_ptr mTerrainRoot; + osg::ref_ptr mCompositeMapRenderer; Resource::ResourceSystem* mResourceSystem;