Noise object optimisation. Fix code style issues. Add info to readme
parent
1af8b2cfd1
commit
f3c5a4d918
|
@ -1,4 +1,9 @@
|
|||
subterrain 0.1.1 by paramat
|
||||
For Minetest 0.4.8 stable
|
||||
subterrain 0.2.0 by paramat
|
||||
For Minetest 0.4.12 and later
|
||||
Depends default
|
||||
Licenses: code WTFPL
|
||||
|
||||
A fast, very simple mod to develop and replace the big caves of the now removed 'indev' mapgen.
|
||||
By default massive caverns start to appear below y = -256.
|
||||
Realm limits, blend distance and cave size / underground volume ratio are parameters for you to adjust.
|
||||
By default caves are roughly 1/3rd of underground volume, and can be separated by up to roughly 800 nodes.
|
||||
|
|
32
init.lua
32
init.lua
|
@ -1,13 +1,9 @@
|
|||
-- subterrain 0.1.1 by paramat
|
||||
-- For Minetest 0.4.8 stable
|
||||
-- Depends default
|
||||
-- License: code WTFPL
|
||||
|
||||
-- Parameters
|
||||
|
||||
local YMIN = -33000 -- Cave realm limits
|
||||
local YMAX = -256
|
||||
local TCAVE = 0.6 -- Cave threshold. 1 = small rare caves, 0.5 = 1/3rd ground volume, 0 = 1/2 ground volume
|
||||
local TCAVE = 0.6 -- Cave threshold: 1 = small rare caves,
|
||||
-- 0.5 = 1/3rd ground volume, 0 = 1/2 ground volume.
|
||||
local BLEND = 128 -- Cave blend distance near YMIN, YMAX
|
||||
|
||||
-- 3D noise for caves
|
||||
|
@ -15,7 +11,7 @@ local BLEND = 128 -- Cave blend distance near YMIN, YMAX
|
|||
local np_cave = {
|
||||
offset = 0,
|
||||
scale = 1,
|
||||
spread = {x=768, y=256, z=768}, -- squashed 3:1
|
||||
spread = {x = 768, y = 256, z = 768}, -- squashed 3:1
|
||||
seed = 59033,
|
||||
octaves = 6,
|
||||
persist = 0.63
|
||||
|
@ -23,11 +19,13 @@ local np_cave = {
|
|||
|
||||
-- Stuff
|
||||
|
||||
subterrain = {}
|
||||
|
||||
local yblmin = YMIN + BLEND * 1.5
|
||||
local yblmax = YMAX - BLEND * 1.5
|
||||
|
||||
-- Initialize noise objects to nil
|
||||
|
||||
local nobj_cave = nil
|
||||
|
||||
-- On generated function
|
||||
|
||||
minetest.register_on_generated(function(minp, maxp, seed)
|
||||
|
@ -43,20 +41,20 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||
local y0 = minp.y
|
||||
local z0 = minp.z
|
||||
|
||||
print ("[subterrain] chunk minp ("..x0.." "..y0.." "..z0..")")
|
||||
|
||||
local vm, emin, emax = minetest.get_mapgen_object("voxelmanip")
|
||||
local area = VoxelArea:new{MinEdge=emin, MaxEdge=emax}
|
||||
local area = VoxelArea:new{MinEdge = emin, MaxEdge = emax}
|
||||
local data = vm:get_data()
|
||||
|
||||
local c_air = minetest.get_content_id("air")
|
||||
|
||||
local sidelen = x1 - x0 + 1
|
||||
local chulens = {x=sidelen, y=sidelen, z=sidelen}
|
||||
local minposxyz = {x=x0, y=y0, z=z0}
|
||||
local chulens = {x = sidelen, y = sidelen, z = sidelen}
|
||||
local minposxyz = {x = x0, y = y0, z = z0}
|
||||
|
||||
local nvals_cave = minetest.get_perlin_map(np_cave, chulens):get3dMap_flat(minposxyz)
|
||||
nobj_cave = nobj_cave or minetest.get_perlin_map(np_cave, chulens)
|
||||
|
||||
local nvals_cave = nobj_cave:get3dMap_flat(minposxyz)
|
||||
|
||||
local nixyz = 1
|
||||
for z = z0, z1 do -- for each xy plane progressing northwards
|
||||
for y = y0, y1 do -- for each x row progressing upwards
|
||||
|
@ -80,10 +78,10 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||
end
|
||||
|
||||
vm:set_data(data)
|
||||
vm:set_lighting({day=0, night=0})
|
||||
vm:set_lighting({day = 0, night = 0})
|
||||
vm:calc_lighting()
|
||||
vm:write_to_map(data)
|
||||
|
||||
local chugent = math.ceil((os.clock() - t1) * 1000)
|
||||
print ("[subterrain] "..chugent.." ms")
|
||||
print ("[subterrain] " .. chugent .. " ms")
|
||||
end)
|
||||
|
|
Loading…
Reference in New Issue