1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-02-06 09:39:49 +00:00
OpenMW/apps/openmw/mwrender/groundcover.hpp

64 lines
1.9 KiB
C++
Raw Normal View History

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