2022-09-19 02:16:22 +02:00
|
|
|
local wea_c = worldeditadditions_core
|
|
|
|
local Vector3 = wea_c.Vector3
|
2021-12-28 18:22:18 +01:00
|
|
|
|
2023-08-03 03:42:46 +02:00
|
|
|
---
|
|
|
|
-- @module worldeditadditions.sculpt.brushes
|
|
|
|
|
2022-09-19 02:16:22 +02:00
|
|
|
--- Makes a circle brush of a given size.
|
2023-08-03 03:42:46 +02:00
|
|
|
-- Default inbuilt brush.
|
2023-07-02 21:05:46 +02:00
|
|
|
-- @name circle
|
2022-09-19 02:16:22 +02:00
|
|
|
-- @param size Vector3 The desired sizez of the brush (only X and Y are considered; Z is ignored).
|
|
|
|
-- @returns bool,brush,Vector3 Success bool, then the brush, then finally the actual size of the brush generated.
|
2021-12-28 18:22:18 +01:00
|
|
|
return function(size)
|
|
|
|
local brush = {}
|
|
|
|
|
|
|
|
local centre = (size / 2):floor()
|
|
|
|
local minsize = math.floor(math.min(size.x, size.y) / 2)
|
|
|
|
|
|
|
|
for y = size.y - 1, 0, -1 do
|
|
|
|
for x = size.x - 1, 0, -1 do
|
|
|
|
local i = y*size.x + x
|
|
|
|
|
2021-12-28 18:45:20 +01:00
|
|
|
if math.floor((centre - Vector3.new(x, y, 0)):length()) < minsize then
|
2021-12-28 18:22:18 +01:00
|
|
|
brush[i] = 1
|
|
|
|
else
|
|
|
|
brush[i] = 0
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
return true, brush, size
|
|
|
|
end
|