Default/trees: Add checks for air/ignore/needles to pinetree trunk
Speed optimise: Trunk placing, add_pine_needles, add_snow
This commit is contained in:
parent
0914e595c7
commit
585b2bc22e
|
@ -74,11 +74,11 @@ local function add_trunk_and_leaves(data, a, pos, tree_cid, leaves_cid,
|
|||
local c_apple = minetest.get_content_id("default:apple")
|
||||
|
||||
-- Trunk
|
||||
for y_dist = 0, height - 1 do
|
||||
local vi = a:index(x, y + y_dist, z)
|
||||
data[a:index(x, y, z)] = tree_cid -- Force-place lowest trunk node to replace sapling
|
||||
for yy = y + 1, y + height - 1 do
|
||||
local vi = a:index(x, yy, z)
|
||||
local node_id = data[vi]
|
||||
if y_dist == 0 or node_id == c_air or node_id == c_ignore
|
||||
or node_id == leaves_cid then
|
||||
if node_id == c_air or node_id == c_ignore or node_id == leaves_cid then
|
||||
data[vi] = tree_cid
|
||||
end
|
||||
end
|
||||
|
@ -209,13 +209,15 @@ end
|
|||
-- Pinetree from mg mapgen mod, design by sfan5, pointy top added by paramat
|
||||
|
||||
local function add_pine_needles(data, vi, c_air, c_ignore, c_snow, c_pine_needles)
|
||||
if data[vi] == c_air or data[vi] == c_ignore or data[vi] == c_snow then
|
||||
local node_id = data[vi]
|
||||
if node_id == c_air or node_id == c_ignore or node_id == c_snow then
|
||||
data[vi] = c_pine_needles
|
||||
end
|
||||
end
|
||||
|
||||
local function add_snow(data, vi, c_air, c_ignore, c_snow)
|
||||
if data[vi] == c_air or data[vi] == c_ignore then
|
||||
local node_id = data[vi]
|
||||
if node_id == c_air or node_id == c_ignore then
|
||||
data[vi] = c_snow
|
||||
end
|
||||
end
|
||||
|
@ -240,16 +242,14 @@ function default.grow_pine_tree(pos)
|
|||
local a = VoxelArea:new({MinEdge = minp, MaxEdge = maxp})
|
||||
local data = vm:get_data()
|
||||
|
||||
-- Scan for snow nodes near sapling
|
||||
-- Scan for snow nodes near sapling to enable snow on branches
|
||||
local snow = false
|
||||
for yy = y - 1, y + 1 do
|
||||
for zz = z - 1, z + 1 do
|
||||
local vi = a:index(x - 1, yy, zz)
|
||||
for xx = x - 1, x + 1 do
|
||||
local nodid = data[vi]
|
||||
if nodid == c_snow
|
||||
or nodid == c_snowblock
|
||||
or nodid == c_dirtsnow then
|
||||
if nodid == c_snow or nodid == c_snowblock or nodid == c_dirtsnow then
|
||||
snow = true
|
||||
end
|
||||
vi = vi + 1
|
||||
|
@ -332,10 +332,14 @@ function default.grow_pine_tree(pos)
|
|||
end
|
||||
|
||||
-- Trunk
|
||||
for yy = y, maxy do
|
||||
data[a:index(x, y, z)] = c_pinetree -- Force-place lowest trunk node to replace sapling
|
||||
for yy = y + 1, maxy do
|
||||
local vi = a:index(x, yy, z)
|
||||
local node_id = data[vi]
|
||||
if node_id == c_air or node_id == c_ignore or node_id == c_pine_needles then
|
||||
data[vi] = c_pinetree
|
||||
end
|
||||
end
|
||||
|
||||
vm:set_data(data)
|
||||
vm:write_to_map()
|
||||
|
|
Loading…
Reference in New Issue