2017-03-08 01:53:13 +01:00
|
|
|
#ifndef COMPONENTS_TERRAIN_QUADTREEWORLD_H
|
|
|
|
#define COMPONENTS_TERRAIN_QUADTREEWORLD_H
|
|
|
|
|
|
|
|
#include "world.hpp"
|
2019-02-28 22:19:48 +04:00
|
|
|
#include "terraingrid.hpp"
|
2017-03-08 01:53:13 +01:00
|
|
|
|
2017-03-09 03:31:30 +01:00
|
|
|
#include <OpenThreads/Mutex>
|
|
|
|
|
2017-03-08 01:53:13 +01:00
|
|
|
namespace osg
|
|
|
|
{
|
|
|
|
class NodeVisitor;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace Terrain
|
|
|
|
{
|
|
|
|
class RootNode;
|
2017-03-09 02:03:51 +01:00
|
|
|
class ViewDataMap;
|
2017-03-08 01:53:13 +01:00
|
|
|
|
|
|
|
/// @brief Terrain implementation that loads cells into a Quad Tree, with geometry LOD and texture LOD. The entire world is displayed at all times.
|
2019-02-28 22:19:48 +04:00
|
|
|
class QuadTreeWorld : public TerrainGrid // note: derived from TerrainGrid is only to render default cells (see loadCell)
|
2017-03-08 01:53:13 +01:00
|
|
|
{
|
|
|
|
public:
|
2019-02-28 12:48:04 +04:00
|
|
|
QuadTreeWorld(osg::Group* parent, osg::Group* compileRoot, Resource::ResourceSystem* resourceSystem, Storage* storage, int nodeMask, int preCompileMask, int borderMask, int compMapResolution, float comMapLevel, float lodFactor, int vertexLodMod, float maxCompGeometrySize);
|
2019-02-20 13:37:00 +00:00
|
|
|
|
2017-03-08 01:53:13 +01:00
|
|
|
~QuadTreeWorld();
|
|
|
|
|
|
|
|
void accept(osg::NodeVisitor& nv);
|
|
|
|
|
2017-03-09 02:17:25 +01:00
|
|
|
virtual void enable(bool enabled);
|
|
|
|
|
2017-03-09 21:05:25 +01:00
|
|
|
void cacheCell(View *view, int x, int y);
|
2019-02-28 22:19:48 +04:00
|
|
|
/// @note Not thread safe.
|
|
|
|
virtual void loadCell(int x, int y);
|
|
|
|
/// @note Not thread safe.
|
|
|
|
virtual void unloadCell(int x, int y);
|
2017-03-09 21:05:25 +01:00
|
|
|
|
2017-03-09 04:17:25 +01:00
|
|
|
View* createView();
|
|
|
|
void preload(View* view, const osg::Vec3f& eyePoint);
|
|
|
|
|
2017-03-09 19:52:30 +01:00
|
|
|
void reportStats(unsigned int frameNumber, osg::Stats* stats);
|
|
|
|
|
2017-07-19 13:11:44 +02:00
|
|
|
virtual void setDefaultViewer(osg::Object* obj);
|
|
|
|
|
2017-03-08 01:53:13 +01:00
|
|
|
private:
|
2017-03-09 03:31:30 +01:00
|
|
|
void ensureQuadTreeBuilt();
|
|
|
|
|
2017-03-08 01:53:13 +01:00
|
|
|
osg::ref_ptr<RootNode> mRootNode;
|
|
|
|
|
2017-03-09 02:03:51 +01:00
|
|
|
osg::ref_ptr<ViewDataMap> mViewDataMap;
|
|
|
|
|
2017-03-09 03:31:30 +01:00
|
|
|
OpenThreads::Mutex mQuadTreeMutex;
|
2017-03-08 01:53:13 +01:00
|
|
|
bool mQuadTreeBuilt;
|
2019-02-27 19:41:07 +04:00
|
|
|
float mLodFactor;
|
2019-02-20 13:37:00 +00:00
|
|
|
int mVertexLodMod;
|
2017-03-08 01:53:13 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|