2020-01-12 07:42:47 +00:00
|
|
|
#ifndef OPENMW_MWRENDER_GROUNDCOVER_H
|
|
|
|
#define OPENMW_MWRENDER_GROUNDCOVER_H
|
|
|
|
|
2022-01-22 14:58:41 +00:00
|
|
|
#include <components/esm3/loadcell.hpp>
|
2020-01-12 07:42:47 +00:00
|
|
|
#include <components/resource/scenemanager.hpp>
|
|
|
|
#include <components/terrain/quadtreeworld.hpp>
|
2024-10-12 12:16:50 +00:00
|
|
|
#include <components/vfs/pathutil.hpp>
|
2021-11-13 22:37:53 +00:00
|
|
|
|
|
|
|
namespace MWWorld
|
|
|
|
{
|
|
|
|
class ESMStore;
|
2021-10-29 12:47:17 +00:00
|
|
|
class GroundcoverStore;
|
2021-11-13 22:37:53 +00:00
|
|
|
}
|
|
|
|
namespace osg
|
|
|
|
{
|
|
|
|
class Program;
|
|
|
|
}
|
2020-01-12 07:42:47 +00:00
|
|
|
|
|
|
|
namespace MWRender
|
|
|
|
{
|
2021-09-09 21:10:22 +00:00
|
|
|
typedef std::tuple<osg::Vec2f, float> GroundcoverChunkId; // Center, Size
|
|
|
|
class Groundcover : public Resource::GenericResourceManager<GroundcoverChunkId>,
|
|
|
|
public Terrain::QuadTreeWorld::ChunkManager
|
2020-01-12 07:42:47 +00:00
|
|
|
{
|
|
|
|
public:
|
2021-10-29 12:47:17 +00:00
|
|
|
Groundcover(Resource::SceneManager* sceneManager, float density, float viewDistance,
|
|
|
|
const MWWorld::GroundcoverStore& store);
|
2021-11-13 22:37:53 +00:00
|
|
|
~Groundcover();
|
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;
|
|
|
|
|
|
|
|
unsigned int getNodeMask() override;
|
|
|
|
|
|
|
|
void reportStats(unsigned int frameNumber, osg::Stats* stats) const override;
|
|
|
|
|
|
|
|
struct GroundcoverEntry
|
|
|
|
{
|
|
|
|
ESM::Position mPos;
|
|
|
|
float mScale;
|
|
|
|
|
2021-09-29 10:08:51 +00:00
|
|
|
GroundcoverEntry(const ESM::CellRef& ref)
|
|
|
|
: mPos(ref.mPos)
|
|
|
|
, mScale(ref.mScale)
|
2021-06-23 21:36:43 +00:00
|
|
|
{
|
|
|
|
}
|
2020-01-12 07:42:47 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
private:
|
2024-10-12 12:16:50 +00:00
|
|
|
using InstanceMap = std::map<VFS::Path::Normalized, std::vector<GroundcoverEntry>, std::less<>>;
|
|
|
|
|
2020-01-12 07:42:47 +00:00
|
|
|
Resource::SceneManager* mSceneManager;
|
|
|
|
float mDensity;
|
2021-09-13 10:20:00 +00:00
|
|
|
osg::ref_ptr<osg::StateSet> mStateset;
|
2021-09-29 13:40:37 +00:00
|
|
|
osg::ref_ptr<osg::Program> mProgramTemplate;
|
2021-10-29 12:47:17 +00:00
|
|
|
const MWWorld::GroundcoverStore& mGroundcoverStore;
|
2020-01-12 07:42:47 +00:00
|
|
|
|
|
|
|
osg::ref_ptr<osg::Node> createChunk(InstanceMap& instances, const osg::Vec2f& center);
|
|
|
|
void collectInstances(InstanceMap& instances, float size, const osg::Vec2f& center);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|