#ifndef COMPONENTS_TERRAIN_TERRAINGRID_H #define COMPONENTS_TERRAIN_TERRAINGRID_H #include #include #include "world.hpp" 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: TerrainGrid(osg::Group* parent, osg::Group* compileRoot, Resource::ResourceSystem* resourceSystem, Storage* storage, int nodeMask, int preCompileMask=~0); ~TerrainGrid(); /// 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 cacheCell(int x, int y); /// @note Not thread safe. virtual void loadCell(int x, int y); /// @note Not thread safe. virtual void unloadCell(int x, int y); private: osg::ref_ptr buildTerrain (osg::Group* parent, float chunkSize, const osg::Vec2f& chunkCenter); // split each ESM::Cell into mNumSplits*mNumSplits terrain chunks unsigned int mNumSplits; typedef std::map, osg::ref_ptr > Grid; Grid mGrid; }; } #endif