mirror of
https://gitlab.com/gaelysam/mapgen_rivers.git
synced 2024-12-28 20:00:41 +01:00
terrainlib_lua: replaced space indents by tabs
This commit is contained in:
parent
417ce1bcbc
commit
68c19c3b94
@ -71,50 +71,50 @@ local function erode(model, time)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function diffuse(model, time)
|
local function diffuse(model, time)
|
||||||
local mmax = math.max
|
local mmax = math.max
|
||||||
local dem = model.dem
|
local dem = model.dem
|
||||||
local X, Y = dem.X, dem.Y
|
local X, Y = dem.X, dem.Y
|
||||||
local d = model.params.d
|
local d = model.params.d
|
||||||
local dmax = d
|
local dmax = d
|
||||||
if type(d) == "table" then
|
if type(d) == "table" then
|
||||||
dmax = -math.huge
|
dmax = -math.huge
|
||||||
for i=1, X*Y do
|
for i=1, X*Y do
|
||||||
dmax = mmax(dmax, d[i])
|
dmax = mmax(dmax, d[i])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local diff = dmax * time
|
local diff = dmax * time
|
||||||
local niter = math.floor(diff) + 1
|
local niter = math.floor(diff) + 1
|
||||||
local ddiff = diff / niter
|
local ddiff = diff / niter
|
||||||
|
|
||||||
local temp = {}
|
local temp = {}
|
||||||
for n=1, niter do
|
for n=1, niter do
|
||||||
local i = 1
|
local i = 1
|
||||||
for y=1, Y do
|
for y=1, Y do
|
||||||
local iN = (y==1) and 0 or -X
|
local iN = (y==1) and 0 or -X
|
||||||
local iS = (y==Y) and 0 or X
|
local iS = (y==Y) and 0 or X
|
||||||
for x=1, X do
|
for x=1, X do
|
||||||
local iW = (x==1) and 0 or -1
|
local iW = (x==1) and 0 or -1
|
||||||
local iE = (x==X) and 0 or 1
|
local iE = (x==X) and 0 or 1
|
||||||
temp[i] = (dem[i+iN]+dem[i+iE]+dem[i+iS]+dem[i+iW])*0.25 - dem[i]
|
temp[i] = (dem[i+iN]+dem[i+iE]+dem[i+iS]+dem[i+iW])*0.25 - dem[i]
|
||||||
i = i + 1
|
i = i + 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
for i=1, X*Y do
|
for i=1, X*Y do
|
||||||
dem[i] = dem[i] + temp[i]*ddiff
|
dem[i] = dem[i] + temp[i]*ddiff
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
-- TODO Test this
|
-- TODO Test this
|
||||||
end
|
end
|
||||||
|
|
||||||
local modpath = ""
|
local modpath = ""
|
||||||
if minetest then
|
if minetest then
|
||||||
if minetest.global_exists('mapgen_rivers') then
|
if minetest.global_exists('mapgen_rivers') then
|
||||||
modpath = mapgen_rivers.modpath .. "terrainlib_lua/"
|
modpath = mapgen_rivers.modpath .. "terrainlib_lua/"
|
||||||
else
|
else
|
||||||
modpath = minetest.get_modpath(minetest.get_current_modname()) .. "terrainlib_lua/"
|
modpath = minetest.get_modpath(minetest.get_current_modname()) .. "terrainlib_lua/"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local rivermapper = dofile(modpath .. "rivermapper.lua")
|
local rivermapper = dofile(modpath .. "rivermapper.lua")
|
||||||
@ -152,20 +152,20 @@ local function noise(model, time)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function define_isostasy(model, ref, link)
|
local function define_isostasy(model, ref, link)
|
||||||
ref = ref or model.dem
|
ref = ref or model.dem
|
||||||
if link then
|
if link then
|
||||||
model.isostasy_ref = ref
|
model.isostasy_ref = ref
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local X, Y = ref.X, ref.Y
|
local X, Y = ref.X, ref.Y
|
||||||
local ref2 = model.isostasy_ref or {X=X, Y=Y}
|
local ref2 = model.isostasy_ref or {X=X, Y=Y}
|
||||||
model.isostasy_ref = ref2
|
model.isostasy_ref = ref2
|
||||||
for i=1, X*Y do
|
for i=1, X*Y do
|
||||||
ref2[i] = ref[i]
|
ref2[i] = ref[i]
|
||||||
end
|
end
|
||||||
|
|
||||||
return ref2
|
return ref2
|
||||||
end
|
end
|
||||||
|
|
||||||
local function isostasy(model)
|
local function isostasy(model)
|
||||||
|
Loading…
Reference in New Issue
Block a user