mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2025-04-16 04:35:15 +02:00
more timing logging for mapgen
This commit is contained in:
parent
088095adf3
commit
c95a29742c
2 changed files with 19 additions and 26 deletions
|
@ -7,19 +7,6 @@ local logging = minetest.settings:get_bool("mcl_logging_mapgen", false)
|
|||
local log_timing = minetest.settings:get_bool("mcl_logging_mapgen_timing", false) -- detailed, for performance debugging
|
||||
local seed = minetest.get_mapgen_setting("seed")
|
||||
|
||||
local function run_generators(minp, maxp, blockseed)
|
||||
if nodes == 0 then return end
|
||||
for _, rec in ipairs(registered_generators) do
|
||||
if rec.nf then
|
||||
local gt1 = os.clock()
|
||||
rec.nf(vector.copy(minp), vector.copy(maxp), blockseed) -- defensive copies against some generator changing the vectors
|
||||
if log_timing then
|
||||
minetest.log("action", string.format("[mcl_mapgen_core] %-20s %s ... %s %8.2fms", rec.id, minetest.pos_to_string(minp), minetest.pos_to_string(maxp), (os.clock() - gt1)*1000))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
minetest.register_on_generated(function(minp, maxp, blockseed)
|
||||
local t1 = os.clock()
|
||||
if lvm > 0 then
|
||||
|
@ -32,12 +19,12 @@ minetest.register_on_generated(function(minp, maxp, blockseed)
|
|||
end
|
||||
|
||||
local lvm_used, shadow, deco_used, deco_table, ore_used, ore_table = false, false, false, false, false, false
|
||||
for _, rec in ipairs(registered_generators) do
|
||||
if rec.vf then
|
||||
for _, gen in ipairs(registered_generators) do
|
||||
if gen.vf then
|
||||
local gt1 = os.clock()
|
||||
local p1, p2 = vector.copy(minp), vector.copy(maxp) -- defensive copies against some generator changing the vectors
|
||||
local e1, e2 = vector.copy(emin), vector.copy(emax) -- defensive copies against some generator changing the vectors
|
||||
local lvm_used0, shadow0, deco, ore = rec.vf(vm, data, data2, e1, e2, area, p1, p2, blockseed)
|
||||
local lvm_used0, shadow0, deco, ore = gen.vf(vm, data, data2, e1, e2, area, p1, p2, blockseed)
|
||||
lvm_used = lvm_used or lvm_used0
|
||||
shadow = shadow or shadow0
|
||||
if deco and type(deco) == "table" then
|
||||
|
@ -51,7 +38,7 @@ minetest.register_on_generated(function(minp, maxp, blockseed)
|
|||
ore_used = true
|
||||
end
|
||||
if log_timing then
|
||||
minetest.log("action", string.format("[mcl_mapgen_core] %-20s %s ... %s %8.2fms", rec.id, minetest.pos_to_string(minp), minetest.pos_to_string(maxp), (os.clock() - gt1)*1000))
|
||||
minetest.log("action", string.format("[mcl_mapgen_core] %-20s %s ... %s %8.2fms", gen.id, minetest.pos_to_string(minp), minetest.pos_to_string(maxp), (os.clock() - gt1)*1000))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -64,7 +51,7 @@ minetest.register_on_generated(function(minp, maxp, blockseed)
|
|||
minetest.log("action", string.format("[mcl_mapgen_core] %-20s %s ... %s %8.2fms", "set_data", minetest.pos_to_string(minp), minetest.pos_to_string(maxp), (os.clock() - gt1)*1000))
|
||||
end
|
||||
local gt2 = os.clock()
|
||||
if deco_table then
|
||||
if deco_table and #deco_table > 0 then
|
||||
minetest.generate_decorations(vm,vector.new(minp.x,deco_table.min,minp.z),vector.new(maxp.x,deco_table.max,maxp.z))
|
||||
elseif deco_used then
|
||||
minetest.generate_decorations(vm)
|
||||
|
@ -73,7 +60,7 @@ minetest.register_on_generated(function(minp, maxp, blockseed)
|
|||
minetest.log("action", string.format("[mcl_mapgen_core] %-20s %s ... %s %8.2fms", "decorations", minetest.pos_to_string(minp), minetest.pos_to_string(maxp), (os.clock() - gt2)*1000))
|
||||
end
|
||||
local gt3 = os.clock()
|
||||
if ore_table then
|
||||
if ore_table and #ore_table > 0 then
|
||||
minetest.generate_ores(vm,vector.new(minp.x,ore_table.min,minp.z),vector.new(maxp.x,ore_table.max,maxp.z))
|
||||
elseif ore_used then
|
||||
minetest.generate_ores(vm)
|
||||
|
@ -91,7 +78,17 @@ minetest.register_on_generated(function(minp, maxp, blockseed)
|
|||
end
|
||||
end
|
||||
|
||||
run_generators(minp, maxp, blockseed)
|
||||
if nodes > 0 then
|
||||
for _, gen in ipairs(registered_generators) do
|
||||
if gen.nf then
|
||||
local gt1 = os.clock()
|
||||
gen.nf(vector.copy(minp), vector.copy(maxp), blockseed) -- defensive copies against some generator changing the vectors
|
||||
if log_timing then
|
||||
minetest.log("action", string.format("[mcl_mapgen_core] %-20s %s ... %s %8.2fms", gen.id, minetest.pos_to_string(minp), minetest.pos_to_string(maxp), (os.clock() - gt1)*1000))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if logging then
|
||||
minetest.log("action", string.format("[mcl_mapgen_core] %-20s %s ... %s %8.2fms", "Generating chunk", minetest.pos_to_string(minp), minetest.pos_to_string(maxp), (os.clock() - t1)*1000))
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
mcl_mapgen_core = {}
|
||||
local registered_generators = {}
|
||||
|
||||
local modname = minetest.get_current_modname()
|
||||
local modpath = minetest.get_modpath(modname)
|
||||
|
||||
|
@ -118,8 +116,6 @@ elseif mg_name == "fractal" then
|
|||
mg_flags.caverns = true
|
||||
end
|
||||
|
||||
|
||||
|
||||
local mg_flags_str = ""
|
||||
for k,v in pairs(mg_flags) do
|
||||
if v == false then
|
||||
|
@ -211,12 +207,12 @@ end
|
|||
local function set_layers(data, area, content_id, check, min, max, minp, maxp, pr)
|
||||
if maxp.y < min or minp.y > max then return false end
|
||||
local lvm_used = false
|
||||
if check == nil then
|
||||
if not check then
|
||||
for p_pos in area:iter(minp.x, math.max(min, minp.y), minp.z, maxp.x, math.min(max, maxp.y), maxp.z) do
|
||||
data[p_pos] = content_id
|
||||
lvm_used = true
|
||||
end
|
||||
elseif check and type(check) == "function" then
|
||||
elseif type(check) == "function" then
|
||||
-- slow path, needs vector coordinates (bedrock uses y only)
|
||||
for p_pos in area:iter(minp.x, math.max(min, minp.y), minp.z, maxp.x, math.min(max, maxp.y), maxp.z) do
|
||||
if check(area:position(p_pos), data[p_pos], pr) then
|
||||
|
|
Loading…
Add table
Reference in a new issue