]> git.tdb.fi Git - libs/gl.git/blob - source/occludedscene.h
Make animation curve creation more generic
[libs/gl.git] / source / occludedscene.h
1 #ifndef MSP_GL_OCCLUDEDSCENE_H_
2 #define MSP_GL_OCCLUDEDSCENE_H_
3
4 #include <set>
5 #include <vector>
6 #include "mesh.h"
7 #include "program.h"
8 #include "scene.h"
9
10 namespace Msp {
11 namespace GL {
12
13 /**
14 A scene that performs occlusion queries on renderables to skip those that are
15 entirely occluded by others.
16 */
17 class OccludedScene: public Scene
18 {
19 private:
20         struct OccludedRenderable
21         {
22                 Renderable *renderable;
23                 const Geometry::BoundingSphere<float, 3> *bounding_sphere;
24                 bool in_frustum;
25                 bool occluder;
26                 unsigned query;
27
28                 OccludedRenderable();
29         };
30
31         typedef std::set<Renderable *> RenderableSet;
32         typedef std::vector<OccludedRenderable> OccludedArray;
33
34         Mesh bounding_mesh;
35         Program bounding_shader;
36         RenderableSet renderables;
37         float occluder_min_size;
38         mutable OccludedArray occluded_cache;
39         mutable bool cache_dirty;
40
41 public:
42         OccludedScene();
43         ~OccludedScene();
44
45         virtual void add(Renderable &);
46         virtual void remove(Renderable &);
47
48 private:
49         void populate_cache() const;
50
51 public:
52         virtual void setup_frame(Renderer &);
53         virtual void finish_frame();
54
55         virtual void render(Renderer &, const Tag & = Tag()) const;
56 };
57
58 } // namespace GL
59 } // namespace Msp
60
61 #endif