From 60e10234081fe181b7d456c751b17b19937a8df7 Mon Sep 17 00:00:00 2001 From: Vanic Date: Sun, 5 Oct 2025 14:51:09 +0300 Subject: [PATCH] Mapgen: changes due to added noise annotation --- mods/CORE/MapGen/src/MapGen.lua | 9 ++++++--- .../MapGen/src/MapGen/Region/Multinoise.lua | 2 +- .../src/MapGen/Region/MultinoiseParams.lua | 17 +++-------------- 3 files changed, 10 insertions(+), 18 deletions(-) diff --git a/mods/CORE/MapGen/src/MapGen.lua b/mods/CORE/MapGen/src/MapGen.lua index dce7d8d..024fffa 100644 --- a/mods/CORE/MapGen/src/MapGen.lua +++ b/mods/CORE/MapGen/src/MapGen.lua @@ -4,10 +4,11 @@ local mathCeil, mathAbs -- --- MapGen default moises --- local oceanNoise +---@type NoiseParams local oceanNoiseParams = { offset = -30, scale = 10, - spread = {x = 100, y = 100, z = 100}, + spread = vector.new(100, 100, 100), seed = 47, octaves = 8, persistence = 0.4, @@ -204,10 +205,12 @@ local function generatorHandler(mapGenerator, data, index, x, y, z) for _, region in ipairs(regions) do local noise = region:getMultinoise().landscapeNoise + if noise ~= nil then -- The further a point is from the center of a region, the less noise affects it. - local weight = calculateWeight2D(region:getMinPos(), region:getMaxPos(), x, z, region.getWeightFactor()) + local weight = calculateWeight2D(region:getMinPos(), region:getMaxPos(), x, z, region.getWeightFactor()) - noiseHeightValue = noiseHeightValue + ( noise:get_2d({x = x, y = z}) * weight ) + noiseHeightValue = noiseHeightValue + ( noise:get_2d(vector.new(x, z, 0)) * weight ) + end end generateNode(mapGenerator, noiseHeightValue, data, index, x, y, z) diff --git a/mods/CORE/MapGen/src/MapGen/Region/Multinoise.lua b/mods/CORE/MapGen/src/MapGen/Region/Multinoise.lua index b2fda37..bdf8043 100644 --- a/mods/CORE/MapGen/src/MapGen/Region/Multinoise.lua +++ b/mods/CORE/MapGen/src/MapGen/Region/Multinoise.lua @@ -1,7 +1,7 @@ ---For EmmyLua only ---@class MapGen.Region.Multinoise ----@field landscapeNoise ValueNoise? -- TODO: describe ValueNoise class from Luanti (push Alek) +---@field landscapeNoise ValueNoise? ---@field tempNoise ValueNoise? ---@field humidityNoise ValueNoise? local Multinoise = {} diff --git a/mods/CORE/MapGen/src/MapGen/Region/MultinoiseParams.lua b/mods/CORE/MapGen/src/MapGen/Region/MultinoiseParams.lua index 87042e5..18d872c 100644 --- a/mods/CORE/MapGen/src/MapGen/Region/MultinoiseParams.lua +++ b/mods/CORE/MapGen/src/MapGen/Region/MultinoiseParams.lua @@ -1,20 +1,9 @@ ---For EmmyLua only - -- TODO: Когда в хелпер добавятся аннотации шумов, надо будет удалить этот класс и заменить его на хелперский ----@class MapGen.Region.NoiseParams ----@field offset number ----@field scale number ----@field spread vector ----@field seed number ----@field octaves number ----@field persistence number ----@field lacunarity number ----@field flags string? - ---@class MapGen.Region.MultinoiseParams ----@field landscapeNoise MapGen.Region.NoiseParams? ----@field tempNoise MapGen.Region.NoiseParams? ----@field humidityNoise MapGen.Region.NoiseParams? +---@field landscapeNoise NoiseParams? +---@field tempNoise NoiseParams? +---@field humidityNoise NoiseParams? local MultinoiseParams = {} return MultinoiseParams