diff options
author | Jon Bergli Heier <snakebite@jvnv.net> | 2011-05-08 15:02:30 +0200 |
---|---|---|
committer | Jon Bergli Heier <snakebite@jvnv.net> | 2011-05-08 15:02:30 +0200 |
commit | 7d5c1adf8e581599848b3fec54e0af88eb469046 (patch) | |
tree | 824d398dc14b7044b49d15b35d0c3501264e10fd /terrain.cpp | |
parent | 17715403aff8ba1889c9e1ef473fe9319b87d1d2 (diff) |
Working dynamic generation of terrain.
Diffstat (limited to 'terrain.cpp')
-rw-r--r-- | terrain.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/terrain.cpp b/terrain.cpp index a44d0d3..e0cd291 100644 --- a/terrain.cpp +++ b/terrain.cpp @@ -18,7 +18,7 @@ float *Terrain::generate_heights(int x, int y, int width, int height) { heightmap_builder.SetDestNoiseMap(heightmap); heightmap_builder.SetDestSize(width, height); - heightmap_builder.SetBounds(x / 100, (x+width) / 100, y / 100, (y+height) / 100); + heightmap_builder.SetBounds((double)x / 100, (double)(x+width) / 100, (double)y / 100, (double)(y+height) / 100); heightmap_builder.Build(); float *heights = new float[width*height]; @@ -28,5 +28,15 @@ float *Terrain::generate_heights(int x, int y, int width, int height) { } } + chunk_indices.insert(std::pair<int, int>(x, y)); + return heights; } + +float *Terrain::get_chunk(int x, int y, int width, int height) { + return generate_heights(x, y, width, height); +} + +bool Terrain::has_chunk(int x, int y) { + return chunk_indices.find(std::pair<int, int>(x, y)) != chunk_indices.end(); +} |