mirror of
https://gitlab.com/gaelysam/mapgen_rivers.git
synced 2025-04-17 01:50:36 +02:00
Optionally disable distorsion
by setting 'mapgen_rivers_distort = false' in minetest.conf
This commit is contained in:
parent
25c5cb2e1f
commit
103cd49d78
40
init.lua
40
init.lua
@ -8,6 +8,7 @@ local blocksize = mapgen_rivers.blocksize
|
|||||||
local sea_level = mapgen_rivers.sea_level
|
local sea_level = mapgen_rivers.sea_level
|
||||||
local riverbed_slope = mapgen_rivers.riverbed_slope
|
local riverbed_slope = mapgen_rivers.riverbed_slope
|
||||||
local elevation_chill = mapgen_rivers.elevation_chill
|
local elevation_chill = mapgen_rivers.elevation_chill
|
||||||
|
local use_distort = mapgen_rivers.distort
|
||||||
|
|
||||||
dofile(modpath .. 'noises.lua')
|
dofile(modpath .. 'noises.lua')
|
||||||
|
|
||||||
@ -48,21 +49,28 @@ local function generate(minp, maxp, seed)
|
|||||||
y = chulens.y+1,
|
y = chulens.y+1,
|
||||||
z = chulens.z,
|
z = chulens.z,
|
||||||
}
|
}
|
||||||
|
if use_distort then
|
||||||
noise_x_obj = minetest.get_perlin_map(mapgen_rivers.noise_params.distort_x, mapsize)
|
noise_x_obj = minetest.get_perlin_map(mapgen_rivers.noise_params.distort_x, mapsize)
|
||||||
noise_z_obj = minetest.get_perlin_map(mapgen_rivers.noise_params.distort_z, mapsize)
|
noise_z_obj = minetest.get_perlin_map(mapgen_rivers.noise_params.distort_z, mapsize)
|
||||||
|
noise_distort_obj = minetest.get_perlin_map(mapgen_rivers.noise_params.distort_amplitude, chulens)
|
||||||
|
end
|
||||||
noise_heat_obj = minetest.get_perlin_map(mapgen_rivers.noise_params.heat, chulens)
|
noise_heat_obj = minetest.get_perlin_map(mapgen_rivers.noise_params.heat, chulens)
|
||||||
noise_heat_blend_obj = minetest.get_perlin_map(mapgen_rivers.noise_params.heat_blend, chulens)
|
noise_heat_blend_obj = minetest.get_perlin_map(mapgen_rivers.noise_params.heat_blend, chulens)
|
||||||
noise_distort_obj = minetest.get_perlin_map(mapgen_rivers.noise_params.distort_amplitude, chulens)
|
|
||||||
init = true
|
init = true
|
||||||
end
|
end
|
||||||
|
|
||||||
local minp2d = {x=minp.x, y=minp.z}
|
local minp2d = {x=minp.x, y=minp.z}
|
||||||
|
if use_distort then
|
||||||
noise_x_obj:get_3d_map_flat(minp, noise_x_map)
|
noise_x_obj:get_3d_map_flat(minp, noise_x_map)
|
||||||
noise_z_obj:get_3d_map_flat(minp, noise_z_map)
|
noise_z_obj:get_3d_map_flat(minp, noise_z_map)
|
||||||
noise_distort_obj:get_2d_map_flat(minp2d, noise_distort_map)
|
noise_distort_obj:get_2d_map_flat(minp2d, noise_distort_map)
|
||||||
|
end
|
||||||
noise_heat_obj:get_2d_map_flat(minp2d, noise_heat_map)
|
noise_heat_obj:get_2d_map_flat(minp2d, noise_heat_map)
|
||||||
noise_heat_blend_obj:get_2d_map_flat(minp2d, noise_heat_blend_map)
|
noise_heat_blend_obj:get_2d_map_flat(minp2d, noise_heat_blend_map)
|
||||||
|
|
||||||
|
local terrain_map, lake_map, incr, i_origin
|
||||||
|
|
||||||
|
if use_distort then
|
||||||
local xmin, xmax, zmin, zmax = minp.x, maxp.x, minp.z, maxp.z
|
local xmin, xmax, zmin, zmax = minp.x, maxp.x, minp.z, maxp.z
|
||||||
local i = 0
|
local i = 0
|
||||||
local i2d = 0
|
local i2d = 0
|
||||||
@ -87,9 +95,12 @@ local function generate(minp, maxp, seed)
|
|||||||
|
|
||||||
local pminp = {x=math.floor(xmin), z=math.floor(zmin)}
|
local pminp = {x=math.floor(xmin), z=math.floor(zmin)}
|
||||||
local pmaxp = {x=math.floor(xmax)+1, z=math.floor(zmax)+1}
|
local pmaxp = {x=math.floor(xmax)+1, z=math.floor(zmax)+1}
|
||||||
local incr = pmaxp.x-pminp.x+1
|
incr = pmaxp.x-pminp.x+1
|
||||||
local i_origin = 1 - pminp.z*incr - pminp.x
|
i_origin = 1 - pminp.z*incr - pminp.x
|
||||||
local terrain_map, lake_map = heightmaps(pminp, pmaxp)
|
terrain_map, lake_map = heightmaps(pminp, pmaxp)
|
||||||
|
else
|
||||||
|
terrain_map, lake_map = heightmaps(minp, maxp)
|
||||||
|
end
|
||||||
|
|
||||||
local c_stone = minetest.get_content_id("default:stone")
|
local c_stone = minetest.get_content_id("default:stone")
|
||||||
local c_dirt = minetest.get_content_id("default:dirt")
|
local c_dirt = minetest.get_content_id("default:dirt")
|
||||||
@ -119,7 +130,14 @@ local function generate(minp, maxp, seed)
|
|||||||
local ivm = a:index(x, minp.y, z)
|
local ivm = a:index(x, minp.y, z)
|
||||||
local ground_above = false
|
local ground_above = false
|
||||||
local temperature = noise_heat_map[i2d]+noise_heat_blend_map[i2d]
|
local temperature = noise_heat_map[i2d]+noise_heat_blend_map[i2d]
|
||||||
|
local terrain, lake
|
||||||
|
if not use_distort then
|
||||||
|
terrain = terrain_map[i2d]
|
||||||
|
lake = lake_map[i2d]
|
||||||
|
end
|
||||||
|
|
||||||
for y = maxp.y+1, minp.y, -1 do
|
for y = maxp.y+1, minp.y, -1 do
|
||||||
|
if use_distort then
|
||||||
local xn = noise_x_map[nid]
|
local xn = noise_x_map[nid]
|
||||||
local zn = noise_z_map[nid]
|
local zn = noise_z_map[nid]
|
||||||
local x0 = math.floor(xn)
|
local x0 = math.floor(xn)
|
||||||
@ -130,9 +148,11 @@ local function generate(minp, maxp, seed)
|
|||||||
local i2 = i1+incr
|
local i2 = i1+incr
|
||||||
local i3 = i2-1
|
local i3 = i2-1
|
||||||
|
|
||||||
local terrain = interp(terrain_map[i0], terrain_map[i1], terrain_map[i2], terrain_map[i3], xn-x0, zn-z0)
|
terrain = interp(terrain_map[i0], terrain_map[i1], terrain_map[i2], terrain_map[i3], xn-x0, zn-z0)
|
||||||
|
lake = math.min(lake_map[i0], lake_map[i1], lake_map[i2], lake_map[i3])
|
||||||
|
end
|
||||||
|
|
||||||
if y <= maxp.y then
|
if y <= maxp.y then
|
||||||
local lake = math.min(lake_map[i0], lake_map[i1], lake_map[i2], lake_map[i3])
|
|
||||||
|
|
||||||
local is_lake = lake > terrain
|
local is_lake = lake > terrain
|
||||||
local ivm = a:index(x, y, z)
|
local ivm = a:index(x, y, z)
|
||||||
@ -166,13 +186,21 @@ local function generate(minp, maxp, seed)
|
|||||||
ground_above = y <= terrain
|
ground_above = y <= terrain
|
||||||
|
|
||||||
ivm = ivm + ystride
|
ivm = ivm + ystride
|
||||||
|
if use_distort then
|
||||||
nid = nid + incrY
|
nid = nid + incrY
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if use_distort then
|
||||||
nid = nid + incrX
|
nid = nid + incrX
|
||||||
|
end
|
||||||
i2d = i2d + 1
|
i2d = i2d + 1
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if use_distort then
|
||||||
nid = nid + incrZ
|
nid = nid + incrZ
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
vm:set_data(data)
|
vm:set_data(data)
|
||||||
minetest.generate_ores(vm, minp, maxp)
|
minetest.generate_ores(vm, minp, maxp)
|
||||||
|
@ -47,7 +47,7 @@ mapgen_rivers.sea_level = get_settings('sea_level', 'int', 1)
|
|||||||
mapgen_rivers.min_catchment = get_settings('min_catchment', 'float', 25)
|
mapgen_rivers.min_catchment = get_settings('min_catchment', 'float', 25)
|
||||||
mapgen_rivers.max_catchment = get_settings('max_catchment', 'float', 40000)
|
mapgen_rivers.max_catchment = get_settings('max_catchment', 'float', 40000)
|
||||||
mapgen_rivers.riverbed_slope = get_settings('riverbed_slope', 'float', 0.4) * mapgen_rivers.blocksize
|
mapgen_rivers.riverbed_slope = get_settings('riverbed_slope', 'float', 0.4) * mapgen_rivers.blocksize
|
||||||
--mapgen_rivers.distort = get_settings('distort', 'bool', true) To be implemented: should be possible to disable distorsion
|
mapgen_rivers.distort = get_settings('distort', 'bool', true)
|
||||||
mapgen_rivers.glaciers = get_settings('glaciers', 'bool', true)
|
mapgen_rivers.glaciers = get_settings('glaciers', 'bool', true)
|
||||||
mapgen_rivers.glacier_factor = get_settings('glacier_factor', 'float', 8)
|
mapgen_rivers.glacier_factor = get_settings('glacier_factor', 'float', 8)
|
||||||
mapgen_rivers.elevation_chill = get_settings('elevation_chill', 'float', 0.25)
|
mapgen_rivers.elevation_chill = get_settings('elevation_chill', 'float', 0.25)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user