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