From 4dbd224249b24d14b0cc210d816204e50a52b29e Mon Sep 17 00:00:00 2001 From: scrawl Date: Thu, 9 Mar 2017 02:17:25 +0100 Subject: [PATCH] Hide the terrain in non-exterior cells --- apps/openmw/mwrender/renderingmanager.cpp | 5 +++++ apps/openmw/mwrender/renderingmanager.hpp | 2 ++ apps/openmw/mwworld/scene.cpp | 2 ++ components/terrain/quadtreeworld.cpp | 8 ++++++++ components/terrain/quadtreeworld.hpp | 2 ++ components/terrain/world.hpp | 2 ++ 6 files changed, 21 insertions(+) diff --git a/apps/openmw/mwrender/renderingmanager.cpp b/apps/openmw/mwrender/renderingmanager.cpp index ff7f6ae9a..a8baf9530 100644 --- a/apps/openmw/mwrender/renderingmanager.cpp +++ b/apps/openmw/mwrender/renderingmanager.cpp @@ -421,6 +421,11 @@ namespace MWRender mWater->removeCell(store); } + void RenderingManager::enableTerrain(bool enable) + { + mTerrain->enable(enable); + } + void RenderingManager::setSkyEnabled(bool enabled) { mSky->setEnabled(enabled); diff --git a/apps/openmw/mwrender/renderingmanager.hpp b/apps/openmw/mwrender/renderingmanager.hpp index 230fe3f7d..d81dbf180 100644 --- a/apps/openmw/mwrender/renderingmanager.hpp +++ b/apps/openmw/mwrender/renderingmanager.hpp @@ -102,6 +102,8 @@ namespace MWRender void addCell(const MWWorld::CellStore* store); void removeCell(const MWWorld::CellStore* store); + void enableTerrain(bool enable); + void updatePtr(const MWWorld::Ptr& old, const MWWorld::Ptr& updated); void rotateObject(const MWWorld::Ptr& ptr, const osg::Quat& rot); diff --git a/apps/openmw/mwworld/scene.cpp b/apps/openmw/mwworld/scene.cpp index 3e1227b37..41dcce1d9 100644 --- a/apps/openmw/mwworld/scene.cpp +++ b/apps/openmw/mwworld/scene.cpp @@ -440,6 +440,8 @@ namespace MWWorld { mCurrentCell = cell; + mRendering.enableTerrain(cell->isExterior()); + MWBase::World *world = MWBase::Environment::get().getWorld(); MWWorld::Ptr old = world->getPlayerPtr(); world->getPlayer().setCell(cell); diff --git a/components/terrain/quadtreeworld.cpp b/components/terrain/quadtreeworld.cpp index 535b3a583..bc4a4abc5 100644 --- a/components/terrain/quadtreeworld.cpp +++ b/components/terrain/quadtreeworld.cpp @@ -98,6 +98,8 @@ public: virtual void accept(osg::NodeVisitor &nv) { + if (!nv.validNodeMask(*this)) + return; nv.pushOntoNodePath(this); mWorld->accept(nv); nv.popFromNodePath(); @@ -361,6 +363,12 @@ osg::ref_ptr QuadTreeWorld::cacheCell(int x, int y) return NULL; } +void QuadTreeWorld::enable(bool enabled) +{ + if (mRootNode) + mRootNode->setNodeMask(enabled ? ~0 : 0); +} + } diff --git a/components/terrain/quadtreeworld.hpp b/components/terrain/quadtreeworld.hpp index ebea60fc5..bec901b09 100644 --- a/components/terrain/quadtreeworld.hpp +++ b/components/terrain/quadtreeworld.hpp @@ -33,6 +33,8 @@ namespace Terrain virtual void loadCell(int x, int y); virtual osg::ref_ptr cacheCell(int x, int y); + virtual void enable(bool enabled); + private: osg::ref_ptr mRootNode; diff --git a/components/terrain/world.hpp b/components/terrain/world.hpp index 091ddadd2..7abc9a4ca 100644 --- a/components/terrain/world.hpp +++ b/components/terrain/world.hpp @@ -64,6 +64,8 @@ namespace Terrain /// @note May be ignored by derived implementations that don't organize the terrain into cells. virtual void unloadCell(int x, int y) {} + virtual void enable(bool enabled) {} + Storage* getStorage() { return mStorage; } protected: