MapGen: remove unnecessary code

This commit is contained in:
Van
2026-01-12 18:43:09 +03:00
parent 8640e55415
commit d0eba35e8d

View File

@@ -266,8 +266,6 @@ function MapGen:register2DPeaksFromFile(layerName, map, scale,zeroPos, category,
groups = groups, groups = groups,
} }
print(peakPos.x, peakPos.y)
self:register2DPeak(layerName, category, def) self:register2DPeak(layerName, category, def)
end end
end end
@@ -556,48 +554,6 @@ local function calcNoise2dValue(category, layer, triangle, x, y, z)
return (noiseValue / totalWeight) return (noiseValue / totalWeight)
end end
--[[
---Returns the weighted values of 2d noises.
---@param triangle MapGen.Triangle
---@param x number
---@param y number
---@param z number
---@return number, number, number
local function calcNoises2dValues(triangle, x, y, z)
local peak1 = triangle.p1
local peak2 = triangle.p2
local peak3 = triangle.p3
local noiseHeightValue = 0.0
local noiseTempValue = 0.0
local noiseHumidityValue = 0.0
local totalWeight = 0.0
-- We calculate the noise value using the smoothing formula:
-- ( peak1 * weight1 + peak2 * weight2 + peak3 * weight3) / totalWeight, when
-- totalWeight = weight1 + weight2 + weight3
local weight = calcWeight(triangle.h1, x, y, z)
noiseHeightValue = noiseHeightValue + peak1:getMultinoise().landscapeNoise:get_2d({x = x, y = z}) * weight
noiseTempValue = noiseTempValue + peak1:getMultinoise().tempNoise:get_2d({x = x, y = z}) * weight
noiseHumidityValue = noiseHumidityValue + peak1:getMultinoise().humidityNoise:get_2d({x = x, y = z}) * weight
totalWeight = totalWeight + weight
weight = calcWeight(triangle.h2, x, y, z)
noiseHeightValue = noiseHeightValue + peak2:getMultinoise().landscapeNoise:get_2d({x = x, y = z}) * weight
noiseTempValue = noiseTempValue + peak2:getMultinoise().tempNoise:get_2d({x = x, y = z}) * weight
noiseHumidityValue = noiseHumidityValue + peak2:getMultinoise().humidityNoise:get_2d({x = x, y = z}) * weight
totalWeight = totalWeight + weight
weight = calcWeight(triangle.h3, x, y, z)
noiseHeightValue = noiseHeightValue + peak3:getMultinoise().landscapeNoise:get_2d({x = x, y = z}) * weight
noiseTempValue = noiseTempValue + peak3:getMultinoise().tempNoise:get_2d({x = x, y = z}) * weight
noiseHumidityValue = noiseHumidityValue + peak3:getMultinoise().humidityNoise:get_2d({x = x, y = z}) * weight
totalWeight = totalWeight + weight
return noiseHeightValue / totalWeight, noiseTempValue / totalWeight, noiseHumidityValue / totalWeight
end--]]
---Calculates a smoothed 2D noise value based on a preliminary space partitioning. ---Calculates a smoothed 2D noise value based on a preliminary space partitioning.
--- ---
---Returns `nil` if the point is not included in any triangle. ---Returns `nil` if the point is not included in any triangle.
@@ -644,62 +600,6 @@ function MapGen:getNoises2dValue(category, layer, x, y, z)
--core.log('warning', string.format('The point %s %s %s does not fall within any triangle, calculating the noise value is impossible.', tostring(x), tostring(y), tostring(z))) --core.log('warning', string.format('The point %s %s %s does not fall within any triangle, calculating the noise value is impossible.', tostring(x), tostring(y), tostring(z)))
end end
--[[
---Calculates a smoothed 2D noise value based on a preliminary space partitioning.
---
---Returns `nil` if the point is not included in any triangle.
---@param layer MapGen.Layer
---@param x number
---@param y number
---@param z number
---@return number?, number?, number?
function MapGen:getNoises2dValues(layer, x, y, z)
if (pastNoise2DCalc.x ~= nil and pastNoise2DCalc.z ~= nil) and (x == pastNoise2DCalc.x and z == pastNoise2DCalc.z) then
return pastNoise2DCalc.noiseValues.height, pastNoise2DCalc.noiseValues.temp, pastNoise2DCalc.noiseValues.humidity
end
if pastNoise2DCalc.triangle ~= nil and pointInTriangle(x, z, pastNoise2DCalc.triangle) then
local noiseHeightValue, noiseTempValue, noiseHumidityValue = calcNoises2dValues(pastNoise2DCalc.triangle, x, y, z)
noiseTempValue, noiseHumidityValue = layer:calcTemp(noiseTempValue, y), layer:calcHumidity(noiseHumidityValue, y)
pastNoise2DCalc.x = x
pastNoise2DCalc.z = z
pastNoise2DCalc.noiseValues = {
height = noiseHeightValue,
temp = noiseTempValue,
humidity = noiseHumidityValue,
}
return noiseHeightValue, noiseTempValue, noiseHumidityValue
end
---@param triangle MapGen.Triangle
for _, triangle in ipairs(layer.trianglesList) do
if pointInTriangle(x, z,triangle) then
local noiseHeightValue, noiseTempValue, noiseHumidityValue = calcNoises2dValues(triangle, x, y, z)
noiseTempValue, noiseHumidityValue = layer:calcTemp(noiseTempValue, y), layer:calcHumidity(noiseHumidityValue, y)
pastNoise2DCalc.triangle = triangle
pastNoise2DCalc.x = x
pastNoise2DCalc.z = z
pastNoise2DCalc.noiseValues = {
height = noiseHeightValue,
temp = noiseTempValue,
humidity = noiseHumidityValue,
}
return noiseHeightValue, noiseTempValue, noiseHumidityValue
end
end
-- If the point does not fall within the triangle, it is impossible to calculate the height.
-- For debugging purposes only, may slow down generation:
--core.log('warning', string.format('The point %s %s %s does not fall within any triangle, calculating the noise value is impossible.', tostring(x), tostring(y), tostring(z)))
end
--]]
--[[ --[[
3D noise smoothing is too slow, so it was decided to stop using it. 3D noise smoothing is too slow, so it was decided to stop using it.
@@ -825,8 +725,6 @@ local function generatorHandler(mapGenerator, data, index, x, y, z)
noiseTempValue = layer:calcTemp(noiseTempValue, y) noiseTempValue = layer:calcTemp(noiseTempValue, y)
noiseHumidityValue = layer:calcHumidity(noiseHumidityValue, y) noiseHumidityValue = layer:calcHumidity(noiseHumidityValue, y)
--print(noiseHeightValue, noiseTempValue, noiseHumidityValue)
generateNode(mapGenerator, layer, noiseHeightValue, noiseTempValue, noiseHumidityValue, data, index, x, y, z) generateNode(mapGenerator, layer, noiseHeightValue, noiseTempValue, noiseHumidityValue, data, index, x, y, z)
end end