Compare commits
5 Commits
b646a8e3e3
...
907230e67d
| Author | SHA1 | Date | |
|---|---|---|---|
| 907230e67d | |||
| 03ce7983eb | |||
| e81e2141a6 | |||
| 3d0a906a59 | |||
| 18dbce95c0 |
@@ -5,9 +5,9 @@ local mathAbs, mathRound, mathMin, mathMax, id
|
||||
local pastCalcNoiseValue = {
|
||||
---@type MapGen.Triangle?
|
||||
triangle = nil,
|
||||
---@type number?
|
||||
---@type integer?
|
||||
x = nil,
|
||||
---@type number?
|
||||
---@type integer?
|
||||
z = nil,
|
||||
---@type number?
|
||||
noiseValue = nil,
|
||||
@@ -353,9 +353,9 @@ end
|
||||
|
||||
---Returns `true` if there is a cavern at the specified coordinates.
|
||||
---@param layer MapGen.Layer
|
||||
---@param x number
|
||||
---@param y number
|
||||
---@param z number
|
||||
---@param x integer
|
||||
---@param y integer
|
||||
---@param z integer
|
||||
---@return boolean
|
||||
local function isCavern(layer, x, y, z)
|
||||
for _, cavern in ipairs(layer.cavernsList) do
|
||||
@@ -376,9 +376,9 @@ end
|
||||
---@param humidity number
|
||||
---@param data number[]
|
||||
---@param index number
|
||||
---@param x number
|
||||
---@param y number
|
||||
---@param z number
|
||||
---@param x integer
|
||||
---@param y integer
|
||||
---@param z integer
|
||||
local function generateNode(mapGenerator, layer, height, temp, humidity, data, index, x, y, z)
|
||||
local ids = mapGenerator.nodeIDs
|
||||
local waterLevel = layer.waterLevel
|
||||
@@ -388,6 +388,7 @@ local function generateNode(mapGenerator, layer, height, temp, humidity, data, i
|
||||
local scatteringVertical = layer.biomesVerticalScattering or 0
|
||||
local scattTemp = temp
|
||||
local scattHumidity = humidity
|
||||
---@type number
|
||||
local scattHeight = y
|
||||
|
||||
if scatteringGorizontal ~= 0 then
|
||||
@@ -467,9 +468,9 @@ end
|
||||
---the triangle's height and specifying the distance to the peak
|
||||
---for which the weight is calculated.
|
||||
---@param height MapGen.Triangulation.Edge
|
||||
---@param x number
|
||||
---@param y number
|
||||
---@param z number
|
||||
---@param x integer
|
||||
---@param y integer
|
||||
---@param z integer
|
||||
---@return number
|
||||
local function calcWeight(height, x, y, z)
|
||||
local pos1 = vector.new(x, y, z)
|
||||
@@ -491,8 +492,8 @@ end
|
||||
|
||||
---Returns `true` if the point is within the triangle's region.
|
||||
---The barycentric coordinate method is used.
|
||||
---@param px number
|
||||
---@param pz number
|
||||
---@param px integer
|
||||
---@param pz integer
|
||||
---@param triangle MapGen.Triangle
|
||||
local function pointInTriangle(px, pz, triangle)
|
||||
local posP = vector.new(px, 0, pz)
|
||||
@@ -521,9 +522,9 @@ end
|
||||
---@param category MapGen.Layer.Category
|
||||
---@param layer MapGen.Layer
|
||||
---@param triangle MapGen.Triangle
|
||||
---@param x number
|
||||
---@param y number
|
||||
---@param z number
|
||||
---@param x integer
|
||||
---@param y integer
|
||||
---@param z integer
|
||||
---@return number
|
||||
local function calcNoise2dValue(category, layer, triangle, x, y, z)
|
||||
local peak1 = triangle.p1
|
||||
@@ -561,9 +562,9 @@ end
|
||||
---Returns `nil` if the point is not included in any triangle.
|
||||
---@param category MapGen.Layer.Category
|
||||
---@param layer MapGen.Layer
|
||||
---@param x number
|
||||
---@param y number
|
||||
---@param z number
|
||||
---@param x integer
|
||||
---@param y integer
|
||||
---@param z integer
|
||||
---@return number?
|
||||
function MapGen:getNoises2dValue(category, layer, x, y, z)
|
||||
---@type MapGen.PastCalcNoiseValue
|
||||
@@ -696,9 +697,9 @@ end
|
||||
---@param mapGenerator MapGen
|
||||
---@param data number[]
|
||||
---@param index number
|
||||
---@param x number
|
||||
---@param y number
|
||||
---@param z number
|
||||
---@param x integer
|
||||
---@param y integer
|
||||
---@param z integer
|
||||
local function generatorHandler(mapGenerator, data, index, x, y, z)
|
||||
-- If the node belongs to a static layer, then a static node is generated.
|
||||
local static = mapGenerator:getStaticByHeight(y)
|
||||
@@ -732,8 +733,8 @@ end
|
||||
|
||||
---Chunk generation handler.
|
||||
---@param voxelManip VoxelManip
|
||||
---@param minPos table
|
||||
---@param maxPos table
|
||||
---@param minPos Position
|
||||
---@param maxPos Position
|
||||
---@param blockseed number
|
||||
function MapGen:onMapGenerated(voxelManip, minPos, maxPos, blockseed)
|
||||
-- We obtain a generation area for further manipulations
|
||||
@@ -795,6 +796,7 @@ function MapGen:run()
|
||||
error('Only one instance of a `MapGen` class can be running.')
|
||||
end
|
||||
|
||||
---@param ... VoxelManip
|
||||
core.register_on_generated(function(...)
|
||||
self:onMapGenerated(...)
|
||||
end)
|
||||
|
||||
@@ -90,9 +90,9 @@ local function calcCavernWeight(y, smoothDistance, minY, maxY)
|
||||
end
|
||||
|
||||
---Returns `true` if there is a cavern at the specified coordinates.
|
||||
---@param x number
|
||||
---@param y number
|
||||
---@param z number
|
||||
---@param x integer
|
||||
---@param y integer
|
||||
---@param z integer
|
||||
---@return boolean
|
||||
function Cavern:isCavern(x, y, z)
|
||||
local minY, maxY = self.minY, self.maxY
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
---@class MapGen.Layer
|
||||
---@field name string
|
||||
---@field minY number
|
||||
---@field maxY number
|
||||
---@field minTemp number
|
||||
---@field maxTemp number
|
||||
---@field minHumidity number
|
||||
---@field maxHumidity number
|
||||
---@field waterLevel number
|
||||
---@field minY integer
|
||||
---@field maxY integer
|
||||
---@field minTemp integer
|
||||
---@field maxTemp integer
|
||||
---@field minHumidity integer
|
||||
---@field maxHumidity integer
|
||||
---@field waterLevel integer
|
||||
---@field calcTemp fun(self:MapGen.Layer, value:number, height:number):number
|
||||
---@field calcHumidity fun(self:MapGen.Layer, value:number, height:number):number
|
||||
---@field peaksList {['landscape']:MapGen.Peak[],['temp']:MapGen.Peak[],['humidity']:MapGen.Peak[]}
|
||||
@@ -15,8 +15,8 @@
|
||||
---@field biomesByName table<string, MapGen.Biome>
|
||||
---@field biomesList MapGen.Biome[]
|
||||
---@field biomesDiagram table
|
||||
---@field biomesGorizontalScattering number
|
||||
---@field biomesVerticalScattering number
|
||||
---@field biomesGorizontalScattering integer
|
||||
---@field biomesVerticalScattering integer
|
||||
---@field cavernsByName table<string, MapGen.Cavern>
|
||||
---@field cavernsList MapGen.Cavern[]
|
||||
---@field trianglesList {['landscape']:MapGen.Triangle[],['temp']:MapGen.Triangle[],['humidity']:MapGen.Triangle[]}
|
||||
@@ -130,7 +130,7 @@ end
|
||||
---@param color ColorString
|
||||
---@param noiseParams NoiseParams
|
||||
function Layer:addNoiseParamsColor(category, color, noiseParams)
|
||||
color = core.colorspec_to_colorstring(core.colorspec_to_table(color))
|
||||
color = Smc.fixColorString(color)
|
||||
|
||||
local noisesParams = self.noisesParamsByColor
|
||||
|
||||
@@ -153,7 +153,7 @@ end
|
||||
---@param color ColorString
|
||||
---@return ValueNoise
|
||||
function Layer:getNoiseByColor(category, color)
|
||||
color = core.colorspec_to_colorstring(core.colorspec_to_table(color))
|
||||
color = Smc.fixColorString(color)
|
||||
|
||||
local noises = self.noisesByColor
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ local function ff2luat(filepath, backgroundColor)
|
||||
|
||||
if not backgroundColor then backgroundColor = '#000000FF' end
|
||||
--HACK: normalizing colorstring for future string comparison ('#000' -> '#000000FF')
|
||||
backgroundColor = core.colorspec_to_colorstring(core.colorspec_to_table(backgroundColor))
|
||||
backgroundColor = Smc.fixColorString(backgroundColor)
|
||||
|
||||
---@type ColoredDotsTable
|
||||
local dots = { size = { w = uintb2num(ff:sub(9,12)), h = uintb2num(ff:sub(13,16)) } }
|
||||
@@ -83,7 +83,7 @@ local function ff2luat(filepath, backgroundColor)
|
||||
}
|
||||
|
||||
---@type string @ColorString
|
||||
local color = core.colorspec_to_colorstring(colorT)
|
||||
local color = core.colorspec_to_colorstring(colorT) or ''
|
||||
|
||||
if color ~= backgroundColor then
|
||||
if not dots[color] then
|
||||
|
||||
@@ -3,4 +3,23 @@ Smc = {}
|
||||
local modInfo = Mod.getInfo('smc__system__helper_lib')
|
||||
local require = modInfo.require
|
||||
|
||||
---Converts a colorstring into a single representation so that similar colors can match.
|
||||
---@param color ColorString
|
||||
---@return ColorString
|
||||
function Smc.fixColorString(color)
|
||||
local colorTable = core.colorspec_to_table(color)
|
||||
|
||||
if colorTable == nil then
|
||||
return ''
|
||||
end
|
||||
|
||||
local colorString = core.colorspec_to_colorstring(colorTable)
|
||||
|
||||
if colorString == nil then
|
||||
return ''
|
||||
end
|
||||
|
||||
return colorString
|
||||
end
|
||||
|
||||
require('Lib.globalStep')
|
||||
|
||||
@@ -4,6 +4,7 @@ local math = math
|
||||
---@param value number The value to be limited.
|
||||
---@param min number Minimum limit.
|
||||
---@param max number Maximum limit.
|
||||
---@return number
|
||||
math.clamp = function(value, min, max)
|
||||
return math.min(math.max(value, min), max)
|
||||
end
|
||||
@@ -12,6 +13,7 @@ end
|
||||
---@param a number Minimum value.
|
||||
---@param b number Maximum value.
|
||||
---@param t number Number in range [0, 1].
|
||||
---@return number
|
||||
math.lerp = function (a, b, t)
|
||||
t = math.clamp(t, 0, 1)
|
||||
|
||||
|
||||
Submodule util/ide-helper updated: 138ceae165...096c706f79
Reference in New Issue
Block a user