mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-22 13:23:55 +00:00
9d661359a1
* chunkmanager.hpp viewdistance * chunkmanager.cpp viewdistance * chunkmanager.hpp viewdistance * quadtreeworld.cpp viewdistance * quadtreeworld.cpp consolidate * quadtreeworld.hpp consolidate * renderingmanager.cpp groundcover consolidate * renderingmanager.hpp groundcover consolidate * renderingmanager.cpp updater move * renderingmanager.hpp updater move * groundcover.hpp activegrid consolidation * groundcover.cpp activegrid consolidation * settings-default.cfg dead settings remove * viewdata.cpp revert * wrong file paste mistake * wrong file paste mistake * wrong file paste mistake * renderingmanager.cpp updatecallback fix * renderingmanager.cpp namespace fix * groundcover.hpp redefinition fix * groundcover.cpp redefinition fix * renderingmanager.cpp crash fix * renderingmanager.cpp euclidean groundcover distance * viewdata.hpp getreusedistance * quadtreeworld.cpp reusedistance * groundcover.rst [ci skip]
79 lines
2.6 KiB
C++
79 lines
2.6 KiB
C++
#ifndef COMPONENTS_TERRAIN_QUADTREEWORLD_H
|
|
#define COMPONENTS_TERRAIN_QUADTREEWORLD_H
|
|
|
|
#include "world.hpp"
|
|
#include "terraingrid.hpp"
|
|
|
|
#include <mutex>
|
|
|
|
namespace osg
|
|
{
|
|
class NodeVisitor;
|
|
}
|
|
|
|
namespace Terrain
|
|
{
|
|
class RootNode;
|
|
class ViewDataMap;
|
|
|
|
/// @brief Terrain implementation that loads cells into a Quad Tree, with geometry LOD and texture LOD.
|
|
class QuadTreeWorld : public TerrainGrid // note: derived from TerrainGrid is only to render default cells (see loadCell)
|
|
{
|
|
public:
|
|
QuadTreeWorld(osg::Group* parent, osg::Group* compileRoot, Resource::ResourceSystem* resourceSystem, Storage* storage, unsigned int nodeMask, unsigned int preCompileMask, unsigned int borderMask, int compMapResolution, float comMapLevel, float lodFactor, int vertexLodMod, float maxCompGeometrySize);
|
|
|
|
~QuadTreeWorld();
|
|
|
|
void accept(osg::NodeVisitor& nv);
|
|
|
|
void enable(bool enabled) override;
|
|
|
|
void setViewDistance(float distance) override { mViewDistance = distance; }
|
|
|
|
void cacheCell(View *view, int x, int y) override {}
|
|
/// @note Not thread safe.
|
|
void loadCell(int x, int y) override;
|
|
/// @note Not thread safe.
|
|
void unloadCell(int x, int y) override;
|
|
|
|
View* createView() override;
|
|
void preload(View* view, const osg::Vec3f& eyePoint, const osg::Vec4i &cellgrid, std::atomic<bool>& abort, Loading::Reporter& reporter) override;
|
|
bool storeView(const View* view, double referenceTime) override;
|
|
void rebuildViews() override;
|
|
|
|
void reportStats(unsigned int frameNumber, osg::Stats* stats) override;
|
|
|
|
class ChunkManager
|
|
{
|
|
public:
|
|
virtual ~ChunkManager(){}
|
|
virtual 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) = 0;
|
|
virtual unsigned int getNodeMask() { return 0; }
|
|
|
|
void setViewDistance(float viewDistance) { mViewDistance = viewDistance; }
|
|
float getViewDistance() const { return mViewDistance; }
|
|
private:
|
|
float mViewDistance = 0.f;
|
|
};
|
|
void addChunkManager(ChunkManager*);
|
|
|
|
private:
|
|
void ensureQuadTreeBuilt();
|
|
|
|
osg::ref_ptr<RootNode> mRootNode;
|
|
|
|
osg::ref_ptr<ViewDataMap> mViewDataMap;
|
|
|
|
std::vector<ChunkManager*> mChunkManagers;
|
|
|
|
std::mutex mQuadTreeMutex;
|
|
bool mQuadTreeBuilt;
|
|
float mLodFactor;
|
|
int mVertexLodMod;
|
|
float mViewDistance;
|
|
float mMinSize;
|
|
};
|
|
|
|
}
|
|
|
|
#endif
|