2014-08-07 20:43:33 +02:00
|
|
|
#ifndef COMPONENTS_TERRAIN_TERRAINGRID_H
|
|
|
|
#define COMPONENTS_TERRAIN_TERRAINGRID_H
|
2014-06-29 02:42:36 +02:00
|
|
|
|
2017-03-06 20:41:02 +01:00
|
|
|
#include <map>
|
|
|
|
|
2015-11-06 20:14:57 +01:00
|
|
|
#include <osg/Vec2f>
|
|
|
|
|
2014-08-07 20:43:33 +02:00
|
|
|
#include "world.hpp"
|
2014-06-29 02:42:36 +02:00
|
|
|
|
2016-02-19 15:00:50 +01:00
|
|
|
namespace osg
|
|
|
|
{
|
|
|
|
class Texture2D;
|
|
|
|
}
|
|
|
|
|
2014-06-29 02:42:36 +02:00
|
|
|
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);
|
2014-06-29 02:42:36 +02:00
|
|
|
~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.
|
2014-06-29 02:42:36 +02:00
|
|
|
virtual void loadCell(int x, int y);
|
2016-02-09 20:57:30 +01:00
|
|
|
|
|
|
|
/// @note Not thread safe.
|
2014-06-29 02:42:36 +02:00
|
|
|
virtual void unloadCell(int x, int y);
|
|
|
|
|
2016-02-14 23:14:52 +01:00
|
|
|
/// Apply the scene manager's texture filtering settings to all cached textures.
|
|
|
|
/// @note Thread safe.
|
|
|
|
void updateTextureFiltering();
|
|
|
|
|
2014-06-29 02:42:36 +02:00
|
|
|
private:
|
2015-11-06 20:14:57 +01:00
|
|
|
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;
|
2014-06-29 02:42:36 +02:00
|
|
|
Grid mGrid;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|