mirror of
https://github.com/sbrl/Minetest-WorldEditAdditions.git
synced 2024-11-22 15:33:00 +00:00
//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:
parent
bbafca2020
commit
a2a9108d36
5 changed files with 16 additions and 9 deletions
|
@ -30,12 +30,12 @@ local function apply_heightmap(brush, brush_size, height, position, heightmap, h
|
||||||
-- Iterate over the heightmap and apply the brush
|
-- Iterate over the heightmap and apply the brush
|
||||||
-- Note that we do not iterate over the brush, because we don't know if the
|
-- Note that we do not iterate over the brush, because we don't know if the
|
||||||
-- brush actually fits inside the region.... O.o
|
-- brush actually fits inside the region.... O.o
|
||||||
for z = pos_end, pos_start, -1 do
|
for z = pos_end.z - 1, pos_start.z, -1 do
|
||||||
for x = pos_end, pos_start, -1 do
|
for x = pos_end.x - 1, pos_start.x, -1 do
|
||||||
local hi = z*heightmap_size.x + x
|
local hi = z*heightmap_size.x + x
|
||||||
local pos_brush = Vector3.new(x, 0, z) - pos_start
|
local pos_brush = Vector3.new(x, 0, z) - pos_start
|
||||||
local bi = pos_brush.z*brush_size.x + pos_brush.x
|
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)
|
local adjustment = math.floor(brush[bi]*height)
|
||||||
if adjustment > 0 then
|
if adjustment > 0 then
|
||||||
added = added + adjustment
|
added = added + adjustment
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
local wea = worldeditadditions
|
local wea = worldeditadditions
|
||||||
|
local Vector3 = wea.Vector3
|
||||||
|
|
||||||
--- Returns a smooth gaussian brush.
|
--- 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.
|
-- @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
|
gaussian[i] = gaussian[i] / max
|
||||||
end
|
end
|
||||||
|
|
||||||
return success, gaussian, { x = size, y = size }
|
return success, gaussian, Vector3.new(size, size, 0)
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
local wea = worldeditadditions
|
local wea = worldeditadditions
|
||||||
|
local Vector3 = wea.Vector3
|
||||||
|
|
||||||
--- Given a manip object and associates, generates a 2D x/z heightmap.
|
--- Given a manip object and associates, generates a 2D x/z heightmap.
|
||||||
-- Note that pos1 and pos2 should have already been pushed through
|
-- 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
|
||||||
end
|
end
|
||||||
|
|
||||||
local heightmap_size = {
|
local heightmap_size = Vector3.new(
|
||||||
z = (pos2.z - pos1.z) + 1,
|
(pos2.x - pos1.x) + 1, -- x
|
||||||
x = (pos2.x - pos1.x) + 1
|
0, -- y
|
||||||
}
|
(pos2.z - pos1.z) + 1 -- z
|
||||||
|
)
|
||||||
|
|
||||||
return heightmap, heightmap_size
|
return heightmap, heightmap_size
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
local we_c = worldeditadditions_commands
|
local we_c = worldeditadditions_commands
|
||||||
local wea = worldeditadditions
|
local wea = worldeditadditions
|
||||||
|
local Vector3 = wea.Vector3
|
||||||
|
|
||||||
-- ███████ ██████ ██ ██ ██ ██████ ████████
|
-- ███████ ██████ ██ ██ ██ ██████ ████████
|
||||||
-- ██ ██ ██ ██ ██ ██ ██ ██
|
-- ██ ██ ██ ██ ██ ██ ██ ██
|
||||||
|
@ -41,7 +42,9 @@ worldedit.register_command("sculpt", {
|
||||||
end
|
end
|
||||||
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,
|
end,
|
||||||
nodes_needed = function(name, brush_name, height, brush_size)
|
nodes_needed = function(name, brush_name, height, brush_size)
|
||||||
local success, brush, size_actual = wea.sculpt.make_brush(brush_name, brush_size)
|
local success, brush, size_actual = wea.sculpt.make_brush(brush_name, brush_size)
|
||||||
|
|
|
@ -40,6 +40,7 @@ dofile(we_c.modpath.."/commands/copy.lua")
|
||||||
dofile(we_c.modpath.."/commands/move.lua")
|
dofile(we_c.modpath.."/commands/move.lua")
|
||||||
|
|
||||||
dofile(we_c.modpath.."/commands/count.lua")
|
dofile(we_c.modpath.."/commands/count.lua")
|
||||||
|
dofile(we_c.modpath.."/commands/sculpt.lua")
|
||||||
|
|
||||||
-- Meta Commands
|
-- Meta Commands
|
||||||
dofile(we_c.modpath.."/commands/meta/init.lua")
|
dofile(we_c.modpath.."/commands/meta/init.lua")
|
||||||
|
|
Loading…
Reference in a new issue