Faster mapgen: use voxelmanip for ungen check and scanning chunk below. Use sidelen not 80
This commit is contained in:
parent
0a51271786
commit
c0802ab89b
@ -1,4 +1,4 @@
|
|||||||
watershed 0.4.1 by paramat
|
watershed 0.4.3 by paramat
|
||||||
For latest stable Minetest back to 0.4.8
|
For latest stable Minetest back to 0.4.8
|
||||||
Depends default bucket
|
Depends default bucket
|
||||||
Licenses: code WTFPL, textures CC BY-SA
|
Licenses: code WTFPL, textures CC BY-SA
|
||||||
|
@ -1,2 +1,3 @@
|
|||||||
default
|
default
|
||||||
bucket
|
bucket
|
||||||
|
stairs
|
||||||
|
55
init.lua
55
init.lua
@ -1,11 +1,12 @@
|
|||||||
-- watershed 0.4.2 by paramat
|
-- watershed 0.4.3 by paramat
|
||||||
-- For latest stable Minetest and back to 0.4.8
|
-- For latest stable Minetest and back to 0.4.8
|
||||||
-- Depends default bucket
|
-- Depends default bucket
|
||||||
-- License: code WTFPL, textures CC BY-SA
|
-- License: code WTFPL, textures CC BY-SA
|
||||||
-- watershed:redcobble texture CC BY-SA by brunob.santos
|
-- watershed:redcobble texture CC BY-SA by brunob.santos
|
||||||
-- watershed:pineling texture CC BY-SA by Splizard
|
-- watershed:pineling texture CC BY-SA by Splizard
|
||||||
|
|
||||||
-- acaciawood, pinewood stairs and slabs
|
-- use LVM for 'ungen' check, scanning chunk below, faster mapgen
|
||||||
|
-- 80 becomes sidelen, works with any chunk size
|
||||||
|
|
||||||
-- Parameters
|
-- Parameters
|
||||||
|
|
||||||
@ -199,6 +200,7 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||||||
local data = vm:get_data() -- get flat array of voxelarea content ids
|
local data = vm:get_data() -- get flat array of voxelarea content ids
|
||||||
-- content ids
|
-- content ids
|
||||||
local c_air = minetest.get_content_id("air")
|
local c_air = minetest.get_content_id("air")
|
||||||
|
local c_ignore = minetest.get_content_id("ignore")
|
||||||
local c_water = minetest.get_content_id("default:water_source")
|
local c_water = minetest.get_content_id("default:water_source")
|
||||||
local c_sand = minetest.get_content_id("default:sand")
|
local c_sand = minetest.get_content_id("default:sand")
|
||||||
local c_desand = minetest.get_content_id("default:desert_sand")
|
local c_desand = minetest.get_content_id("default:desert_sand")
|
||||||
@ -242,7 +244,7 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||||||
-- perlinmap stuff
|
-- perlinmap stuff
|
||||||
local sidelen = x1 - x0 + 1 -- chunk sidelength
|
local sidelen = x1 - x0 + 1 -- chunk sidelength
|
||||||
local chulens = {x=sidelen, y=sidelen+2, z=sidelen} -- chunk dimensions, '+2' for overgeneration
|
local chulens = {x=sidelen, y=sidelen+2, z=sidelen} -- chunk dimensions, '+2' for overgeneration
|
||||||
local minposxyz = {x=x0, y=y0-1, z=z0} -- 3D and 2D perlinmaps start from these co-ordinates, '-1' for overgeneration
|
local minposxyz = {x=x0, y=y0-1, z=z0}
|
||||||
local minposxz = {x=x0, y=z0}
|
local minposxz = {x=x0, y=z0}
|
||||||
-- 3D and 2D perlinmaps
|
-- 3D and 2D perlinmaps
|
||||||
local nvals_terrain = minetest.get_perlin_map(np_terrain, chulens):get3dMap_flat(minposxyz)
|
local nvals_terrain = minetest.get_perlin_map(np_terrain, chulens):get3dMap_flat(minposxyz)
|
||||||
@ -257,10 +259,9 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||||||
local nvals_xlscale = minetest.get_perlin_map(np_xlscale, chulens):get2dMap_flat(minposxz)
|
local nvals_xlscale = minetest.get_perlin_map(np_xlscale, chulens):get2dMap_flat(minposxz)
|
||||||
local nvals_magma = minetest.get_perlin_map(np_magma, chulens):get2dMap_flat(minposxz)
|
local nvals_magma = minetest.get_perlin_map(np_magma, chulens):get2dMap_flat(minposxz)
|
||||||
|
|
||||||
local ungen = false -- ungenerated chunk below?
|
local viu = area:index(x0, y0-1, z0) -- ungenerated chunk below?
|
||||||
if minetest.get_node({x=x0, y=y0-1, z=z0}).name == "ignore" then
|
local ungen = data[viu] == c_ignore
|
||||||
ungen = true
|
|
||||||
end
|
|
||||||
-- mapgen loop
|
-- mapgen loop
|
||||||
local nixyz = 1 -- 3D and 2D perlinmap indexes
|
local nixyz = 1 -- 3D and 2D perlinmap indexes
|
||||||
local nixz = 1
|
local nixz = 1
|
||||||
@ -345,24 +346,24 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||||||
stable[si] = 0
|
stable[si] = 0
|
||||||
end
|
end
|
||||||
else -- scan top layer of chunk below
|
else -- scan top layer of chunk below
|
||||||
local nodename = minetest.get_node({x=x,y=y,z=z}).name
|
local nodid = data[vi]
|
||||||
if nodename == "watershed:stone"
|
if nodid == c_wsstone
|
||||||
or nodename == "watershed:redstone"
|
or nodid == c_wsredstone
|
||||||
or nodename == "watershed:dirt"
|
or nodid == c_wsdirt
|
||||||
or nodename == "watershed:permafrost"
|
or nodid == c_wspermafrost
|
||||||
or nodename == "watershed:luxoreoff"
|
or nodid == c_wsluxore
|
||||||
or nodename == "default:sand"
|
or nodid == c_sand
|
||||||
or nodename == "default:desert_sand"
|
or nodid == c_desand
|
||||||
or nodename == "default:mese"
|
or nodid == c_mese
|
||||||
or nodename == "default:stone_with_diamond"
|
or nodid == c_stodiam
|
||||||
or nodename == "default:stone_with_gold"
|
or nodid == c_stogold
|
||||||
or nodename == "default:stone_with_copper"
|
or nodid == c_stocopp
|
||||||
or nodename == "default:stone_with_iron"
|
or nodid == c_stoiron
|
||||||
or nodename == "default:stone_with_coal"
|
or nodid == c_stocoal
|
||||||
or nodename == "default:sandstone"
|
or nodid == c_sandstone
|
||||||
or nodename == "default:gravel"
|
or nodid == c_gravel
|
||||||
or nodename == "default:clay"
|
or nodid == c_clay
|
||||||
or nodename == "default:obsidian" then
|
or nodid == c_obsidian then
|
||||||
stable[si] = 2
|
stable[si] = 2
|
||||||
else
|
else
|
||||||
stable[si] = 0
|
stable[si] = 0
|
||||||
@ -638,9 +639,9 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||||||
vi = vi + 1
|
vi = vi + 1
|
||||||
viu = viu + 1
|
viu = viu + 1
|
||||||
end
|
end
|
||||||
nixz = nixz - 80
|
nixz = nixz - sidelen
|
||||||
end
|
end
|
||||||
nixz = nixz + 80
|
nixz = nixz + sidelen
|
||||||
end
|
end
|
||||||
-- voxelmanip stuff
|
-- voxelmanip stuff
|
||||||
vm:set_data(data)
|
vm:set_data(data)
|
||||||
|
Loading…
Reference in New Issue
Block a user