Faster mapgen: use voxelmanip for ungen check, scanning chunk below

This commit is contained in:
Mat 2014-07-28 01:06:32 +01:00
parent 648ab529d4
commit e81927ece8
4 changed files with 37 additions and 33 deletions

View File

@ -1,4 +1,4 @@
fracture 0.1.6 by paramat fracture 0.1.7 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

View File

@ -130,12 +130,12 @@ if SINGLENODE then
minetest.set_mapgen_params({mgname="singlenode", water_level=-32000}) minetest.set_mapgen_params({mgname="singlenode", water_level=-32000})
end) end)
-- Spawn player -- Spawn player. Dependant on chunk size = 5 mapblocks
function spawnplayer(player) function spawnplayer(player)
local DENOFF = -0.4 local DENOFF = -0.4
local TSTONE = 0.02 local TSTONE = 0.02
local SCAT = 8 -- Player scatter from world centre in chunks (80 nodes). local PSCA = 8 -- Player scatter from world centre in chunks (80 nodes).
local xsp local xsp
local ysp local ysp
local zsp local zsp
@ -157,9 +157,9 @@ if SINGLENODE then
} }
for chunk = 1, 64 do for chunk = 1, 64 do
print ("[fracture] searching for spawn "..chunk) print ("[fracture] searching for spawn "..chunk)
local x0 = 80 * math.random(-SCAT, SCAT) - 32 local x0 = 80 * math.random(-PSCA, PSCA) - 32
local z0 = 80 * math.random(-SCAT, SCAT) - 32 local z0 = 80 * math.random(-PSCA, PSCA) - 32
local y0 = 80 * math.random(-SCAT, SCAT) - 32 local y0 = 80 * math.random(-PSCA, PSCA) - 32
local x1 = x0 + 79 local x1 = x0 + 79
local z1 = z0 + 79 local z1 = z0 + 79
local y1 = y0 + 79 local y1 = y0 + 79

View File

@ -1,8 +1,10 @@
-- fracture 0.1.6 by paramat -- fracture 0.1.7 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
-- use LVM for 'ungen' check, scanning chunk below
-- Parameters -- Parameters
local YMIN = -33000 -- Set to -33000 when using singlenode option local YMIN = -33000 -- Set to -33000 when using singlenode option
@ -122,7 +124,8 @@ minetest.register_on_generated(function(minp, maxp, seed)
local c_grass5 = minetest.get_content_id("default:grass_5") local c_grass5 = minetest.get_content_id("default:grass_5")
local c_dryshrub = minetest.get_content_id("default:dry_shrub") local c_dryshrub = minetest.get_content_id("default:dry_shrub")
local sidelen = x1 - x0 + 1 local sidelen = x1 - x0 + 1 -- mapchunk side length
local facearea = sidelen ^ 2 -- mapchunk face area
local chulens = {x=sidelen, y=sidelen+2, z=sidelen} local chulens = {x=sidelen, y=sidelen+2, z=sidelen}
local minposxyz = {x=x0, y=y0-1, z=z0} local minposxyz = {x=x0, y=y0-1, z=z0}
@ -132,10 +135,8 @@ minetest.register_on_generated(function(minp, maxp, seed)
local nvals_biome = minetest.get_perlin_map(np_biome, chulens):get3dMap_flat(minposxyz) local nvals_biome = minetest.get_perlin_map(np_biome, chulens):get3dMap_flat(minposxyz)
local nvals_cloud = minetest.get_perlin_map(np_cloud, chulens):get3dMap_flat(minposxyz) local nvals_cloud = minetest.get_perlin_map(np_cloud, chulens):get3dMap_flat(minposxyz)
local ungen = false 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
local nixyz = 1 local nixyz = 1
local stable = {} local stable = {}
@ -178,20 +179,20 @@ minetest.register_on_generated(function(minp, maxp, seed)
stable[si] = 0 stable[si] = 0
end end
else else
local nodename = minetest.get_node({x=x,y=y,z=z}).name local nodid = data[vi]
if nodename == "fracture:stone" if nodid == c_stone
or nodename == "fracture:desertstone" or nodid == c_destone
or nodename == "fracture:dirt" or nodid == c_dirt
or nodename == "fracture:grass" or nodid == c_grass
or nodename == "fracture:dirtsnow" or nodid == c_dirtsnow
or nodename == "default:snowblock" or nodid == c_snowblock
or nodename == "default:desert_sand" or nodid == c_desand
or nodename == "default:stone_with_diamond" or nodid == c_stodiam
or nodename == "default:stone_with_mese" or nodid == c_stomese
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" then or nodid == c_stocoal then
stable[si] = 2 stable[si] = 2
else else
stable[si] = 0 stable[si] = 0
@ -270,8 +271,7 @@ minetest.register_on_generated(function(minp, maxp, seed)
local xrq = 16 * math.floor((x - x0) / 16) local xrq = 16 * math.floor((x - x0) / 16)
local zrq = 16 * math.floor((z - z0) / 16) local zrq = 16 * math.floor((z - z0) / 16)
local yrq = 40 local yrq = 40
--local yrq = 79 local qixyz = zrq * facearea + yrq * sidelen + xrq + 1
local qixyz = zrq * 6400 + yrq * 80 + xrq + 1
if math.abs(nvals_cloud[qixyz]) < 0.05 then if math.abs(nvals_cloud[qixyz]) < 0.05 then
data[vi] = c_cloud data[vi] = c_cloud
end end

View File

@ -1,6 +1,7 @@
minetest.register_node("fracture:stone", { minetest.register_node("fracture:stone", {
description = "FR Stone", description = "FR Stone",
tiles = {"default_stone.png"}, tiles = {"default_stone.png"},
is_ground_content = false,
groups = {cracky=3}, groups = {cracky=3},
drop = "default:cobble", drop = "default:cobble",
sounds = default.node_sound_stone_defaults(), sounds = default.node_sound_stone_defaults(),
@ -9,6 +10,7 @@ minetest.register_node("fracture:stone", {
minetest.register_node("fracture:desertstone", { minetest.register_node("fracture:desertstone", {
description = "FR Desert Stone", description = "FR Desert Stone",
tiles = {"default_desert_stone.png"}, tiles = {"default_desert_stone.png"},
is_ground_content = false,
groups = {cracky=3}, groups = {cracky=3},
drop = "default:desert_stone", drop = "default:desert_stone",
sounds = default.node_sound_stone_defaults(), sounds = default.node_sound_stone_defaults(),
@ -31,7 +33,7 @@ minetest.register_node("fracture:dirt", {
minetest.register_node("fracture:dirtsnow", { minetest.register_node("fracture:dirtsnow", {
description = "Dirt with Snow", description = "Dirt with Snow",
tiles = {"default_snow.png", "default_dirt.png", "default_snow.png"}, tiles = {"default_snow.png", "default_dirt.png", "default_snow.png"},
is_ground_content = true, is_ground_content = false,
groups = {crumbly=3,soil=1}, groups = {crumbly=3,soil=1},
drop = "default:dirt", drop = "default:dirt",
sounds = default.node_sound_dirt_defaults({ sounds = default.node_sound_dirt_defaults({
@ -87,6 +89,7 @@ minetest.register_node("fracture:appling", {
wield_image = "default_sapling.png", wield_image = "default_sapling.png",
paramtype = "light", paramtype = "light",
walkable = false, walkable = false,
is_ground_content = false,
selection_box = { selection_box = {
type = "fixed", type = "fixed",
fixed = {-0.3, -0.5, -0.3, 0.3, 0.35, 0.3} fixed = {-0.3, -0.5, -0.3, 0.3, 0.35, 0.3}
@ -114,6 +117,7 @@ minetest.register_node("fracture:pineling", {
wield_image = "fracture_pineling.png", wield_image = "fracture_pineling.png",
paramtype = "light", paramtype = "light",
walkable = false, walkable = false,
is_ground_content = false,
selection_box = { selection_box = {
type = "fixed", type = "fixed",
fixed = {-0.3, -0.5, -0.3, 0.3, 0.35, 0.3} fixed = {-0.3, -0.5, -0.3, 0.3, 0.35, 0.3}