Fix heightmap issues with trees.

This commit is contained in:
Duane 2016-06-23 22:35:48 -05:00
parent 3e3e0c17d6
commit 9325a474b5
2 changed files with 25 additions and 4 deletions

View file

@ -7,12 +7,25 @@ fun_caves.cave_noise_2 = {offset = 0, scale = 1, seed = -8402, spread = {x = 40,
local cave_noise_3 = {offset = 15, scale = 10, seed = 3721, spread = {x = 40, y = 40, z = 40}, octaves = 3, persist = 1, lacunarity = 2}
local ground_nodes = {}
ground_nodes[minetest.get_content_id('default:stone')] = true
ground_nodes[minetest.get_content_id('default:desert_stone')] = true
ground_nodes[minetest.get_content_id('default:sandstone')] = true
ground_nodes[minetest.get_content_id('default:dirt')] = true
ground_nodes[minetest.get_content_id('default:sand')] = true
ground_nodes[minetest.get_content_id('default:dirt_with_grass')] = true
ground_nodes[minetest.get_content_id('default:dirt_with_snow')] = true
ground_nodes[minetest.get_content_id('default:dirt_with_dry_grass')] = true
fun_caves.cavegen = function(minp, maxp, data, area, node, heightmap, underzone)
local csize = vector.add(vector.subtract(maxp, minp), 1)
local map_max = {x = csize.x, y = csize.y + 2, z = csize.z}
local map_min = {x = minp.x, y = minp.y - 1, z = minp.z}
local return_heightmap = false
if not heightmap then
return_heightmap = true
heightmap = {}
end
@ -39,7 +52,7 @@ fun_caves.cavegen = function(minp, maxp, data, area, node, heightmap, underzone)
height = - max_depth
local ivm2 = area:index(x, maxp.y + 8, z)
for y = maxp.y + 8, minp.y - 8, -1 do
if data[ivm2] ~= node['air'] and data[ivm2] ~= node['ignore'] then
if ground_nodes[data[ivm2]] then
height = (y < maxp.y + 8) and y or max_depth
break
end
@ -103,5 +116,9 @@ fun_caves.cavegen = function(minp, maxp, data, area, node, heightmap, underzone)
end
end
return write, heightmap
if return_heightmap then
return write, heightmap
else
return write, nil
end
end