2014-08-07 18:43:33 +00:00
|
|
|
#ifndef COMPONENTS_TERRAIN_TERRAINGRID_H
|
|
|
|
#define COMPONENTS_TERRAIN_TERRAINGRID_H
|
2014-06-29 00:42:36 +00:00
|
|
|
|
2017-03-06 19:41:02 +00:00
|
|
|
#include <map>
|
|
|
|
|
2015-11-06 19:14:57 +00:00
|
|
|
#include <osg/Vec2f>
|
|
|
|
|
2014-08-07 18:43:33 +00:00
|
|
|
#include "world.hpp"
|
2014-06-29 00:42:36 +00:00
|
|
|
|
|
|
|
namespace Terrain
|
|
|
|
{
|
|
|
|
|
2017-03-08 00:53:13 +00:00
|
|
|
/// @brief Simple terrain implementation that loads cells in a grid, with no LOD. Only requested cells are loaded.
|
2014-06-29 00:42:36 +00:00
|
|
|
class TerrainGrid : public Terrain::World
|
|
|
|
{
|
|
|
|
public:
|
2017-03-07 16:25:23 +00:00
|
|
|
TerrainGrid(osg::Group* parent, osg::Group* compileRoot, Resource::ResourceSystem* resourceSystem, Storage* storage, int nodeMask, int preCompileMask=~0);
|
2014-06-29 00:42:36 +00:00
|
|
|
~TerrainGrid();
|
|
|
|
|
2017-03-09 19:52:50 +00:00
|
|
|
virtual void cacheCell(View* view, int x, int y);
|
2016-02-09 19:57:30 +00:00
|
|
|
|
|
|
|
/// @note Not thread safe.
|
2014-06-29 00:42:36 +00:00
|
|
|
virtual void loadCell(int x, int y);
|
2016-02-09 19:57:30 +00:00
|
|
|
|
|
|
|
/// @note Not thread safe.
|
2014-06-29 00:42:36 +00:00
|
|
|
virtual void unloadCell(int x, int y);
|
|
|
|
|
2017-03-09 19:52:50 +00:00
|
|
|
View* createView();
|
|
|
|
|
2014-06-29 00:42:36 +00:00
|
|
|
private:
|
2015-11-06 19:14:57 +00: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 19:23:53 +00:00
|
|
|
typedef std::map<std::pair<int, int>, osg::ref_ptr<osg::Node> > Grid;
|
2014-06-29 00:42:36 +00:00
|
|
|
Grid mGrid;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|