mirror of
https://github.com/mt-mods/biome_lib.git
synced 2024-12-26 02:40:17 +01:00
optimize some blocklist/actionlist checks
This commit is contained in:
parent
d65c72d48b
commit
353ca0cbd4
27
init.lua
27
init.lua
@ -395,7 +395,7 @@ end
|
|||||||
-- a surface during the initial map read stage.
|
-- a surface during the initial map read stage.
|
||||||
|
|
||||||
function biome_lib:generate_block_with_air_checking()
|
function biome_lib:generate_block_with_air_checking()
|
||||||
if #biome_lib.blocklist_aircheck == 0 then
|
if not biome_lib.blocklist_aircheck[1] then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -407,13 +407,13 @@ function biome_lib:generate_block_with_air_checking()
|
|||||||
|
|
||||||
local blockhash = minetest.hash_node_position(minp)
|
local blockhash = minetest.hash_node_position(minp)
|
||||||
|
|
||||||
if not biome_lib.surface_nodes_aircheck.blockhash then
|
if not biome_lib.surface_nodes_aircheck.blockhash then -- read it into the block cache
|
||||||
biome_lib.surface_nodes_aircheck.blockhash =
|
biome_lib.surface_nodes_aircheck.blockhash =
|
||||||
minetest.find_nodes_in_area_under_air(minp, maxp, biome_lib.surfaceslist_aircheck)
|
minetest.find_nodes_in_area_under_air(minp, maxp, biome_lib.surfaceslist_aircheck)
|
||||||
biome_lib.actioncount_aircheck.blockhash = 1
|
biome_lib.actioncount_aircheck.blockhash = 1
|
||||||
|
|
||||||
else
|
else
|
||||||
if biome_lib.actioncount_aircheck.blockhash <= #biome_lib.actionslist_aircheck then
|
if biome_lib.actionslist_aircheck[biome_lib.actioncount_aircheck.blockhash] then
|
||||||
-- [1] is biome, [2] is node/function/model
|
-- [1] is biome, [2] is node/function/model
|
||||||
biome_lib:populate_surfaces(
|
biome_lib:populate_surfaces(
|
||||||
biome_lib.actionslist_aircheck[biome_lib.actioncount_aircheck.blockhash][1],
|
biome_lib.actionslist_aircheck[biome_lib.actioncount_aircheck.blockhash][1],
|
||||||
@ -421,10 +421,9 @@ function biome_lib:generate_block_with_air_checking()
|
|||||||
biome_lib.surface_nodes_aircheck.blockhash, true)
|
biome_lib.surface_nodes_aircheck.blockhash, true)
|
||||||
biome_lib.actioncount_aircheck.blockhash = biome_lib.actioncount_aircheck.blockhash + 1
|
biome_lib.actioncount_aircheck.blockhash = biome_lib.actioncount_aircheck.blockhash + 1
|
||||||
else
|
else
|
||||||
if biome_lib.surface_nodes_aircheck.blockhash then
|
table.remove(biome_lib.blocklist_aircheck, 1)
|
||||||
table.remove(biome_lib.blocklist_aircheck, 1)
|
biome_lib.surface_nodes_aircheck.blockhash = nil
|
||||||
biome_lib.surface_nodes_aircheck.blockhash = nil
|
biome_lib.actioncount_aircheck.blockhash = nil
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -433,7 +432,7 @@ end
|
|||||||
-- checking for air during the initial map read stage.
|
-- checking for air during the initial map read stage.
|
||||||
|
|
||||||
function biome_lib:generate_block_no_aircheck()
|
function biome_lib:generate_block_no_aircheck()
|
||||||
if #biome_lib.blocklist_no_aircheck == 0 then
|
if not biome_lib.blocklist_no_aircheck[1] then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -443,25 +442,21 @@ function biome_lib:generate_block_no_aircheck()
|
|||||||
local blockhash = minetest.hash_node_position(minp)
|
local blockhash = minetest.hash_node_position(minp)
|
||||||
|
|
||||||
if not biome_lib.surface_nodes_no_aircheck.blockhash then
|
if not biome_lib.surface_nodes_no_aircheck.blockhash then
|
||||||
|
|
||||||
-- directly read the block to be searched into the chunk cache
|
|
||||||
|
|
||||||
biome_lib.surface_nodes_no_aircheck.blockhash =
|
biome_lib.surface_nodes_no_aircheck.blockhash =
|
||||||
minetest.find_nodes_in_area(minp, maxp, biome_lib.surfaceslist_no_aircheck)
|
minetest.find_nodes_in_area(minp, maxp, biome_lib.surfaceslist_no_aircheck)
|
||||||
biome_lib.actioncount_no_aircheck.blockhash = 1
|
biome_lib.actioncount_no_aircheck.blockhash = 1
|
||||||
|
|
||||||
else
|
else
|
||||||
if biome_lib.actioncount_no_aircheck.blockhash <= #biome_lib.actionslist_no_aircheck then
|
if biome_lib.actionslist_no_aircheck[biome_lib.actioncount_no_aircheck.blockhash] then
|
||||||
biome_lib:populate_surfaces(
|
biome_lib:populate_surfaces(
|
||||||
biome_lib.actionslist_no_aircheck[biome_lib.actioncount_no_aircheck.blockhash][1],
|
biome_lib.actionslist_no_aircheck[biome_lib.actioncount_no_aircheck.blockhash][1],
|
||||||
biome_lib.actionslist_no_aircheck[biome_lib.actioncount_no_aircheck.blockhash][2],
|
biome_lib.actionslist_no_aircheck[biome_lib.actioncount_no_aircheck.blockhash][2],
|
||||||
biome_lib.surface_nodes_no_aircheck.blockhash, false)
|
biome_lib.surface_nodes_no_aircheck.blockhash, false)
|
||||||
biome_lib.actioncount_no_aircheck.blockhash = biome_lib.actioncount_no_aircheck.blockhash + 1
|
biome_lib.actioncount_no_aircheck.blockhash = biome_lib.actioncount_no_aircheck.blockhash + 1
|
||||||
else
|
else
|
||||||
if biome_lib.surface_nodes_no_aircheck.blockhash then
|
table.remove(biome_lib.blocklist_no_aircheck, 1)
|
||||||
table.remove(biome_lib.blocklist_no_aircheck, 1)
|
biome_lib.surface_nodes_no_aircheck.blockhash = nil
|
||||||
biome_lib.surface_nodes_no_aircheck.blockhash = nil
|
biome_lib.actioncount_no_aircheck.blockhash = nil
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user