Fix boolean error. Faster code. Persist 0.5
This commit is contained in:
parent
98bba5468a
commit
0eb26c263a
@ -1,4 +1,4 @@
|
|||||||
intersection 0.1.0 by paramat
|
intersecting 0.1.1 by paramat
|
||||||
For latest stable Minetest back to 0.4.8
|
For latest stable Minetest back to 0.4.8
|
||||||
Depends default
|
Depends default
|
||||||
Licenses: code WTFPL
|
Licenses: code WTFPL
|
||||||
|
34
init.lua
34
init.lua
@ -1,16 +1,13 @@
|
|||||||
-- intersecting 0.1.0 by paramat
|
-- intersecting 0.1.1 by paramat
|
||||||
-- For latest stable Minetest and back to 0.4.8
|
-- For latest stable Minetest and back to 0.4.8
|
||||||
-- Depends default
|
-- Depends default
|
||||||
-- License: code WTFPL
|
-- License: code WTFPL
|
||||||
|
|
||||||
-- TODO
|
|
||||||
-- enables 1-3 fissures, isolated tunnels and intersecting tunnels, also isolated tunnel plus 1 fissure
|
|
||||||
|
|
||||||
-- Parameters
|
-- Parameters
|
||||||
|
|
||||||
local TFIS = 0.02
|
local TFIS = 0.02 -- fissure and tunnel width
|
||||||
|
|
||||||
-- 3D noise for
|
-- 3D noise for fissure a
|
||||||
|
|
||||||
local np_weba = {
|
local np_weba = {
|
||||||
offset = 0,
|
offset = 0,
|
||||||
@ -18,10 +15,10 @@ local np_weba = {
|
|||||||
spread = {x=192, y=192, z=192},
|
spread = {x=192, y=192, z=192},
|
||||||
seed = 5900033,
|
seed = 5900033,
|
||||||
octaves = 3,
|
octaves = 3,
|
||||||
persist = 0.6
|
persist = 0.5
|
||||||
}
|
}
|
||||||
|
|
||||||
-- 3D noise for
|
-- 3D noise for fissure b
|
||||||
|
|
||||||
local np_webb = {
|
local np_webb = {
|
||||||
offset = 0,
|
offset = 0,
|
||||||
@ -29,10 +26,10 @@ local np_webb = {
|
|||||||
spread = {x=191, y=191, z=191},
|
spread = {x=191, y=191, z=191},
|
||||||
seed = 33,
|
seed = 33,
|
||||||
octaves = 3,
|
octaves = 3,
|
||||||
persist = 0.6
|
persist = 0.5
|
||||||
}
|
}
|
||||||
|
|
||||||
-- 3D noise for
|
-- 3D noise for fissure c
|
||||||
|
|
||||||
local np_webc = {
|
local np_webc = {
|
||||||
offset = 0,
|
offset = 0,
|
||||||
@ -40,7 +37,7 @@ local np_webc = {
|
|||||||
spread = {x=190, y=190, z=190},
|
spread = {x=190, y=190, z=190},
|
||||||
seed = -18000001,
|
seed = -18000001,
|
||||||
octaves = 3,
|
octaves = 3,
|
||||||
persist = 0.6
|
persist = 0.5
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Stuff
|
-- Stuff
|
||||||
@ -69,11 +66,11 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||||||
local data = vm:get_data()
|
local data = vm:get_data()
|
||||||
|
|
||||||
local c_air = minetest.get_content_id("air")
|
local c_air = minetest.get_content_id("air")
|
||||||
|
local c_water = minetest.get_content_id("default:water_source")
|
||||||
|
|
||||||
local sidelen = x1 - x0 + 1
|
local sidelen = x1 - x0 + 1
|
||||||
local chulens = {x=sidelen, y=sidelen, z=sidelen}
|
local chulens = {x=sidelen, y=sidelen, z=sidelen}
|
||||||
local minposxyz = {x=x0, y=y0, z=z0}
|
local minposxyz = {x=x0, y=y0, z=z0}
|
||||||
local minposxz = {x=x0, y=z0}
|
|
||||||
|
|
||||||
local nvals_weba = minetest.get_perlin_map(np_weba, chulens):get3dMap_flat(minposxyz)
|
local nvals_weba = minetest.get_perlin_map(np_weba, chulens):get3dMap_flat(minposxyz)
|
||||||
local nvals_webb = minetest.get_perlin_map(np_webb, chulens):get3dMap_flat(minposxyz)
|
local nvals_webb = minetest.get_perlin_map(np_webb, chulens):get3dMap_flat(minposxyz)
|
||||||
@ -85,12 +82,13 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||||||
local vi = area:index(x0, y, z)
|
local vi = area:index(x0, y, z)
|
||||||
for x = x0, x1 do -- for each node do
|
for x = x0, x1 do -- for each node do
|
||||||
local nodid = data[vi]
|
local nodid = data[vi]
|
||||||
local weba = math.abs(nvals_weba[nixyz]) < TFIS
|
if nodid ~= c_water and nodid ~= c_air then
|
||||||
local webb = math.abs(nvals_webb[nixyz]) < TFIS
|
local weba = math.abs(nvals_weba[nixyz]) < TFIS
|
||||||
local webc = math.abs(nvals_webc[nixyz]) < TFIS
|
local webb = math.abs(nvals_webb[nixyz]) < TFIS
|
||||||
if (weba and webb) or (weba and webc)
|
local webc = math.abs(nvals_webc[nixyz]) < TFIS
|
||||||
and nodid ~= c_water then
|
if (weba and webb) or (weba and webc) then
|
||||||
data[vi] = c_air
|
data[vi] = c_air
|
||||||
|
end
|
||||||
end
|
end
|
||||||
nixyz = nixyz + 1
|
nixyz = nixyz + 1
|
||||||
vi = vi + 1
|
vi = vi + 1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user