diff --git a/.luacheckrc b/.luacheckrc index c3a1473..b4d086c 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -31,6 +31,7 @@ read_globals = { "it", "describe", "bonemeal", - "dofile" + "dofile", + "PerlinNoise" } std = "max" diff --git a/worldeditadditions/lib/noise/engines/init.lua b/worldeditadditions/lib/noise/engines/init.lua index 38cd625..2266d70 100644 --- a/worldeditadditions/lib/noise/engines/init.lua +++ b/worldeditadditions/lib/noise/engines/init.lua @@ -2,8 +2,9 @@ local wea = worldeditadditions return { - available = { "perlin", "sin", "white", "red", "infrared" }, + available = { "perlin", "perlinmt", "sin", "white", "red", "infrared" }, Perlin = dofile(wea.modpath.."/lib/noise/engines/perlin.lua"), + PerlinMT = dofile(wea.modpath.."/lib/noise/engines/perlinmt.lua"), Sin = dofile(wea.modpath.."/lib/noise/engines/sin.lua"), White = dofile(wea.modpath.."/lib/noise/engines/white.lua"), Red = dofile(wea.modpath.."/lib/noise/engines/red.lua"), diff --git a/worldeditadditions/lib/noise/engines/perlinmt.lua b/worldeditadditions/lib/noise/engines/perlinmt.lua new file mode 100644 index 0000000..01d4059 --- /dev/null +++ b/worldeditadditions/lib/noise/engines/perlinmt.lua @@ -0,0 +1,32 @@ +local wea = worldeditadditions + + +local PerlinMT = {} +PerlinMT.__index = PerlinMT + + +function PerlinMT.new(seed, params) + if not seed then seed = 0 end + local result = { + -- Provided by Minetest + engine = PerlinNoise({ + offset = 0, + scale = 1, + spread = {x = 10, y = 10, z = 10}, + seed = seed, + octaves = 1, + persistence = 0.63, + lacunarity = 2.0, + flags = "defaults,absvalue", + }) + } + setmetatable(result, PerlinMT) + return result +end + +function PerlinMT:noise( x, y, z ) + local value = self.engine:get_3d(wea.Vector3.new(x, y, z)) + return value +end + +return PerlinMT diff --git a/worldeditadditions/lib/noise/make_2d.lua b/worldeditadditions/lib/noise/make_2d.lua index 92e4972..2c69949 100644 --- a/worldeditadditions/lib/noise/make_2d.lua +++ b/worldeditadditions/lib/noise/make_2d.lua @@ -11,12 +11,16 @@ local wea = worldeditadditions -- @param size Vector An x/y vector representing the size of the noise area to generate. -- @param params table|table