mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-06 00:55:50 +00:00
Move cell border management to World
This commit is contained in:
parent
1b8d500c07
commit
f18d57429e
@ -19,9 +19,8 @@ public:
|
||||
|
||||
TerrainGrid::TerrainGrid(osg::Group* parent, osg::Group* compileRoot, Resource::ResourceSystem* resourceSystem, Storage* storage, int nodeMask, int preCompileMask, int borderMask)
|
||||
: Terrain::World(parent, compileRoot, resourceSystem, storage, nodeMask, preCompileMask, borderMask)
|
||||
, mNumSplits(4), mBorderVisible(false)
|
||||
, mNumSplits(4)
|
||||
{
|
||||
mCellBorder.reset(new MWRender::CellBorder(this,mTerrainRoot.get()));
|
||||
}
|
||||
|
||||
TerrainGrid::~TerrainGrid()
|
||||
@ -89,8 +88,7 @@ void TerrainGrid::loadCell(int x, int y)
|
||||
if (!terrainNode)
|
||||
return; // no terrain defined
|
||||
|
||||
if (mBorderVisible)
|
||||
mCellBorder->createCellBorderGeometry(x,y);
|
||||
TerrainGrid::World::loadCell(x,y);
|
||||
|
||||
mTerrainRoot->addChild(terrainNode);
|
||||
|
||||
@ -103,8 +101,7 @@ void TerrainGrid::unloadCell(int x, int y)
|
||||
if (it == mGrid.end())
|
||||
return;
|
||||
|
||||
if (mBorderVisible)
|
||||
mCellBorder->destroyCellBorderGeometry(x,y);
|
||||
Terrain::World::unloadCell(x,y);
|
||||
|
||||
osg::ref_ptr<osg::Node> terrainNode = it->second;
|
||||
mTerrainRoot->removeChild(terrainNode);
|
||||
|
@ -7,8 +7,6 @@
|
||||
|
||||
#include "world.hpp"
|
||||
|
||||
#include "cellborder.hpp"
|
||||
|
||||
namespace Terrain
|
||||
{
|
||||
|
||||
@ -37,10 +35,6 @@ namespace Terrain
|
||||
unsigned int mNumSplits;
|
||||
|
||||
MWRender::CellBorder::CellGrid mGrid;
|
||||
|
||||
std::unique_ptr<MWRender::CellBorder> mCellBorder;
|
||||
|
||||
bool mBorderVisible;
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -18,6 +18,7 @@ World::World(osg::Group* parent, osg::Group* compileRoot, Resource::ResourceSyst
|
||||
: mStorage(storage)
|
||||
, mParent(parent)
|
||||
, mResourceSystem(resourceSystem)
|
||||
, mBorderVisible(false)
|
||||
{
|
||||
mTerrainRoot = new osg::Group;
|
||||
mTerrainRoot->setNodeMask(nodeMask);
|
||||
@ -46,6 +47,7 @@ World::World(osg::Group* parent, osg::Group* compileRoot, Resource::ResourceSyst
|
||||
|
||||
mTextureManager.reset(new TextureManager(mResourceSystem->getSceneManager()));
|
||||
mChunkManager.reset(new ChunkManager(mStorage, mResourceSystem->getSceneManager(), mTextureManager.get(), mCompositeMapRenderer));
|
||||
mCellBorder.reset(new MWRender::CellBorder(this,mTerrainRoot.get()));
|
||||
|
||||
mResourceSystem->addResourceManager(mChunkManager.get());
|
||||
mResourceSystem->addResourceManager(mTextureManager.get());
|
||||
@ -64,6 +66,26 @@ World::~World()
|
||||
delete mStorage;
|
||||
}
|
||||
|
||||
void World::setBordersVisible(bool visible)
|
||||
{
|
||||
mBorderVisible = visible;
|
||||
|
||||
if (!visible)
|
||||
mCellBorder->destroyCellBorderGeometry();
|
||||
}
|
||||
|
||||
void World::loadCell(int x, int y)
|
||||
{
|
||||
if (mBorderVisible)
|
||||
mCellBorder->createCellBorderGeometry(x,y);
|
||||
}
|
||||
|
||||
void World::unloadCell(int x, int y)
|
||||
{
|
||||
if (mBorderVisible)
|
||||
mCellBorder->destroyCellBorderGeometry(x,y);
|
||||
}
|
||||
|
||||
void World::setTargetFrameRate(float rate)
|
||||
{
|
||||
mCompositeMapRenderer->setTargetFrameRate(rate);
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include <memory>
|
||||
|
||||
#include "defs.hpp"
|
||||
#include "cellborder.hpp"
|
||||
|
||||
namespace osg
|
||||
{
|
||||
@ -76,15 +77,15 @@ namespace Terrain
|
||||
|
||||
/// Load the cell into the scene graph.
|
||||
/// @note Not thread safe.
|
||||
virtual void loadCell(int x, int y) {}
|
||||
virtual void loadCell(int x, int y);
|
||||
|
||||
/// Remove the cell from the scene graph.
|
||||
/// @note Not thread safe.
|
||||
virtual void unloadCell(int x, int y) {}
|
||||
virtual void unloadCell(int x, int y);
|
||||
|
||||
virtual void enable(bool enabled) {}
|
||||
|
||||
virtual void setBordersVisible(bool visible) {}
|
||||
virtual void setBordersVisible(bool visible);
|
||||
|
||||
/// Create a View to use with preload feature. The caller is responsible for deleting the view.
|
||||
/// @note Thread safe.
|
||||
@ -113,6 +114,10 @@ namespace Terrain
|
||||
|
||||
std::unique_ptr<TextureManager> mTextureManager;
|
||||
std::unique_ptr<ChunkManager> mChunkManager;
|
||||
|
||||
std::unique_ptr<MWRender::CellBorder> mCellBorder;
|
||||
|
||||
bool mBorderVisible;
|
||||
};
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user