X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Foccludedscene.h;fp=source%2Foccludedscene.h;h=3f8ca76ce4dcbfe40dc3edaa5553f92785640acb;hb=b160f64ab6da260bad06a4e5f5bfed243e2cdc24;hp=0000000000000000000000000000000000000000;hpb=3e6a7f8ae2ba43728d16954ac7c31257b7bfb581;p=libs%2Fgl.git diff --git a/source/occludedscene.h b/source/occludedscene.h new file mode 100644 index 00000000..3f8ca76c --- /dev/null +++ b/source/occludedscene.h @@ -0,0 +1,54 @@ +#ifndef MSP_GL_OCCLUDEDSCENE_H_ +#define MSP_GL_OCCLUDEDSCENE_H_ + +#include +#include +#include "mesh.h" +#include "program.h" +#include "scene.h" + +namespace Msp { +namespace GL { + +/** +A scene that performs occlusion queries on renderables to skip those that are +entirely occluded by others. +*/ +class OccludedScene: public Scene +{ +private: + struct OccludedRenderable + { + const Renderable *renderable; + const Geometry::BoundingSphere *bounding_sphere; + bool in_frustum; + bool occluder; + unsigned query; + + OccludedRenderable(); + }; + + typedef std::set RenderableSet; + typedef std::vector OccludedArray; + + Mesh bounding_mesh; + Program bounding_shader; + RenderableSet renderables; + float occluder_min_size; + mutable OccludedArray occluded_cache; + mutable bool cache_dirty; + +public: + OccludedScene(); + ~OccludedScene(); + + virtual void add(const Renderable &); + virtual void remove(const Renderable &); + + virtual void render(Renderer &, const Tag &) const; +}; + +} // namespace GL +} // namespace Msp + +#endif