mirror of
git://repo.or.cz/rocks.git
synced 2025-01-04 07:10:28 +01:00
Optimize generation callbacks.
This commit is contained in:
parent
7574b0f463
commit
b9ad0a251c
@ -34,10 +34,8 @@ local np_sp = {
|
|||||||
local stats
|
local stats
|
||||||
stats={ total=0 }
|
stats={ total=0 }
|
||||||
|
|
||||||
rocksl.gensed = function (minp, maxp, seed)
|
rocksl.gensed = function (minp, maxp, seed, vm, area)
|
||||||
local t1 = os.clock()
|
local t1 = os.clock()
|
||||||
local vm, emin, emax = minetest.get_mapgen_object("voxelmanip")
|
|
||||||
local area = VoxelArea:new{MinEdge=emin, MaxEdge=emax}
|
|
||||||
local data = vm:get_data()
|
local data = vm:get_data()
|
||||||
|
|
||||||
local chunksize = maxp.x - minp.x + 1
|
local chunksize = maxp.x - minp.x + 1
|
||||||
@ -160,7 +158,6 @@ rocksl.gensed = function (minp, maxp, seed)
|
|||||||
end end
|
end end
|
||||||
if generated then
|
if generated then
|
||||||
vm:set_data(data)
|
vm:set_data(data)
|
||||||
vm:write_to_map(data)
|
|
||||||
if stats then for k,v in pairs(stats) do print("stat: "..k..": "..((v/stats.total)*100).."%") end end
|
if stats then for k,v in pairs(stats) do print("stat: "..k..": "..((v/stats.total)*100).."%") end end
|
||||||
else
|
else
|
||||||
print("no sed layer y="..minp.y)
|
print("no sed layer y="..minp.y)
|
||||||
|
@ -91,10 +91,9 @@ local np_intr = {
|
|||||||
seed = 3740,
|
seed = 3740,
|
||||||
}
|
}
|
||||||
|
|
||||||
minetest.register_on_generated( function( minp, maxp, seed )
|
--minetest.register_on_generated( function( minp, maxp, seed )
|
||||||
|
rocksl.genign=function(minp,maxp,seed, vm, area)
|
||||||
local t1 = os.clock()
|
local t1 = os.clock()
|
||||||
local vm, emin, emax = minetest.get_mapgen_object("voxelmanip")
|
|
||||||
local area = VoxelArea:new{MinEdge=emin, MaxEdge=emax}
|
|
||||||
local data = vm:get_data()
|
local data = vm:get_data()
|
||||||
|
|
||||||
local chunksize = maxp.x - minp.x + 1
|
local chunksize = maxp.x - minp.x + 1
|
||||||
@ -137,9 +136,8 @@ minetest.register_on_generated( function( minp, maxp, seed )
|
|||||||
vm:set_data(data)
|
vm:set_data(data)
|
||||||
--DEBUG: vm:set_lighting({day=15,night=2})
|
--DEBUG: vm:set_lighting({day=15,night=2})
|
||||||
minetest.generate_ores(vm)
|
minetest.generate_ores(vm)
|
||||||
vm:write_to_map(data)
|
|
||||||
minetest.log("action", "rocks/layer/ "..math.ceil((os.clock() - t1) * 1000).." ms ")
|
minetest.log("action", "rocks/layer/ "..math.ceil((os.clock() - t1) * 1000).." ms ")
|
||||||
end)
|
end
|
||||||
|
|
||||||
|
|
||||||
-- ~ Tomas Brod
|
-- ~ Tomas Brod
|
@ -30,7 +30,14 @@ dofile(modpath.."/ign.lua")
|
|||||||
dofile(modpath.."/skarn.lua")
|
dofile(modpath.."/skarn.lua")
|
||||||
dofile(modpath.."/pegmatite.lua")
|
dofile(modpath.."/pegmatite.lua")
|
||||||
dofile(modpath.."/gensed.lua")
|
dofile(modpath.."/gensed.lua")
|
||||||
minetest.register_on_generated(rocksl.gensed)
|
|
||||||
|
minetest.register_on_generated(function(minp,maxp,seed)
|
||||||
|
local vm, emin, emax = minetest.get_mapgen_object("voxelmanip")
|
||||||
|
local area = VoxelArea:new{MinEdge=emin, MaxEdge=emax}
|
||||||
|
rocksl.gensed(minp,maxp,seed,vm,area)
|
||||||
|
--rocksl.genign
|
||||||
|
vm:write_to_map(data)
|
||||||
|
end)
|
||||||
|
|
||||||
minetest.register_on_mapgen_init(function(mapgen_params)
|
minetest.register_on_mapgen_init(function(mapgen_params)
|
||||||
-- todo: disable caves and ores
|
-- todo: disable caves and ores
|
||||||
|
Loading…
Reference in New Issue
Block a user