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