diff options
author | Jon Bergli Heier <snakebite@jvnv.net> | 2011-04-09 14:31:18 +0200 |
---|---|---|
committer | Jon Bergli Heier <snakebite@jvnv.net> | 2011-04-09 14:31:18 +0200 |
commit | e9d6ab657235ebbf3eb9fcb35537c9b2181a1360 (patch) | |
tree | 7607687d7c778a4a76a4ecc70f119f02e557bc48 /quadtree.h | |
parent | 095be9811eaccd92cee156b4c486fb92b77cdcd2 (diff) |
Moved from dynamic LOD to chunked loading.
Diffstat (limited to 'quadtree.h')
-rw-r--r-- | quadtree.h | 67 |
1 files changed, 31 insertions, 36 deletions
@@ -3,64 +3,59 @@ #include "vector.h" -#include <boost/thread.hpp> +#include <list> class Quadtree { public: - - struct UpdateThread { - Quadtree *tree; - float *buffer; - UpdateThread(Quadtree *t, float *b); - void operator()(); - }; + struct QuadChunk; struct QuadNode { - Quadtree *tree; - QuadNode *parent; - QuadNode *children[4]; - int elems; + QuadChunk *chunk; float x, y, width, height; - int level; - float *vertex_array; + float vertex_array[15]; - QuadNode(Quadtree *tree, QuadNode *parent, float x, float y, float width, float height, int level, bool leaf); + QuadNode(QuadChunk *chunk, float x, float y, float width, float height); virtual ~QuadNode(); float distance(float px, float pz); void fill(); - void fix_cracks(); - void subdivide(bool leaf = true); - void merge(); void draw(); void draw_grid(); float get_height(float px, float py); Vector3 get_normal(int index); }; + struct QuadChunk { + Quadtree *tree; + QuadChunk *children[4]; + QuadNode **nodes; + float x, y, width, height; + size_t buf_size; + unsigned int vbo_object; + unsigned int node_count; + unsigned int vertices; + float init_time; + + QuadChunk(Quadtree *tree, float x, float y, float width, float height); + ~QuadChunk(); + + float distance(float px, float pz); + void make_vbo(); + QuadNode *find(float x, float y); + }; + + static const int chunk_size = 32; + + QuadChunk *root; float *heights; - float *thread_buffer; - size_t buf_size; - bool thread_done, thread_running; - boost::mutex vbo_lock; - boost::mutex node_lock; - int width, height, levels; + Vector3 *normals; + int width, height; float init_time; - QuadNode *root; - unsigned int temp_vbo; - unsigned int vbo_object; - unsigned int nodes; - unsigned int vertices; - Quadtree(int width, int height, float *heightmap, int levels); + Quadtree(int width, int height, float *heightmap); virtual ~Quadtree(); void update(float x, float z); - void fix_cracks(); - void create_nodes(int levels); - unsigned int count_nodes(); - void make_vbo(); - void update_vbo(); - QuadNode *find(float x, float y, int level = -1); + QuadNode *find(float x, float y); QuadNode *get_left(QuadNode *node); QuadNode *get_right(QuadNode *node); QuadNode *get_up(QuadNode *node); |