diff options
author | Jon Bergli Heier <snakebite@jvnv.net> | 2011-03-30 22:30:35 +0200 |
---|---|---|
committer | Jon Bergli Heier <snakebite@jvnv.net> | 2011-03-30 22:30:35 +0200 |
commit | d8a69e6abeea2034c17d84ef74009b137faa06cc (patch) | |
tree | 7ed3fbd07adc8328aba71cfb26ffc3eb5ff5ebf7 /quadtree.h |
Initial commit.
Diffstat (limited to 'quadtree.h')
-rw-r--r-- | quadtree.h | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/quadtree.h b/quadtree.h new file mode 100644 index 0000000..9a84e98 --- /dev/null +++ b/quadtree.h @@ -0,0 +1,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 |