GlobeEngine
KPatchBintree.h
Go to the documentation of this file.
1 
8 #ifndef GlobeEngine_Raster_KPatchbintree_h
9 #define GlobeEngine_Raster_KPatchbintree_h
10 
11 #include "OpenGL_Includes.h"
12 #include "KPatchBase.h"
13 #include "KPatchBintreeNode.h"
14 #include "DrawableComponent.h"
15 #include "MBlockQuadtree.h"
16 #include "MBlock.h"
17 #include "ArrayTree.h"
18 #include "BufferArray.h"
19 #include "Buffer.h"
20 #include "DrawCommand.h"
21 #include "Timer.h"
22 #include "TerrainConfigStructs.h"
23 
24 namespace geRaster {
25 
27  {
28 
29  public:
30  KPatchBintree();
32  void clear();
33  void clearBintree();
34  void create() {};
35  void create(std::shared_ptr<MBlockQuadtree> _quadtree, short _max_lod, double _max_dist_error, KPatchBase::PatchMode _mode, vmml::Vector3d _pos,short _maxQuadtreeLodLevels);
36  void draw(std::shared_ptr<ge::Camera> _cam);
37  void update();
38  void drawPrimitives();
39 
40  void saturateError(int _uid, vmml::Vector3d _pos);
41  void generateBintree(const vmml::Vector3d _pos);
42  //void generateBintreeNodes(int _uid, const vmml::Vector3d& _pos);
43  void generateBintreeNodesAtLod(int _uid, int _lod, const vmml::Vector3d& _pos);
44 
45  //void assignKPatchesToMBlocks();
47  void createGeometry();
48  void updateUniformBuffers();
49 
50  void printKPatchBintree(unsigned int _lod);
51  void printKPatchBintreeGeometryInformation(unsigned int _lod);
52  void printVertexArray();
53  void printIndexArray();
54  void printBuffers();
55  void drawDebug(std::shared_ptr<ge::Camera> _cam);
56 
57  void rescale(float _input);
58 
61 
63 
64  private:
65  bool checkDistanceCriterionForBin(int _uid, const vmml::Vector3d& _pos);
66  //void balanceUp(int _searchID);
67  void restrictNeighbour(int _nodeId, bool _order);
68  int getIDFromBitset(std::bitset<40> const& _bitset, short _lod, short _bintreeRoot);
69  void setMBlockRef(int _uid, int _refID);
70  void clearInitial();
71  //Tree resolution interface
72  void createRootChildren();
73  void forceSplitOnBin(int _nodeId);
74 
75  private:
76 
77  std::shared_ptr<MBlockQuadtree> quadtree;
78  std::vector< std::shared_ptr<KPatchBintreeNode> > bins;
79 
80  // draw state
82 
83  // contains information if bin is visible or not
84  int binCapacity;
85 
86  // visibleIndices are sorted according to MBlocks
87  std::vector<int> visibleKPatches;
88  int visibleKPatchesSize;
89  bool isParent;
90  double bounds[4];
91  double edgelength;
92  int children[2];
93  short patchSize;
94 
95  bool updateShader;
96 
97  // Error metrix parameters
98  short maxBintreeLod;
99  double max_dist_for_error_metric;
100  double distErrorStepPerLod;
101 
102  //BintreeGPUBuffer frontbuffer;
103  TriangulationGPUBuffer backbuffer;
104 
106  TerrainVis::ErrorMetricType metrictype;
107 
108  // Reference KPatch info
109  std::shared_ptr<KPatchBase> basePatch;
110  int kPatchIndexCount;
111  int kPatchSideLenght;
112  // should only be necessary when changing kpatch properties
113  // or only the first time generating geometry
114  bool kpatchInfoUpdateNecessary;
115 
116  float rescaleValue;
117  // uniform buffer
118  ge::UniformBufferArray triangulationInfo;
119 
120 #ifndef GENGINE_GL_BELOW_410
121  ge::DrawIndirectBuffer indirectCommandBuffer;
122 #endif
123  ge::Timer openglTimer;
124 
125  // avoid allocation in createGeometry()
126  std::vector<ge::DrawArraysIndirectCommand> indirectCommands;
127  };
128 }
129 #endif
130 
Definition: DrawableComponent.h:25
void drawDebug(std::shared_ptr< ge::Camera > _cam)
KPatchBintree()
Definition: KPatchBintree.cpp:10
void printKPatchBintreeGeometryInformation(unsigned int _lod)
Definition: KPatchBintree.cpp:746
Definition: KPatchBase.h:13
void printKPatchBintree(unsigned int _lod)
Definition: KPatchBintree.cpp:722
void updateUniformBlockBinding()
Definition: KPatchBintree.cpp:115
void updateVisualizationTypeInShader()
Definition: KPatchBintree.cpp:785
~KPatchBintree()
Definition: KPatchBintree.cpp:16
Definition: Buffer.h:18
void create()
Definition: KPatchBintree.h:34
Definition: BufferArray.h:18
Definition: KPatchBintree.h:26
void update()
Definition: KPatchBintree.cpp:715
void createGeometry()
Definition: KPatchBintree.cpp:459
void updateUniformBuffers()
Definition: KPatchBintree.cpp:99
void sortVisibleKPatchToMBlocks()
Definition: KPatchBintree.cpp:442
void clear()
Definition: KPatchBintree.cpp:23
void setVisualizationType(TerrainVis::VisualizationMode _input)
Definition: KPatchBintree.cpp:774
void draw(std::shared_ptr< ge::Camera > _cam)
Definition: KPatchBintree.cpp:629
void printBuffers()
Definition: KPatchBintree.cpp:763
Definition: TerrainConfigStructs.h:41
void saturateError(int _uid, vmml::Vector3d _pos)
ErrorMetricType
Definition: TerrainConfigStructs.h:34
void generateBintree(const vmml::Vector3d _pos)
Definition: KPatchBintree.cpp:277
void drawPrimitives()
Definition: KPatchBintree.cpp:688
void rescale(float _input)
Definition: KPatchBintree.cpp:769
PatchMode
Definition: KPatchBase.h:21
void generateBintreeNodesAtLod(int _uid, int _lod, const vmml::Vector3d &_pos)
Definition: KPatchBintree.cpp:297
Definition: Timer.h:17
VisualizationMode
Definition: TerrainConfigStructs.h:17