From a2a9108d366ff7d8a7681cb3530d5eeb6b7818cf Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Tue, 28 Dec 2021 15:22:51 +0000 Subject: [PATCH] //sculpt: fix a bunch of bugs including, but certainly not limited to, wea.make_heightmap now returns a Vector3 instance for heightmap_size --- worldeditadditions/lib/sculpt/apply_heightmap.lua | 6 +++--- worldeditadditions/lib/sculpt/brushes/__smooth.lua | 3 ++- worldeditadditions/utils/terrain.lua | 10 ++++++---- worldeditadditions_commands/commands/sculpt.lua | 5 ++++- worldeditadditions_commands/init.lua | 1 + 5 files changed, 16 insertions(+), 9 deletions(-) diff --git a/worldeditadditions/lib/sculpt/apply_heightmap.lua b/worldeditadditions/lib/sculpt/apply_heightmap.lua index 1ad9621..5af9d63 100644 --- a/worldeditadditions/lib/sculpt/apply_heightmap.lua +++ b/worldeditadditions/lib/sculpt/apply_heightmap.lua @@ -30,12 +30,12 @@ local function apply_heightmap(brush, brush_size, height, position, heightmap, h -- Iterate over the heightmap and apply the brush -- Note that we do not iterate over the brush, because we don't know if the -- brush actually fits inside the region.... O.o - for z = pos_end, pos_start, -1 do - for x = pos_end, pos_start, -1 do + for z = pos_end.z - 1, pos_start.z, -1 do + for x = pos_end.x - 1, pos_start.x, -1 do local hi = z*heightmap_size.x + x local pos_brush = Vector3.new(x, 0, z) - pos_start local bi = pos_brush.z*brush_size.x + pos_brush.x - + print("hi", hi, "heightmap[hi]", heightmap[hi], "bi", bi, "brush[bi]", brush[bi]) local adjustment = math.floor(brush[bi]*height) if adjustment > 0 then added = added + adjustment diff --git a/worldeditadditions/lib/sculpt/brushes/__smooth.lua b/worldeditadditions/lib/sculpt/brushes/__smooth.lua index 8654da6..7276065 100644 --- a/worldeditadditions/lib/sculpt/brushes/__smooth.lua +++ b/worldeditadditions/lib/sculpt/brushes/__smooth.lua @@ -1,4 +1,5 @@ local wea = worldeditadditions +local Vector3 = wea.Vector3 --- Returns a smooth gaussian brush. -- @param size Vector3 The target size of the brush. Note that the actual size of the brush will be different, as the gaussian function has some limitations. @@ -18,5 +19,5 @@ return function(size, sigma) gaussian[i] = gaussian[i] / max end - return success, gaussian, { x = size, y = size } + return success, gaussian, Vector3.new(size, size, 0) end diff --git a/worldeditadditions/utils/terrain.lua b/worldeditadditions/utils/terrain.lua index 920496f..8649871 100644 --- a/worldeditadditions/utils/terrain.lua +++ b/worldeditadditions/utils/terrain.lua @@ -1,4 +1,5 @@ local wea = worldeditadditions +local Vector3 = wea.Vector3 --- Given a manip object and associates, generates a 2D x/z heightmap. -- Note that pos1 and pos2 should have already been pushed through @@ -35,10 +36,11 @@ function worldeditadditions.make_heightmap(pos1, pos2, manip, area, data) end end - local heightmap_size = { - z = (pos2.z - pos1.z) + 1, - x = (pos2.x - pos1.x) + 1 - } + local heightmap_size = Vector3.new( + (pos2.x - pos1.x) + 1, -- x + 0, -- y + (pos2.z - pos1.z) + 1 -- z + ) return heightmap, heightmap_size end diff --git a/worldeditadditions_commands/commands/sculpt.lua b/worldeditadditions_commands/commands/sculpt.lua index 1d01097..b0ffb98 100644 --- a/worldeditadditions_commands/commands/sculpt.lua +++ b/worldeditadditions_commands/commands/sculpt.lua @@ -1,5 +1,6 @@ local we_c = worldeditadditions_commands local wea = worldeditadditions +local Vector3 = wea.Vector3 -- ███████ ██████ ██ ██ ██ ██████ ████████ -- ██ ██ ██ ██ ██ ██ ██ ██ @@ -41,7 +42,9 @@ worldedit.register_command("sculpt", { end end - return true, brush_name, math.floor(height), math.floor(brush_size) + brush_size = Vector3.new(brush_size, brush_size, 0):floor() + + return true, brush_name, math.floor(height), brush_size end, nodes_needed = function(name, brush_name, height, brush_size) local success, brush, size_actual = wea.sculpt.make_brush(brush_name, brush_size) diff --git a/worldeditadditions_commands/init.lua b/worldeditadditions_commands/init.lua index b6b4244..13939df 100644 --- a/worldeditadditions_commands/init.lua +++ b/worldeditadditions_commands/init.lua @@ -40,6 +40,7 @@ dofile(we_c.modpath.."/commands/copy.lua") dofile(we_c.modpath.."/commands/move.lua") dofile(we_c.modpath.."/commands/count.lua") +dofile(we_c.modpath.."/commands/sculpt.lua") -- Meta Commands dofile(we_c.modpath.."/commands/meta/init.lua")