summaryrefslogtreecommitdiff
path: root/quadtree.h
diff options
context:
space:
mode:
Diffstat (limited to 'quadtree.h')
-rw-r--r--quadtree.h67
1 files changed, 31 insertions, 36 deletions
diff --git a/quadtree.h b/quadtree.h
index b927dee..d6d1e8e 100644
--- a/quadtree.h
+++ b/quadtree.h
@@ -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);