1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
#ifndef QUADTREE_H
#define QUADTREE_H
class Quadtree {
public:
struct QuadNode {
Quadtree *tree;
QuadNode *parent;
QuadNode *children[4];
int elems;
float x, y, width, height;
int level;
float *vertex_array;
QuadNode(Quadtree *tree, QuadNode *parent, float x, float y, float width, float height, int level, bool leaf);
virtual ~QuadNode();
void subdivide(bool leaf = true);
void draw();
void draw_grid();
float get_height(float px, float py);
};
float *heights;
int width, height, levels;
float init_time;
QuadNode *root;
unsigned int vbo_object;
unsigned int nodes;
unsigned int vertices;
Quadtree(int width, int height, float *heightmap, int levels);
virtual ~Quadtree();
unsigned int count_nodes();
void make_vbo();
QuadNode *find(float x, float y);
};
#endif
|