mirror of
https://gitlab.com/gaelysam/mapgen_rivers.git
synced 2024-12-29 12:20:41 +01:00
Optionally center the map around x=0 z=0
This commit is contained in:
parent
53f88d337d
commit
d5cf4a6267
19
polygons.lua
19
polygons.lua
@ -59,6 +59,12 @@ end
|
||||
local blocksize = mapgen_rivers.blocksize
|
||||
local min_catchment = mapgen_rivers.min_catchment
|
||||
local max_catchment = mapgen_rivers.max_catchment
|
||||
local map_offset, map_offset_blocks
|
||||
local center = mapgen_rivers.center
|
||||
if center then
|
||||
map_offset = {x=math.floor(X/2), z=math.floor(Z/2)}
|
||||
map_offset_blocks = {x=map_offset.x/blocksize, z=map_offset.z/blocksize}
|
||||
end
|
||||
|
||||
-- Width coefficients: coefficients solving
|
||||
-- wfactor * min_catchment ^ wpower = 1/(2*blocksize)
|
||||
@ -89,6 +95,12 @@ local init = false
|
||||
-- On map generation, determine into which polygon every point (in 2D) will fall.
|
||||
-- Also store polygon-specific data
|
||||
local function make_polygons(minp, maxp)
|
||||
if center then
|
||||
minp = {x=minp.x+map_offset.x, z=minp.z+map_offset.z}
|
||||
maxp = {x=maxp.x+map_offset.x, z=maxp.z+map_offset.z}
|
||||
map_offset_x_blocks = map_offset.x / blocksize
|
||||
end
|
||||
|
||||
if not init then
|
||||
if glaciers then
|
||||
noise_heat = minetest.get_perlin(mapgen_rivers.noise_params.heat)
|
||||
@ -164,6 +176,13 @@ local function make_polygons(minp, maxp)
|
||||
polygon.dem = poly_dem
|
||||
polygon.lake = math.min(lakes[iA], lakes[iB], lakes[iC], lakes[iD])
|
||||
|
||||
if center then
|
||||
for i=1, 4 do
|
||||
poly_x[i] = poly_x[i] - map_offset_blocks.x
|
||||
poly_z[i] = poly_z[i] - map_offset_blocks.z
|
||||
end
|
||||
end
|
||||
|
||||
-- Now, rivers.
|
||||
-- Load river flux values for the 4 corners
|
||||
local riverA = river_width(rivers[iA])
|
||||
|
@ -45,6 +45,7 @@ local function get_settings(key, dtype, default)
|
||||
end
|
||||
end
|
||||
|
||||
mapgen_rivers.center = get_settings('center', 'bool', false)
|
||||
mapgen_rivers.blocksize = get_settings('blocksize', 'int', 12)
|
||||
mapgen_rivers.sea_level = get_settings('sea_level', 'int', 1)
|
||||
mapgen_rivers.min_catchment = get_settings('min_catchment', 'float', 25)
|
||||
|
@ -1,5 +1,8 @@
|
||||
# File containing all settings for 'mapgen_rivers' mod.
|
||||
|
||||
# Whether the map should be centered at x=0, z=0.
|
||||
mapgen_rivers_center (Center map) bool false
|
||||
|
||||
# Represents horizontal map scale. Every cell of the grid will be upscaled to
|
||||
# a square of this size.
|
||||
# For example if the grid size is 1000x1000 and block size is 12,
|
||||
|
Loading…
Reference in New Issue
Block a user