CompositeMap is plain data shared between a TerrainDrawable and the CompositeMapRenderer compile queue; it never reaches the scene graph, so it needs no osg::Referenced base.
74 lines
1.9 KiB
C++
74 lines
1.9 KiB
C++
#ifndef OPENMW_COMPONENTS_TERRAIN_COMPOSITEMAPRENDERER_H
|
|
#define OPENMW_COMPONENTS_TERRAIN_COMPOSITEMAPRENDERER_H
|
|
|
|
#include <osg/Drawable>
|
|
|
|
#include <memory>
|
|
#include <mutex>
|
|
#include <set>
|
|
|
|
namespace osg
|
|
{
|
|
class FrameBufferObject;
|
|
class RenderInfo;
|
|
class Texture2D;
|
|
}
|
|
|
|
namespace Terrain
|
|
{
|
|
|
|
class CompositeMap
|
|
{
|
|
public:
|
|
std::vector<osg::ref_ptr<osg::Drawable>> mDrawables;
|
|
osg::ref_ptr<osg::Texture2D> mTexture;
|
|
size_t mCompiled = 0;
|
|
};
|
|
|
|
/**
|
|
* @brief The CompositeMapRenderer is responsible for updating composite map textures in a blocking or non-blocking
|
|
* way.
|
|
*/
|
|
class CompositeMapRenderer : public osg::Drawable
|
|
{
|
|
public:
|
|
CompositeMapRenderer();
|
|
~CompositeMapRenderer();
|
|
|
|
void drawImplementation(osg::RenderInfo& renderInfo) const override;
|
|
|
|
void compile(CompositeMap& compositeMap, osg::RenderInfo& renderInfo) const;
|
|
|
|
/// Set the available time in seconds for compiling (non-immediate) composite maps each frame
|
|
void setMinimumTimeAvailableForCompile(double time);
|
|
|
|
/// If current frame rate is higher than this, the extra time will be set aside to do more compiling
|
|
void setTargetFrameRate(float framerate);
|
|
|
|
/// Add a composite map to be rendered
|
|
void addCompositeMap(const std::shared_ptr<CompositeMap>& map, bool immediate = false);
|
|
|
|
/// Mark this composite map to be required for the current frame
|
|
void setImmediate(const std::shared_ptr<CompositeMap>& map);
|
|
|
|
size_t getCompileSetSize() const;
|
|
|
|
private:
|
|
float mTargetFrameRate;
|
|
double mMinimumTimeAvailable;
|
|
mutable osg::Timer mTimer;
|
|
|
|
typedef std::set<std::shared_ptr<CompositeMap>> CompileSet;
|
|
|
|
mutable CompileSet mCompileSet;
|
|
mutable CompileSet mImmediateCompileSet;
|
|
|
|
mutable std::mutex mMutex;
|
|
|
|
osg::ref_ptr<osg::FrameBufferObject> mFBO;
|
|
};
|
|
|
|
}
|
|
|
|
#endif
|