mirror of
https://github.com/luanti-org/minetest_game.git
synced 2025-07-14 02:12:01 -04:00
Further optimize tree leaf and root placing
This commit is contained in:
parent
ead9f936a7
commit
bb3bb6fa47
1 changed files with 21 additions and 18 deletions
|
@ -63,20 +63,21 @@ local function add_trunk_and_leaves(data, a, pos, tree_cid, leaves_cid,
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Force leaves near the trunk
|
-- Force leaves near the trunk
|
||||||
for x_dist = -1, 1 do
|
|
||||||
for y_dist = -size, 1 do
|
|
||||||
for z_dist = -1, 1 do
|
for z_dist = -1, 1 do
|
||||||
local vi = a:index(x + x_dist, y + height + y_dist, z + z_dist)
|
for y_dist = -size, 1 do
|
||||||
if data[vi] == c_air then
|
local vi = a:index(x - 1, y + height + y_dist, z + z_dist)
|
||||||
if is_apple_tree and random(1, 8) == 1 then
|
for x_dist = -1, 1 do
|
||||||
data[vi] = c_apple
|
if data[vi] == c_air then
|
||||||
else
|
if is_apple_tree and random(1, 8) == 1 then
|
||||||
data[vi] = leaves_cid
|
data[vi] = c_apple
|
||||||
|
else
|
||||||
|
data[vi] = leaves_cid
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
vi = vi + 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
-- Randomly add leaves in 2x2x2 clusters.
|
-- Randomly add leaves in 2x2x2 clusters.
|
||||||
for i = 1, iters do
|
for i = 1, iters do
|
||||||
|
@ -159,19 +160,21 @@ function default.grow_jungletree(pos, bad)
|
||||||
add_trunk_and_leaves(data, a, pos, c_jungletree, c_jungleleaves, height, 3, 30, false)
|
add_trunk_and_leaves(data, a, pos, c_jungletree, c_jungleleaves, height, 3, 30, false)
|
||||||
|
|
||||||
-- Roots
|
-- Roots
|
||||||
for x_dist = -1, 1 do
|
|
||||||
for z_dist = -1, 1 do
|
for z_dist = -1, 1 do
|
||||||
if random(1, 3) >= 2 then
|
local vi_1 = a:index(x - 1, y - 1, z + z_dist)
|
||||||
local vi_1 = a:index(x + x_dist, y - 1, z + z_dist)
|
local vi_2 = a:index(x - 1, y, z + z_dist)
|
||||||
local vi_2 = a:index(x + x_dist, y, z + z_dist)
|
for x_dist = -1, 1 do
|
||||||
if data[vi_1] == c_air then
|
if random(1, 3) >= 2 then
|
||||||
data[vi_1] = c_jungletree
|
if data[vi_1] == c_air then
|
||||||
elseif data[vi_2] == c_air then
|
data[vi_1] = c_jungletree
|
||||||
data[vi_2] = c_jungletree
|
elseif data[vi_2] == c_air then
|
||||||
|
data[vi_2] = c_jungletree
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
vi_1 = vi_1 + 1
|
||||||
|
vi_2 = vi_2 + 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
vm:set_data(data)
|
vm:set_data(data)
|
||||||
vm:write_to_map()
|
vm:write_to_map()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue