diff options
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(); +} |