Fix directionality in worldedit region update when scaling down

This commit is contained in:
Starbeamrainbowlabs 2021-02-18 02:33:26 +00:00
parent b2b3f5bec5
commit 4368f74e30
No known key found for this signature in database
GPG Key ID: 1BE5172E637709C2
3 changed files with 14 additions and 1 deletions

@ -38,6 +38,7 @@ The detailed explanations have moved! Check them out [here](https://github.com/s
### Misc
- [`//replacemix <target_node> [<chance>] <replace_node_a> [<chance_a>] [<replace_node_b> [<chance_b>]] [<replace_node_N> [<chance_N>]] ....`](https://github.com/sbrl/Minetest-WorldEditAdditions/blob/master/Chat-Command-Reference.md#replacemix-target_node-chance-replace_node_a-chance_a-replace_node_b-chance_b-replace_node_n-chance_n-)
- [`//floodfill [<replace_node> [<radius>]]`](https://github.com/sbrl/Minetest-WorldEditAdditions/blob/master/Chat-Command-Reference.md#floodfill-replace_node-radius-floodfill)
- [`//scale <axis> <scale_factor> | <factor_x> [<factor_y> <factor_z> [<anchor_x> <anchor_y> <anchor_z>]]`]()
### Terrain
- [`//overlay <node_name_a> [<chance_a>] <node_name_b> [<chance_b>] [<node_name_N> [<chance_N>]] ...`](https://github.com/sbrl/Minetest-WorldEditAdditions/blob/master/Chat-Command-Reference.md#overlay-node_name_a-chance_a-node_name_b-chance_b-node_name_n-chance_n-)

@ -49,6 +49,8 @@ function worldeditadditions.scale(pos1, pos2, scale, anchor)
pos2 = stats.pos2
end
pos1, pos2 = worldedit.sort_pos(pos1, pos2)
stats_total.pos1 = pos1
stats_total.pos2 = pos2

@ -43,8 +43,18 @@ function worldeditadditions.scale_down(pos1, pos2, scale, anchor)
local node_id_air = minetest.get_content_id("air")
local pos1_small = vector.new(pos1)
local pos2_small = vector.new(pos2)
local stats = { updated = 0, scale = scale_down, pos1 = pos1, pos2 = vector.add(pos1, size_small) }
if anchor.x < 1 then pos1_small.x = pos2_small.x - size_small.x
else pos2_small.x = pos1_small.x + size_small.x end
if anchor.y < 1 then pos1_small.y = pos2_small.y - size_small.y
else pos2_small.y = pos1_small.y + size_small.y end
if anchor.z < 1 then pos1_small.z = pos2_small.z - size_small.z
else pos2_small.z = pos1_small.z + size_small.z end
local stats = { updated = 0, scale = scale_down, pos1 = pos1_small, pos2 = pos2_small }
-- Zero out the area we're scaling down into
for i in area:iterp(pos1, pos2) do
data_copy[i] = node_id_air