aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorparamat <mat.gregory@virginmedia.com>2015-03-23 19:36:00 +0000
committerparamat <mat.gregory@virginmedia.com>2015-03-23 21:55:01 +0000
commit37a62970252cb7128900bffb7a07872679738e43 (patch)
treec69c1984e6e109b94b78f6b9b84c34a22ce2567b /src
parent6cf7c89236d6b222f53ca9c8d681d6cde656bea1 (diff)
downloadminetest-37a62970252cb7128900bffb7a07872679738e43.tar.gz
minetest-37a62970252cb7128900bffb7a07872679738e43.tar.bz2
minetest-37a62970252cb7128900bffb7a07872679738e43.zip
Mgv6: Use heightmap in placeTreesAndJungleGrass()
Diffstat (limited to 'src')
-rw-r--r--src/mapgen_v6.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/mapgen_v6.cpp b/src/mapgen_v6.cpp
index 2ecf42a0f..8885c71e5 100644
--- a/src/mapgen_v6.cpp
+++ b/src/mapgen_v6.cpp
@@ -877,9 +877,10 @@ void MapgenV6::placeTreesAndJungleGrass()
for (u32 i = 0; i < grass_count; i++) {
s16 x = grassrandom.range(p2d_min.X, p2d_max.X);
s16 z = grassrandom.range(p2d_min.Y, p2d_max.Y);
-
- s16 y = findGroundLevelFull(v2s16(x, z)); ////////////////optimize this!
- if (y < water_level || y < node_min.Y || y > node_max.Y)
+ int mapindex = central_area_size.X * (z - node_min.Z)
+ + (x - node_min.X);
+ s16 y = heightmap[mapindex];
+ if (y < water_level)
continue;
u32 vi = vm->m_area.index(x, y, z);
@@ -895,7 +896,9 @@ void MapgenV6::placeTreesAndJungleGrass()
for (u32 i = 0; i < tree_count; i++) {
s16 x = myrand_range(p2d_min.X, p2d_max.X);
s16 z = myrand_range(p2d_min.Y, p2d_max.Y);
- s16 y = findGroundLevelFull(v2s16(x, z)); ////////////////////optimize this!
+ int mapindex = central_area_size.X * (z - node_min.Z)
+ + (x - node_min.X);
+ s16 y = heightmap[mapindex];
// Don't make a tree under water level
// Don't make a tree so high that it doesn't fit
if(y < water_level || y > node_max.Y - 6)