//sculpt: fix a bunch of bugs

including, but certainly not limited to, wea.make_heightmap now returns 
a Vector3 instance for heightmap_size
This commit is contained in:
Starbeamrainbowlabs 2021-12-28 15:22:51 +00:00
parent bbafca2020
commit a2a9108d36
Signed by: sbrl
GPG Key ID: 1BE5172E637709C2
5 changed files with 16 additions and 9 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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)

View File

@ -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")