Mapgen improvements, still WIP though
This commit is contained in:
@@ -11,8 +11,8 @@ local id_air = id("air")
|
|||||||
|
|
||||||
-- --- End Node's IDs
|
-- --- End Node's IDs
|
||||||
|
|
||||||
local modInfo = Mod.getInfo()
|
local modInfo = Mod.getInfo()
|
||||||
local require = modInfo.require
|
local require = modInfo.require
|
||||||
|
|
||||||
---@type MapGen.Layer
|
---@type MapGen.Layer
|
||||||
local Layer = require("MapGen.Layer")
|
local Layer = require("MapGen.Layer")
|
||||||
@@ -81,9 +81,9 @@ end
|
|||||||
---@param layerName string
|
---@param layerName string
|
||||||
---@param minPos table
|
---@param minPos table
|
||||||
---@param maxPos table
|
---@param maxPos table
|
||||||
---@param noises table
|
---@param multinoise table
|
||||||
---@param regionIs2D boolean?
|
---@param regionIs2D boolean?
|
||||||
function MapGen:RegisterRegion(layerName, minPos, maxPos, noises, regionIs2D)
|
function MapGen:RegisterRegion(layerName, minPos, maxPos, multinoise, regionIs2D)
|
||||||
---@type MapGen.Layer
|
---@type MapGen.Layer
|
||||||
local layer = self.layersByName[layerName]
|
local layer = self.layersByName[layerName]
|
||||||
|
|
||||||
@@ -97,7 +97,7 @@ function MapGen:RegisterRegion(layerName, minPos, maxPos, noises, regionIs2D)
|
|||||||
end
|
end
|
||||||
|
|
||||||
---@type MapGen.Region
|
---@type MapGen.Region
|
||||||
local region = Region:new(minPos, maxPos, noises)
|
local region = Region:new(minPos, maxPos, multinoise)
|
||||||
|
|
||||||
--TODO: реализовать регистрацию допольнительных регионов для сглаживания шумов
|
--TODO: реализовать регистрацию допольнительных регионов для сглаживания шумов
|
||||||
|
|
||||||
@@ -128,8 +128,8 @@ function MapGen:landscapeGeneration(data, area, x, y, z)
|
|||||||
-- The height noise values of all regions that a node is part of are added together...
|
-- The height noise values of all regions that a node is part of are added together...
|
||||||
---@param region MapGen.Region
|
---@param region MapGen.Region
|
||||||
for _, region in ipairs(regions) do
|
for _, region in ipairs(regions) do
|
||||||
if region.noises.landscapeNoise ~= nil then
|
if region.multinoise.landscapeNoise ~= nil then
|
||||||
local noise = core.get_value_noise(region.noises.landscapeNoise)
|
local noise = core.get_value_noise(region.multinoise.landscapeNoise)
|
||||||
noiseHeightValue = noiseHeightValue + noise:get_2d({x = x, y = z})
|
noiseHeightValue = noiseHeightValue + noise:get_2d({x = x, y = z})
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,55 +1,50 @@
|
|||||||
--============================================================
|
|
||||||
--=======================WARNING!!!===========================
|
|
||||||
--============================================================
|
|
||||||
--======================THIS=FILE=IS==========================
|
|
||||||
--=======================STILL==WIP===========================
|
|
||||||
--=========================BY==ME=============================
|
|
||||||
--============================================================
|
|
||||||
--===================================Doloment=================
|
|
||||||
--============================================================
|
|
||||||
|
|
||||||
-- TODO: replace `table` with `vector` for minPos and maxPos
|
-- TODO: replace `table` with `vector` for minPos and maxPos
|
||||||
---@class MapGen.Region
|
---@class MapGen.Region
|
||||||
---@field minPos table
|
|
||||||
---@field maxPos table
|
|
||||||
---@field noises MapGen.Region.Noises
|
|
||||||
---@field noisesParams MapGen.Region.Noises -- ??? TODO: should be it's own class in EmmyLua
|
|
||||||
local Region = {}
|
local Region = {}
|
||||||
|
|
||||||
---@param noisesParams MapGen.Region.Noises -- ??? TODO: should be it's own class in EmmyLua
|
---@param multinoiseParams MapGen.Region.MultinoiseParams -- ??? TODO: should be it's own class in EmmyLua
|
||||||
---@return MapGen.Region.Noises
|
---@return MapGen.Region.Multinoise
|
||||||
local function paramsToNoises(noisesParams)
|
local function multinoiseParamsToMultinoise(multinoiseParams)
|
||||||
---@type MapGen.Region.Noises
|
---@type MapGen.Region.Multinoise
|
||||||
local noises = {}
|
local multinoise = {}
|
||||||
|
|
||||||
for noiseName, noiseParams in pairs(noisesParams) do
|
for noiseName, noiseParams in pairs(multinoiseParams) do
|
||||||
noises[noiseName] = core.get_value_noise(noiseParams)
|
multinoise[noiseName] = core.get_value_noise(noiseParams)
|
||||||
end
|
end
|
||||||
|
|
||||||
return noises
|
return multinoise
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param minPos table
|
---@param minPos table
|
||||||
---@param maxPos table
|
---@param maxPos table
|
||||||
---@param noisesParams MapGen.Region.Noises
|
---@param multinoiseParams MapGen.Region.MultinoiseParams
|
||||||
---@return MapGen.Region
|
---@return MapGen.Region
|
||||||
function Region:new(minPos, maxPos, noisesParams)
|
function Region:new(minPos, maxPos, multinoiseParams)
|
||||||
|
|
||||||
local _minPos = minPos
|
local _minPos = minPos
|
||||||
local _maxPos = maxPos
|
local _maxPos = maxPos
|
||||||
local _noisesParams = noisesParams
|
local _multinoiseParams = multinoiseParams
|
||||||
|
|
||||||
local _noises = {}
|
local _multinoise = {}
|
||||||
|
|
||||||
local instance = setmetatable({}, {__index = self})
|
local instance = setmetatable({}, {__index = self})
|
||||||
|
|
||||||
function instance:getMinPos() return _minPos end
|
function instance:getMinPos()
|
||||||
function instance:getMaxPos() return _maxPos end
|
return _minPos
|
||||||
function instance:getNoisesParams() return _noisesParams end
|
end
|
||||||
function instance:getNoises() return _noises end
|
function instance:getMaxPos()
|
||||||
|
return _maxPos
|
||||||
|
end
|
||||||
|
function instance:getMultinoiseParams()
|
||||||
|
return _multinoiseParams
|
||||||
|
end
|
||||||
|
function instance:getMultinoise()
|
||||||
|
return _multinoise
|
||||||
|
end
|
||||||
|
|
||||||
function instance:initNoises()
|
function instance:initMultinoise()
|
||||||
_noises = paramsToNoises(_noisesParams)
|
_multinoise = multinoiseParamsToMultinoise(_multinoiseParams)
|
||||||
end
|
end
|
||||||
|
|
||||||
return instance
|
return instance
|
||||||
|
|||||||
@@ -1,8 +0,0 @@
|
|||||||
---Only for EmmyLua
|
|
||||||
---@class MapGen.Region.Noises
|
|
||||||
---@field landscapeNoise table?
|
|
||||||
---@field tempNoise table?
|
|
||||||
---@field humidityNoise table?
|
|
||||||
local Noises = {}
|
|
||||||
|
|
||||||
return Noises
|
|
||||||
9
mods/CORE/MapGen/src/MapGen/Region/Trinoise.lua
Normal file
9
mods/CORE/MapGen/src/MapGen/Region/Trinoise.lua
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
---For EmmyLua only
|
||||||
|
|
||||||
|
---@class MapGen.Region.Multinoise
|
||||||
|
---@field landscapeNoise ValueNoise? -- TODO: describe ValueNoise class from Luanti (push Alek)
|
||||||
|
---@field tempNoise ValueNoise?
|
||||||
|
---@field humidityNoise ValueNoise?
|
||||||
|
local Multinoise = {}
|
||||||
|
|
||||||
|
return Multinoise
|
||||||
19
mods/CORE/MapGen/src/MapGen/Region/TrinoiseParams.lua
Normal file
19
mods/CORE/MapGen/src/MapGen/Region/TrinoiseParams.lua
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
---For EmmyLua only
|
||||||
|
|
||||||
|
---@class MapGen.Region.NoiseParams
|
||||||
|
---@field offset number
|
||||||
|
---@field scale number
|
||||||
|
---@field spread vector -- TODO: describe vector class from Luanti (push Alek)
|
||||||
|
---@field seed number
|
||||||
|
---@field octaves number
|
||||||
|
---@field persistence number
|
||||||
|
---@field lacunarity number
|
||||||
|
---@field flags string?
|
||||||
|
|
||||||
|
---@class MapGen.Region.MultinoiseParams
|
||||||
|
---@field landscapeNoiseParams MapGen.Region.NoiseParams?
|
||||||
|
---@field tempNoiseParams MapGen.Region.NoiseParams?
|
||||||
|
---@field humidityNoiseParams MapGen.Region.NoiseParams?
|
||||||
|
local MultinoiseParams = {}
|
||||||
|
|
||||||
|
return MultinoiseParams
|
||||||
Reference in New Issue
Block a user