1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-25 06:35:30 +00:00
OpenMW/components/terrain/terraingrid.hpp

53 lines
1.5 KiB
C++
Raw Normal View History

#ifndef COMPONENTS_TERRAIN_TERRAINGRID_H
#define COMPONENTS_TERRAIN_TERRAINGRID_H
#include <map>
#include <osg/Vec2f>
#include "world.hpp"
2016-02-19 15:00:50 +01:00
namespace osg
{
class Texture2D;
}
namespace Terrain
{
/// @brief Simple terrain implementation that loads cells in a grid, with no LOD
class TerrainGrid : public Terrain::World
{
public:
2017-03-07 15:04:41 +01:00
TerrainGrid(osg::Group* parent, Resource::ResourceSystem* resourceSystem, osgUtil::IncrementalCompileOperation* ico, Storage* storage, int nodeMask);
~TerrainGrid();
2016-02-09 20:57:30 +01:00
/// Load a terrain cell and store it in cache for later use.
/// @note The returned ref_ptr should be kept by the caller to ensure that the terrain stays in cache for as long as needed.
/// @note Thread safe.
virtual osg::ref_ptr<osg::Node> cacheCell(int x, int y);
/// @note Not thread safe.
virtual void loadCell(int x, int y);
2016-02-09 20:57:30 +01:00
/// @note Not thread safe.
virtual void unloadCell(int x, int y);
/// Apply the scene manager's texture filtering settings to all cached textures.
/// @note Thread safe.
void updateTextureFiltering();
private:
osg::ref_ptr<osg::Node> buildTerrain (osg::Group* parent, float chunkSize, const osg::Vec2f& chunkCenter);
// split each ESM::Cell into mNumSplits*mNumSplits terrain chunks
unsigned int mNumSplits;
2016-02-09 20:23:53 +01:00
typedef std::map<std::pair<int, int>, osg::ref_ptr<osg::Node> > Grid;
Grid mGrid;
};
}
#endif