Overte C++ Documentation
DrawSceneOctree.h
1 //
2 // DrawSceneOctree.h
3 // render/src/render
4 //
5 // Created by Sam Gateau on 1/25/16.
6 // Copyright 2015 High Fidelity, Inc.
7 //
8 // Distributed under the Apache License, Version 2.0.
9 // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
10 //
11 
12 #ifndef hifi_render_DrawSceneOctree_h
13 #define hifi_render_DrawSceneOctree_h
14 
15 #include <ViewFrustum.h>
16 #include <gpu/Batch.h>
17 
18 #include "DrawTask.h"
19 
20 namespace render {
21  class DrawSceneOctreeConfig : public Job::Config {
22  Q_OBJECT
23  Q_PROPERTY(bool showVisibleCells READ getShowVisibleCells WRITE setShowVisibleCells NOTIFY dirty())
24  Q_PROPERTY(bool showEmptyCells READ getShowEmptyCells WRITE setShowEmptyCells NOTIFY dirty())
25  Q_PROPERTY(int numAllocatedCells READ getNumAllocatedCells)
26  Q_PROPERTY(int numFreeCells READ getNumFreeCells)
27 
28  public:
29 
30  DrawSceneOctreeConfig() : Job::Config(false) {}
31 
32  int numAllocatedCells{ 0 };
33  int numFreeCells{ 0 };
34 
35  int getNumAllocatedCells() const { return numAllocatedCells; }
36  int getNumFreeCells() const { return numFreeCells; }
37 
38  bool showVisibleCells{ true };
39  bool showEmptyCells{ false };
40 
41  bool getShowVisibleCells() { return showVisibleCells; }
42  bool getShowEmptyCells() { return showEmptyCells; }
43 
44  public slots:
45  void setShowVisibleCells(bool show) { showVisibleCells = show; emit dirty(); }
46  void setShowEmptyCells(bool show) { showEmptyCells = show; emit dirty(); }
47 
48  signals:
49  void dirty();
50  };
51 
52  class DrawSceneOctree {
53  gpu::PipelinePointer _drawCellBoundsPipeline;
54  gpu::PipelinePointer _drawLODReticlePipeline;
55  gpu::PipelinePointer _drawItemBoundPipeline;
56  gpu::BufferPointer _cellBoundsBuffer;
57  gpu::Stream::FormatPointer _cellBoundsFormat;
58 
59  bool _showVisibleCells; // initialized by Config
60  bool _showEmptyCells; // initialized by Config
61 
62  public:
63  using Config = DrawSceneOctreeConfig;
64  using JobModel = Job::ModelI<DrawSceneOctree, ItemSpatialTree::ItemSelection, Config>;
65 
66  DrawSceneOctree() {}
67 
68  void configure(const Config& config);
69  void run(const RenderContextPointer& renderContext, const ItemSpatialTree::ItemSelection& selection);
70 
71  const gpu::PipelinePointer getDrawCellBoundsPipeline();
72  const gpu::PipelinePointer getDrawLODReticlePipeline();
73  const gpu::PipelinePointer getDrawItemBoundPipeline();
74  };
75 
76 
77  class DrawItemSelectionConfig : public Job::Config {
78  Q_OBJECT
79  Q_PROPERTY(bool showInsideItems READ getShowInsideItems WRITE setShowInsideItems NOTIFY dirty())
80  Q_PROPERTY(bool showInsideSubcellItems READ getShowInsideSubcellItems WRITE setShowInsideSubcellItems NOTIFY dirty())
81  Q_PROPERTY(bool showPartialItems READ getShowPartialItems WRITE setShowPartialItems NOTIFY dirty())
82  Q_PROPERTY(bool showPartialSubcellItems READ getShowPartialSubcellItems WRITE setShowPartialSubcellItems NOTIFY dirty())
83  public:
84 
85  DrawItemSelectionConfig() : Job::Config(false) {}
86 
87  bool showInsideItems{ true };
88  bool showInsideSubcellItems{ true };
89  bool showPartialItems{ true };
90  bool showPartialSubcellItems{ true };
91 
92  bool getShowInsideItems() const { return showInsideItems; };
93  bool getShowInsideSubcellItems() const { return showInsideSubcellItems; };
94  bool getShowPartialItems() const { return showPartialItems; };
95  bool getShowPartialSubcellItems() const { return showPartialSubcellItems; };
96 
97  public slots:
98  void setShowInsideItems(bool show) { showInsideItems = show; emit dirty(); }
99  void setShowInsideSubcellItems(bool show) { showInsideSubcellItems = show; emit dirty(); }
100  void setShowPartialItems(bool show) { showPartialItems = show; emit dirty(); }
101  void setShowPartialSubcellItems(bool show) { showPartialSubcellItems = show; emit dirty(); }
102 
103  signals:
104  void dirty();
105  };
106 
107  class DrawItemSelection {
108  gpu::PipelinePointer _drawItemBoundPipeline;
109  gpu::BufferPointer _boundsBufferInside;
110  gpu::BufferPointer _boundsBufferInsideSubcell;
111  gpu::BufferPointer _boundsBufferPartial;
112  gpu::BufferPointer _boundsBufferPartialSubcell;
113 
114  bool _showInsideItems; // initialized by Config
115  bool _showInsideSubcellItems; // initialized by Config
116  bool _showPartialItems; // initialized by Config
117  bool _showPartialSubcellItems; // initialized by Config
118 
119  public:
120  using Config = DrawItemSelectionConfig;
121  using JobModel = Job::ModelI<DrawItemSelection, ItemSpatialTree::ItemSelection, Config>;
122 
123  DrawItemSelection() {}
124 
125  void configure(const Config& config);
126  void run(const RenderContextPointer& renderContext, const ItemSpatialTree::ItemSelection& selection);
127 
128  const gpu::PipelinePointer getDrawItemBoundPipeline();
129  };
130 }
131 
132 #endif // hifi_render_DrawStatus_h