summaryrefslogtreecommitdiff
path: root/quadtree.h
diff options
context:
space:
mode:
Diffstat (limited to 'quadtree.h')
-rw-r--r--quadtree.h18
1 files changed, 10 insertions, 8 deletions
diff --git a/quadtree.h b/quadtree.h
index 62ac8bb..84125d2 100644
--- a/quadtree.h
+++ b/quadtree.h
@@ -2,6 +2,9 @@
#define QUADTREE_H
#include "vector.h"
+#include "terrain.h"
+
+#include <list>
class Quadtree {
public:
@@ -19,15 +22,17 @@ class Quadtree {
void fill();
void draw();
void draw_grid();
+ void draw_normal();
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;
+ float *heights;
+ Vector3 *normals;
size_t buf_size;
unsigned int vbo_object;
unsigned int node_count;
@@ -40,21 +45,18 @@ class Quadtree {
float distance(float px, float pz);
void make_vbo();
QuadNode *find(float x, float y);
+ void calc_normals();
};
static const int chunk_size = 32;
- QuadChunk *root;
- float *heights;
- Vector3 *normals;
- int width, height;
- float init_time;
- Quadtree(int width, int height, float *heightmap);
+ std::list<QuadChunk*> chunks;
+ Terrain *terrain;
+ Quadtree();
virtual ~Quadtree();
void raise(float x, float z, float radius, float focus, float strength, bool up = true);
- Vector3 calc_normal(int x, int y);
void update(float x, float z);
QuadNode *find(float x, float y);
QuadNode *get_left(QuadNode *node);