2017-03-06 19:41:02 +00:00
|
|
|
#ifndef OPENMW_COMPONENTS_TERRAIN_CHUNKMANAGER_H
|
|
|
|
#define OPENMW_COMPONENTS_TERRAIN_CHUNKMANAGER_H
|
|
|
|
|
2019-03-13 07:15:58 +00:00
|
|
|
#include <tuple>
|
|
|
|
|
2017-03-06 19:41:02 +00:00
|
|
|
#include <components/resource/resourcemanager.hpp>
|
|
|
|
|
|
|
|
#include "buffercache.hpp"
|
2019-06-13 13:37:00 +00:00
|
|
|
#include "quadtreeworld.hpp"
|
2017-03-06 19:41:02 +00:00
|
|
|
|
|
|
|
namespace osg
|
|
|
|
{
|
2017-03-07 15:33:31 +00:00
|
|
|
class Group;
|
|
|
|
class Texture2D;
|
2017-03-06 19:41:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
namespace Resource
|
|
|
|
{
|
|
|
|
class SceneManager;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace Terrain
|
|
|
|
{
|
|
|
|
|
|
|
|
class TextureManager;
|
2017-03-07 15:33:31 +00:00
|
|
|
class CompositeMapRenderer;
|
2017-03-06 19:41:02 +00:00
|
|
|
class Storage;
|
2017-03-09 18:17:58 +00:00
|
|
|
class CompositeMap;
|
2021-09-27 19:32:18 +00:00
|
|
|
class TerrainDrawable;
|
2017-03-06 19:41:02 +00:00
|
|
|
|
2019-03-13 07:15:58 +00:00
|
|
|
typedef std::tuple<osg::Vec2f, unsigned char, unsigned int> ChunkId; // Center, Lod, Lod Flags
|
|
|
|
|
2017-03-06 19:41:02 +00:00
|
|
|
/// @brief Handles loading and caching of terrain chunks
|
2019-06-13 13:37:00 +00:00
|
|
|
class ChunkManager : public Resource::GenericResourceManager<ChunkId>, public QuadTreeWorld::ChunkManager
|
2017-03-06 19:41:02 +00:00
|
|
|
{
|
|
|
|
public:
|
2017-03-07 15:33:31 +00:00
|
|
|
ChunkManager(Storage* storage, Resource::SceneManager* sceneMgr, TextureManager* textureManager, CompositeMapRenderer* renderer);
|
2017-03-06 19:41:02 +00:00
|
|
|
|
2020-01-12 07:42:47 +00:00
|
|
|
osg::ref_ptr<osg::Node> getChunk(float size, const osg::Vec2f& center, unsigned char lod, unsigned int lodFlags, bool activeGrid, const osg::Vec3f& viewPoint, bool compile) override;
|
2017-03-06 19:41:02 +00:00
|
|
|
|
2019-02-27 15:41:07 +00:00
|
|
|
void setCompositeMapSize(unsigned int size) { mCompositeMapSize = size; }
|
|
|
|
void setCompositeMapLevel(float level) { mCompositeMapLevel = level; }
|
2019-02-28 08:48:04 +00:00
|
|
|
void setMaxCompositeGeometrySize(float maxCompGeometrySize) { mMaxCompGeometrySize = maxCompGeometrySize; }
|
2019-02-27 15:41:07 +00:00
|
|
|
|
2019-06-13 13:37:00 +00:00
|
|
|
void setNodeMask(unsigned int mask) { mNodeMask = mask; }
|
2020-10-16 18:18:54 +00:00
|
|
|
unsigned int getNodeMask() override { return mNodeMask; }
|
2019-06-13 13:37:00 +00:00
|
|
|
|
2017-09-18 08:51:11 +00:00
|
|
|
void reportStats(unsigned int frameNumber, osg::Stats* stats) const override;
|
2017-03-06 19:41:02 +00:00
|
|
|
|
2017-09-18 08:51:11 +00:00
|
|
|
void clearCache() override;
|
2017-08-21 02:34:41 +00:00
|
|
|
|
2017-08-26 19:28:23 +00:00
|
|
|
void releaseGLObjects(osg::State* state) override;
|
|
|
|
|
2017-03-06 19:41:02 +00:00
|
|
|
private:
|
2021-09-27 19:32:18 +00:00
|
|
|
osg::ref_ptr<osg::Node> createChunk(float size, const osg::Vec2f& center, unsigned char lod, unsigned int lodFlags, bool compile, TerrainDrawable* templateGeometry);
|
2017-03-06 19:41:02 +00:00
|
|
|
|
2017-03-09 18:17:58 +00:00
|
|
|
osg::ref_ptr<osg::Texture2D> createCompositeMapRTT();
|
2017-03-07 15:33:31 +00:00
|
|
|
|
2017-03-09 18:17:58 +00:00
|
|
|
void createCompositeMapGeometry(float chunkSize, const osg::Vec2f& chunkCenter, const osg::Vec4f& texCoords, CompositeMap& map);
|
2017-03-08 21:13:05 +00:00
|
|
|
|
|
|
|
std::vector<osg::ref_ptr<osg::StateSet> > createPasses(float chunkSize, const osg::Vec2f& chunkCenter, bool forCompositeMap);
|
|
|
|
|
2017-03-06 19:41:02 +00:00
|
|
|
Terrain::Storage* mStorage;
|
|
|
|
Resource::SceneManager* mSceneManager;
|
|
|
|
TextureManager* mTextureManager;
|
2017-03-07 15:33:31 +00:00
|
|
|
CompositeMapRenderer* mCompositeMapRenderer;
|
2017-03-06 19:41:02 +00:00
|
|
|
BufferCache mBufferCache;
|
2017-03-07 15:33:31 +00:00
|
|
|
|
2020-05-07 13:37:00 +00:00
|
|
|
osg::ref_ptr<osg::StateSet> mMultiPassRoot;
|
|
|
|
|
2019-06-13 13:37:00 +00:00
|
|
|
unsigned int mNodeMask;
|
|
|
|
|
2017-03-07 15:33:31 +00:00
|
|
|
unsigned int mCompositeMapSize;
|
2019-02-27 15:41:07 +00:00
|
|
|
float mCompositeMapLevel;
|
2019-02-28 08:48:04 +00:00
|
|
|
float mMaxCompGeometrySize;
|
2017-03-06 19:41:02 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|