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:
|
2020-04-20 16:47:14 +00:00
|
|
|
TerrainGrid(osg::Group* parent, osg::Group* compileRoot, Resource::ResourceSystem* resourceSystem, Storage* storage, int nodeMask, int preCompileMask=~0, int borderMask=0);
|
2014-06-29 00:42:36 +00:00
|
|
|
~TerrainGrid();
|
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
void cacheCell(View* view, int x, int y) override;
|
2016-02-09 19:57:30 +00:00
|
|
|
|
|
|
|
/// @note Not thread safe.
|
2020-10-16 18:18:54 +00:00
|
|
|
void loadCell(int x, int y) override;
|
2016-02-09 19:57:30 +00:00
|
|
|
|
|
|
|
/// @note Not thread safe.
|
2020-10-16 18:18:54 +00:00
|
|
|
void unloadCell(int x, int y) override;
|
2014-06-29 00:42:36 +00:00
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
View* createView() override;
|
2017-03-09 19:52:50 +00:00
|
|
|
|
2019-06-13 13:37:00 +00:00
|
|
|
protected:
|
2020-04-24 06:26:08 +00:00
|
|
|
bool isGridEmpty() const { return mGrid.empty(); }
|
2020-04-23 15:40:10 +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);
|
2019-06-13 13:37:00 +00:00
|
|
|
void updateWaterCulling();
|
2015-11-06 19:14:57 +00:00
|
|
|
|
|
|
|
// split each ESM::Cell into mNumSplits*mNumSplits terrain chunks
|
|
|
|
unsigned int mNumSplits;
|
|
|
|
|
2019-02-20 13:37:00 +00:00
|
|
|
CellBorder::CellGrid mGrid;
|
2018-06-14 10:01:09 +00:00
|
|
|
};
|
2014-06-29 00:42:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|