From 2da0f2dcc28eddbbca26a011ecf9078a026fa983 Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Tue, 28 Dec 2021 17:22:18 +0000 Subject: [PATCH] Add circle brush, but it isn't working right just yet. --- .../lib/sculpt/apply_heightmap.lua | 2 +- .../lib/sculpt/brushes/circle.lua | 28 +++++++++++++++++++ .../lib/sculpt/brushes/default.lua | 2 +- .../lib/sculpt/brushes/default_hard.lua | 2 +- .../lib/sculpt/brushes/default_soft.lua | 2 +- worldeditadditions/lib/sculpt/init.lua | 3 +- 6 files changed, 34 insertions(+), 5 deletions(-) create mode 100644 worldeditadditions/lib/sculpt/brushes/circle.lua diff --git a/worldeditadditions/lib/sculpt/apply_heightmap.lua b/worldeditadditions/lib/sculpt/apply_heightmap.lua index 5af9d63..dd66446 100644 --- a/worldeditadditions/lib/sculpt/apply_heightmap.lua +++ b/worldeditadditions/lib/sculpt/apply_heightmap.lua @@ -35,7 +35,7 @@ local function apply_heightmap(brush, brush_size, height, position, heightmap, h 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/circle.lua b/worldeditadditions/lib/sculpt/brushes/circle.lua new file mode 100644 index 0000000..4ff6746 --- /dev/null +++ b/worldeditadditions/lib/sculpt/brushes/circle.lua @@ -0,0 +1,28 @@ +local wea = worldeditadditions +local Vector3 = wea.Vector3 + +local __smooth = dofile(wea.modpath.."/lib/sculpt/brushes/__smooth.lua") + +return function(size) + local brush = {} + + local centre = (size / 2):floor() + local minsize = math.floor(math.min(size.x, size.y) / 2) + + print("centre", centre, "minsize", minsize) + + for y = size.y - 1, 0, -1 do + for x = size.x - 1, 0, -1 do + local i = y*size.x + x + + + if math.floor((centre - Vector3.new(x, y, 0)):abs():length()) < minsize - 2 then + brush[i] = 1 + else + brush[i] = 0 + end + end + end + + return true, brush, size +end diff --git a/worldeditadditions/lib/sculpt/brushes/default.lua b/worldeditadditions/lib/sculpt/brushes/default.lua index eadf4c6..3982ee9 100644 --- a/worldeditadditions/lib/sculpt/brushes/default.lua +++ b/worldeditadditions/lib/sculpt/brushes/default.lua @@ -3,6 +3,6 @@ local wea = worldeditadditions local __smooth = dofile(wea.modpath.."/lib/sculpt/brushes/__smooth.lua") return function(size) - local success, brush, size_actual = __smooth(size, 2) + local success, brush, size_actual = __smooth(size, 3) return success, brush, size_actual end diff --git a/worldeditadditions/lib/sculpt/brushes/default_hard.lua b/worldeditadditions/lib/sculpt/brushes/default_hard.lua index 33c1192..eadf4c6 100644 --- a/worldeditadditions/lib/sculpt/brushes/default_hard.lua +++ b/worldeditadditions/lib/sculpt/brushes/default_hard.lua @@ -3,6 +3,6 @@ local wea = worldeditadditions local __smooth = dofile(wea.modpath.."/lib/sculpt/brushes/__smooth.lua") return function(size) - local success, brush, size_actual = __smooth(size, 1.25) + local success, brush, size_actual = __smooth(size, 2) return success, brush, size_actual end diff --git a/worldeditadditions/lib/sculpt/brushes/default_soft.lua b/worldeditadditions/lib/sculpt/brushes/default_soft.lua index 3982ee9..228e5ec 100644 --- a/worldeditadditions/lib/sculpt/brushes/default_soft.lua +++ b/worldeditadditions/lib/sculpt/brushes/default_soft.lua @@ -3,6 +3,6 @@ local wea = worldeditadditions local __smooth = dofile(wea.modpath.."/lib/sculpt/brushes/__smooth.lua") return function(size) - local success, brush, size_actual = __smooth(size, 3) + local success, brush, size_actual = __smooth(size, 5) return success, brush, size_actual end diff --git a/worldeditadditions/lib/sculpt/init.lua b/worldeditadditions/lib/sculpt/init.lua index fedb6e7..ad9ffb6 100644 --- a/worldeditadditions/lib/sculpt/init.lua +++ b/worldeditadditions/lib/sculpt/init.lua @@ -5,7 +5,8 @@ local sculpt = { default_hard = dofile(wea.modpath.."/lib/sculpt/brushes/default_hard.lua"), default = dofile(wea.modpath.."/lib/sculpt/brushes/default.lua"), default_soft = dofile(wea.modpath.."/lib/sculpt/brushes/default_soft.lua"), - square = dofile(wea.modpath.."/lib/sculpt/brushes/square.lua") + square = dofile(wea.modpath.."/lib/sculpt/brushes/square.lua"), + circle = dofile(wea.modpath.."/lib/sculpt/brushes/circle.lua") }, make_brush = dofile(wea.modpath.."/lib/sculpt/make_brush.lua"), preview_brush = dofile(wea.modpath.."/lib/sculpt/preview_brush.lua"),