MapGen: add post-processing generation in biomes. Close #30
This commit is contained in:
@@ -6,6 +6,8 @@ local getInstance = Class.getInstance
|
|||||||
local modInfo = Mod.getInfo('smc__core__map_gen')
|
local modInfo = Mod.getInfo('smc__core__map_gen')
|
||||||
local require = modInfo.require
|
local require = modInfo.require
|
||||||
|
|
||||||
|
---@alias MapGen.factors {height:number, temp:number, humidity:number}
|
||||||
|
|
||||||
---@alias MapGen.PastCalcNoiseValue {triangle:MapGen.Triangle?, x:integer?, z:integer?, noiseValue:number?}
|
---@alias MapGen.PastCalcNoiseValue {triangle:MapGen.Triangle?, x:integer?, z:integer?, noiseValue:number?}
|
||||||
|
|
||||||
---@type table<MapGen.Layer.Category, MapGen.PastCalcNoiseValue>
|
---@type table<MapGen.Layer.Category, MapGen.PastCalcNoiseValue>
|
||||||
@@ -649,26 +651,58 @@ end
|
|||||||
|
|
||||||
-- --- GENERATION METHODS ---
|
-- --- GENERATION METHODS ---
|
||||||
|
|
||||||
---The core logic of world generation. Determines which node type (water, rock, soil, air)
|
---@alias MapGen.nodeType 'AIR'|'WATER'|'CAVERN_AIR'|'TURF'|'SOIL'|'ROCK'|'BOTTOM'
|
||||||
---and which biome will be generated at the specified coordinates.
|
---@alias MapGen.postProcessingData {biome:MapGen.Biome, mapGenerator:MapGen, factors:MapGen.factors, data:number[], index:number, x:number, y:number, z:number, nodeType:MapGen.nodeType}
|
||||||
|
|
||||||
|
---@type table<number, MapGen.postProcessingData>
|
||||||
|
local postProcessing = {}
|
||||||
|
|
||||||
|
---@param biome MapGen.Biome
|
||||||
---@param mapGenerator MapGen
|
---@param mapGenerator MapGen
|
||||||
---@param layer MapGen.Layer
|
---@param factors MapGen.factors
|
||||||
---@param height number
|
|
||||||
---@param temp number
|
|
||||||
---@param humidity number
|
|
||||||
---@param data number[]
|
---@param data number[]
|
||||||
---@param index number
|
---@param index number
|
||||||
---@param x integer
|
---@param x integer
|
||||||
---@param y integer
|
---@param y integer
|
||||||
---@param z integer
|
---@param z integer
|
||||||
local function generateNode(mapGenerator, layer, height, temp, humidity, data, index, x, y, z)
|
---@param nodeType MapGen.nodeType
|
||||||
|
local function addPostProccessing(biome, mapGenerator, factors, data, index, x, y, z, nodeType)
|
||||||
|
if biome.postProcessing == nil then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
postProcessing[index] = {
|
||||||
|
biome = biome,
|
||||||
|
mapGenerator = mapGenerator,
|
||||||
|
factors = factors,
|
||||||
|
data = data,
|
||||||
|
index = index,
|
||||||
|
x = x,
|
||||||
|
y = y,
|
||||||
|
z = z,
|
||||||
|
nodeType = nodeType
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
---The core logic of world generation. Determines which node type (water, rock, soil, air)
|
||||||
|
---and which biome will be generated at the specified coordinates.
|
||||||
|
---@param mapGenerator MapGen
|
||||||
|
---@param layer MapGen.Layer
|
||||||
|
---@param factors MapGen.factors
|
||||||
|
---@param data number[]
|
||||||
|
---@param index number
|
||||||
|
---@param x integer
|
||||||
|
---@param y integer
|
||||||
|
---@param z integer
|
||||||
|
local function generateNode(mapGenerator, layer, factors, data, index, x, y, z)
|
||||||
local ids = mapGenerator.nodeIDs
|
local ids = mapGenerator.nodeIDs
|
||||||
local waterLevel = layer.waterLevel
|
local waterLevel = layer.waterLevel
|
||||||
|
local height, temp, humidity = factors.height, factors.temp, factors.humidity
|
||||||
|
|
||||||
-- Creating a rougher biome boundary.
|
-- Creating a rougher biome boundary.
|
||||||
local scatteringGorizontal = layer.biomesGorizontalScattering or 0
|
local scatteringGorizontal = layer.biomesGorizontalScattering or 0
|
||||||
local scatteringVertical = layer.biomesVerticalScattering or 0
|
local scatteringVertical = layer.biomesVerticalScattering or 0
|
||||||
local scattTemp = temp
|
local scattTemp = factors.temp
|
||||||
local scattHumidity = humidity
|
local scattHumidity = humidity
|
||||||
---@type number
|
---@type number
|
||||||
local scattHeight = y
|
local scattHeight = y
|
||||||
@@ -695,33 +729,39 @@ local function generateNode(mapGenerator, layer, height, temp, humidity, data, i
|
|||||||
-- If the block is above surface height and above water level...
|
-- If the block is above surface height and above water level...
|
||||||
if y > height and y > waterLevel then
|
if y > height and y > waterLevel then
|
||||||
-- ... then airspace is generated.
|
-- ... then airspace is generated.
|
||||||
biome:generateAir(mapGenerator, data, index, x, y, z)
|
biome:generateAir(mapGenerator, factors, data, index, x, y, z)
|
||||||
|
addPostProccessing(biome, mapGenerator, factors, data, index, x, y, z, 'AIR')
|
||||||
|
|
||||||
-- If the block is above the surface height BUT below the water level...
|
-- If the block is above the surface height BUT below the water level...
|
||||||
elseif y > height and y <= waterLevel then
|
elseif y > height and y <= waterLevel then
|
||||||
-- ... then underwater space is generated.
|
-- ... then underwater space is generated.
|
||||||
biome:generateWater(mapGenerator, data, index, x, y, z)
|
biome:generateWater(mapGenerator, factors, data, index, x, y, z)
|
||||||
|
addPostProccessing(biome, mapGenerator, factors, data, index, x, y, z, 'WATER')
|
||||||
|
|
||||||
-- If the block is below the surface height...
|
-- If the block is below the surface height...
|
||||||
elseif y <= height then
|
elseif y <= height then
|
||||||
-- ... and a cavern is generated in the block...
|
-- ... and a cavern is generated in the block...
|
||||||
if mapGenerator:isCavern(layer, x, y, z) then
|
if mapGenerator:isCavern(layer, x, y, z) then
|
||||||
-- ... then airspace is generated.
|
-- ... then airspace is generated.
|
||||||
biome:generateCavernAir(mapGenerator, data, index, x, y, z)
|
biome:generateCavernAir(mapGenerator, factors, data, index, x, y, z)
|
||||||
|
addPostProccessing(biome, mapGenerator, factors, data, index, x, y, z, 'CAVERN_AIR')
|
||||||
|
|
||||||
-- ... or if the surface height is above the water level...
|
-- ... or if the surface height is above the water level...
|
||||||
elseif height > waterLevel then
|
elseif height > waterLevel then
|
||||||
--- ... and the height of the block is equal to the height of the surface...
|
--- ... and the height of the block is equal to the height of the surface...
|
||||||
if y == height then
|
if y == height then
|
||||||
-- ... then turf is generated.
|
-- ... then turf is generated.
|
||||||
biome:generateTurf(mapGenerator, data, index, x, y, z)
|
biome:generateTurf(mapGenerator, factors, data, index, x, y, z)
|
||||||
|
addPostProccessing(biome, mapGenerator, factors, data, index, x, y, z, 'TURF')
|
||||||
-- ... or if the height of the block falls within the thickness of the soil layer...
|
-- ... or if the height of the block falls within the thickness of the soil layer...
|
||||||
elseif y > height - biome.soilHeight then
|
elseif y > height - biome.soilHeight then
|
||||||
-- ... then soil is generated.
|
-- ... then soil is generated.
|
||||||
biome:generateSoil(mapGenerator, data, index, x, y, z)
|
biome:generateSoil(mapGenerator, factors, data, index, x, y, z)
|
||||||
|
addPostProccessing(biome, mapGenerator, factors, data, index, x, y, z, 'SOIL')
|
||||||
else
|
else
|
||||||
-- ... else e a stone is generated.
|
-- ... else a stone is generated.
|
||||||
biome:generateRock(mapGenerator, data, index, x, y, z)
|
biome:generateRock(mapGenerator, factors, data, index, x, y, z)
|
||||||
|
addPostProccessing(biome, mapGenerator, factors, data, index, x, y, z, 'ROCK')
|
||||||
end
|
end
|
||||||
|
|
||||||
-- ... or if the surface height is below the water level...
|
-- ... or if the surface height is below the water level...
|
||||||
@@ -729,10 +769,12 @@ local function generateNode(mapGenerator, layer, height, temp, humidity, data, i
|
|||||||
-- ... and if the height of the block falls within the thickness of the soil layer...
|
-- ... and if the height of the block falls within the thickness of the soil layer...
|
||||||
if y > height - biome.soilHeight then
|
if y > height - biome.soilHeight then
|
||||||
-- ... then the river/ocean bottom is generated.
|
-- ... then the river/ocean bottom is generated.
|
||||||
biome:generateBottom(mapGenerator, data, index, x, y, z)
|
biome:generateBottom(mapGenerator, factors, data, index, x, y, z)
|
||||||
|
addPostProccessing(biome, mapGenerator, factors, data, index, x, y, z, 'BOTTOM')
|
||||||
else
|
else
|
||||||
-- ... else a stone is generated.
|
-- ... else a stone is generated.
|
||||||
biome:generateRock(mapGenerator, data, index, x, y, z)
|
biome:generateRock(mapGenerator, factors, data, index, x, y, z)
|
||||||
|
addPostProccessing(biome, mapGenerator, factors, data, index, x, y, z, 'ROCK')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@@ -1019,7 +1061,14 @@ 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)
|
||||||
|
|
||||||
generateNode(mapGenerator, layer, noiseHeightValue, noiseTempValue, noiseHumidityValue, data, index, x, y, z)
|
---@type MapGen.factors
|
||||||
|
local factors = {
|
||||||
|
height = noiseHeightValue,
|
||||||
|
temp = noiseTempValue,
|
||||||
|
humidity = noiseHumidityValue,
|
||||||
|
}
|
||||||
|
|
||||||
|
generateNode(mapGenerator, layer, factors, data, index, x, y, z)
|
||||||
end
|
end
|
||||||
|
|
||||||
---Chunk generation handler.
|
---Chunk generation handler.
|
||||||
@@ -1059,6 +1108,21 @@ function MapGen:onMapGenerated(voxelManip, minPos, maxPos, blockseed)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Post-proccesing generation
|
||||||
|
for _, ppdata in pairs(postProcessing) do
|
||||||
|
if ppdata.biome.postProcessing ~= nil then
|
||||||
|
ppdata.biome:postProcessing(ppdata.mapGenerator,
|
||||||
|
ppdata.factors,
|
||||||
|
ppdata.data,
|
||||||
|
ppdata.index,
|
||||||
|
ppdata.x,
|
||||||
|
ppdata.y,
|
||||||
|
ppdata.z,
|
||||||
|
ppdata.nodeType,
|
||||||
|
area)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- We make changes back to LVM and recalculate light & liquids
|
-- We make changes back to LVM and recalculate light & liquids
|
||||||
voxelManip:set_data(data)
|
voxelManip:set_data(data)
|
||||||
|
|
||||||
|
|||||||
@@ -18,9 +18,10 @@ local getInstance = Class.getInstance
|
|||||||
---@field generateTurf generateFunc
|
---@field generateTurf generateFunc
|
||||||
---@field generateSoil generateFunc
|
---@field generateSoil generateFunc
|
||||||
---@field generateBottom generateFunc
|
---@field generateBottom generateFunc
|
||||||
|
---@field postProcessing fun(self, mapGenerator:MapGen, factors:MapGen.factors, data:number[], index:number, x:number, y:number, z:number, nodeType:MapGen.nodeType, area:VoxelArea)?
|
||||||
local Biome = {}
|
local Biome = {}
|
||||||
|
|
||||||
---@alias generateFunc fun(self, mapGenerator:MapGen, data:number[], index:number, x:number, y:number, z:number)
|
---@alias generateFunc fun(self, mapGenerator:MapGen, factors:MapGen.factors, data:number[], index:number, x:number, y:number, z:number)
|
||||||
|
|
||||||
---Definition table for the `MapGen.Biome`.
|
---Definition table for the `MapGen.Biome`.
|
||||||
---
|
---
|
||||||
@@ -39,84 +40,91 @@ local Biome = {}
|
|||||||
---@field generateTurf generateFunc?
|
---@field generateTurf generateFunc?
|
||||||
---@field generateSoil generateFunc?
|
---@field generateSoil generateFunc?
|
||||||
---@field generateBottom generateFunc?
|
---@field generateBottom generateFunc?
|
||||||
|
---@field postProcessing fun(self, mapGenerator:MapGen, factors:MapGen.factors, data:number[], index:number, x:number, y:number, z:number, nodeType:MapGen.nodeType, area:VoxelArea)?
|
||||||
|
|
||||||
-- Default generate functions
|
-- Default generate functions
|
||||||
|
|
||||||
---@param self MapGen.Biome
|
---@param self MapGen.Biome
|
||||||
---@param mapGenerator MapGen
|
---@param mapGenerator MapGen
|
||||||
|
---@param factors MapGen.factors
|
||||||
---@param data number[]
|
---@param data number[]
|
||||||
---@param index number
|
---@param index number
|
||||||
---@param x number
|
---@param x number
|
||||||
---@param y number
|
---@param y number
|
||||||
---@param z number
|
---@param z number
|
||||||
local defaultGenerateAir = function(self, mapGenerator, data, index, x, y, z)
|
local defaultGenerateAir = function(self, mapGenerator, factors, data, index, x, y, z)
|
||||||
data[index] = mapGenerator.nodeIDs.air
|
data[index] = mapGenerator.nodeIDs.air
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param self MapGen.Biome
|
---@param self MapGen.Biome
|
||||||
---@param mapGenerator MapGen
|
---@param mapGenerator MapGen
|
||||||
|
---@param factors MapGen.factors
|
||||||
---@param data number[]
|
---@param data number[]
|
||||||
---@param index number
|
---@param index number
|
||||||
---@param x number
|
---@param x number
|
||||||
---@param y number
|
---@param y number
|
||||||
---@param z number
|
---@param z number
|
||||||
local defaultGenerateCavernAir = function(self, mapGenerator, data, index, x, y, z)
|
local defaultGenerateCavernAir = function(self, mapGenerator, factors, data, index, x, y, z)
|
||||||
self:generateAir(mapGenerator, data, index, x, y, z)
|
self:generateAir(mapGenerator, factors, data, index, x, y, z)
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param self MapGen.Biome
|
---@param self MapGen.Biome
|
||||||
---@param mapGenerator MapGen
|
---@param mapGenerator MapGen
|
||||||
|
---@param factors MapGen.factors
|
||||||
---@param data number[]
|
---@param data number[]
|
||||||
---@param index number
|
---@param index number
|
||||||
---@param x number
|
---@param x number
|
||||||
---@param y number
|
---@param y number
|
||||||
---@param z number
|
---@param z number
|
||||||
local defaultGenerateWater = function(self, mapGenerator, data, index, x, y, z)
|
local defaultGenerateWater = function(self, mapGenerator, factors, data, index, x, y, z)
|
||||||
data[index] = mapGenerator.nodeIDs.water
|
data[index] = mapGenerator.nodeIDs.water
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param self MapGen.Biome
|
---@param self MapGen.Biome
|
||||||
---@param mapGenerator MapGen
|
---@param mapGenerator MapGen
|
||||||
|
---@param factors MapGen.factors
|
||||||
---@param data number[]
|
---@param data number[]
|
||||||
---@param index number
|
---@param index number
|
||||||
---@param x number
|
---@param x number
|
||||||
---@param y number
|
---@param y number
|
||||||
---@param z number
|
---@param z number
|
||||||
local defaultGenerateRock = function(self, mapGenerator, data, index, x, y, z)
|
local defaultGenerateRock = function(self, mapGenerator, factors, data, index, x, y, z)
|
||||||
data[index] = self.groundNodesIDs.rock
|
data[index] = self.groundNodesIDs.rock
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param self MapGen.Biome
|
---@param self MapGen.Biome
|
||||||
---@param mapGenerator MapGen
|
---@param mapGenerator MapGen
|
||||||
|
---@param factors MapGen.factors
|
||||||
---@param data number[]
|
---@param data number[]
|
||||||
---@param index number
|
---@param index number
|
||||||
---@param x number
|
---@param x number
|
||||||
---@param y number
|
---@param y number
|
||||||
---@param z number
|
---@param z number
|
||||||
local defaultGenerateTurf = function(self, mapGenerator, data, index, x, y, z)
|
local defaultGenerateTurf = function(self, mapGenerator, factors, data, index, x, y, z)
|
||||||
data[index] = self.groundNodesIDs.turf
|
data[index] = self.groundNodesIDs.turf
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param self MapGen.Biome
|
---@param self MapGen.Biome
|
||||||
---@param mapGenerator MapGen
|
---@param mapGenerator MapGen
|
||||||
|
---@param factors MapGen.factors
|
||||||
---@param data number[]
|
---@param data number[]
|
||||||
---@param index number
|
---@param index number
|
||||||
---@param x number
|
---@param x number
|
||||||
---@param y number
|
---@param y number
|
||||||
---@param z number
|
---@param z number
|
||||||
local defaultGenerateSoil = function(self, mapGenerator,data, index, x, y, z)
|
local defaultGenerateSoil = function(self, mapGenerator, factors, data, index, x, y, z)
|
||||||
data[index] = self.groundNodesIDs.soil
|
data[index] = self.groundNodesIDs.soil
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param self MapGen.Biome
|
---@param self MapGen.Biome
|
||||||
---@param mapGenerator MapGen
|
---@param mapGenerator MapGen
|
||||||
|
---@param factors MapGen.factors
|
||||||
---@param data number[]
|
---@param data number[]
|
||||||
---@param index number
|
---@param index number
|
||||||
---@param x number
|
---@param x number
|
||||||
---@param y number
|
---@param y number
|
||||||
---@param z number
|
---@param z number
|
||||||
local defaultGenerateBottom = function(self, mapGenerator, data, index, x, y, z)
|
local defaultGenerateBottom = function(self, mapGenerator, factors, data, index, x, y, z)
|
||||||
data[index] = self.groundNodesIDs.bottom
|
data[index] = self.groundNodesIDs.bottom
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -167,23 +175,23 @@ function Biome:new(name, def)
|
|||||||
end
|
end
|
||||||
|
|
||||||
---@type MapGen.Biome
|
---@type MapGen.Biome
|
||||||
local instance = getInstance(self, {
|
local instance = getInstance(self, {})
|
||||||
name = name,
|
instance.name = name
|
||||||
tempPoint = def.tempPoint,
|
instance.tempPoint = def.tempPoint
|
||||||
humidityPoint = def.humidityPoint,
|
instance.humidityPoint = def.humidityPoint
|
||||||
minY = def.minY,
|
instance.minY = def.minY
|
||||||
maxY = def.maxY,
|
instance.maxY = def.maxY
|
||||||
groundNodes = def.groundNodes,
|
instance.groundNodes = def.groundNodes
|
||||||
groundNodesIDs = groundNodesIDs,
|
instance.groundNodesIDs = groundNodesIDs
|
||||||
soilHeight = def.soilHeight,
|
instance.soilHeight = def.soilHeight
|
||||||
generateAir = def.generateAir,
|
instance.generateAir = def.generateAir
|
||||||
generateCavernAir = def.generateCavernAir,
|
instance.generateCavernAir = def.generateCavernAir
|
||||||
generateWater = def.generateWater,
|
instance.generateWater = def.generateWater
|
||||||
generateRock = def.generateRock,
|
instance.generateRock = def.generateRock
|
||||||
generateSoil = def.generateSoil,
|
instance.generateSoil = def.generateSoil
|
||||||
generateTurf = def.generateTurf,
|
instance.generateTurf = def.generateTurf
|
||||||
generateBottom = def.generateBottom,
|
instance.generateBottom = def.generateBottom
|
||||||
})
|
instance.postProcessing = def.postProcessing
|
||||||
|
|
||||||
return instance
|
return instance
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ local getInstance = Class.getInstance
|
|||||||
---@field maxY number
|
---@field maxY number
|
||||||
---@field staticNode string
|
---@field staticNode string
|
||||||
---@field staticNodeID number
|
---@field staticNodeID number
|
||||||
---@field generateStaticNode generateFunc
|
---@field generateStaticNode fun(self, mapGenerator:MapGen, data:number[], index:number, x:number, y:number, z:number)
|
||||||
local StaticLayer = {}
|
local StaticLayer = {}
|
||||||
|
|
||||||
---Definition table for the `MapGen.StaticLayer`.
|
---Definition table for the `MapGen.StaticLayer`.
|
||||||
@@ -18,7 +18,7 @@ local StaticLayer = {}
|
|||||||
---@field minY number
|
---@field minY number
|
||||||
---@field maxY number
|
---@field maxY number
|
||||||
---@field staticNode string
|
---@field staticNode string
|
||||||
---@field generateStaticNode generateFunc
|
---@field generateStaticNode fun(self, mapGenerator:MapGen, data:number[], index:number, x:number, y:number, z:number)
|
||||||
|
|
||||||
---@param self MapGen.StaticLayer
|
---@param self MapGen.StaticLayer
|
||||||
---@param mapGenerator MapGen
|
---@param mapGenerator MapGen
|
||||||
|
|||||||
@@ -214,7 +214,7 @@ local rocksNoiseParams ={
|
|||||||
lacunarity = 4,
|
lacunarity = 4,
|
||||||
}
|
}
|
||||||
|
|
||||||
local function generateRock(biome, mapGenerator, data, index, x, y, z)
|
local function generateRock(biome, mapGenerator, factors, data, index, x, y, z)
|
||||||
local ids = mapGenerator.nodeIDs
|
local ids = mapGenerator.nodeIDs
|
||||||
|
|
||||||
if rocksNoise == nil then
|
if rocksNoise == nil then
|
||||||
@@ -249,7 +249,7 @@ local function generateRock(biome, mapGenerator, data, index, x, y, z)
|
|||||||
end
|
end
|
||||||
|
|
||||||
---@param biome MapGen.Biome
|
---@param biome MapGen.Biome
|
||||||
local function generateSoil(biome, mapGenerator, data, index, x, y, z)
|
local function generateSoil(biome, mapGenerator, factors, data, index, x, y, z)
|
||||||
local ids = mapGenerator.nodeIDs
|
local ids = mapGenerator.nodeIDs
|
||||||
if rocksNoise == nil then
|
if rocksNoise == nil then
|
||||||
rocksNoise = core.get_value_noise(rocksNoiseParams)
|
rocksNoise = core.get_value_noise(rocksNoiseParams)
|
||||||
@@ -269,7 +269,7 @@ local function generateSoil(biome, mapGenerator, data, index, x, y, z)
|
|||||||
end
|
end
|
||||||
|
|
||||||
---@param biome MapGen.Biome
|
---@param biome MapGen.Biome
|
||||||
local function generateTurf(biome, mapGenerator, data, index, x, y, z)
|
local function generateTurf(biome, mapGenerator, factors, data, index, x, y, z)
|
||||||
local ids = mapGenerator.nodeIDs
|
local ids = mapGenerator.nodeIDs
|
||||||
if rocksNoise == nil then
|
if rocksNoise == nil then
|
||||||
rocksNoise = core.get_value_noise(rocksNoiseParams)
|
rocksNoise = core.get_value_noise(rocksNoiseParams)
|
||||||
@@ -288,6 +288,22 @@ local function generateTurf(biome, mapGenerator, data, index, x, y, z)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---@param area VoxelArea
|
||||||
|
local function postProcessing(biome, mapGenerator, factors, data, index, x, y, z, nodeType, area)
|
||||||
|
local trufID = biome.groundNodesIDs.turf
|
||||||
|
local waterID = mapGenerator.nodeIDs.water
|
||||||
|
if data[index] ~= trufID then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
if (data[area:index(x+1, y, z)] == trufID or data[area:index(x+1, y, z)] == waterID) and
|
||||||
|
(data[area:index(x-1, y, z)] == trufID or data[area:index(x-1, y, z)] == waterID) and
|
||||||
|
(data[area:index(x, y, z+1)] == trufID or data[area:index(x, y, z+1)] == waterID) and
|
||||||
|
(data[area:index(x, y, z-1)] == trufID or data[area:index(x, y, z-1)] == waterID) then
|
||||||
|
data[index] = mapGenerator.nodeIDs.water
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
mapGenerator:registerBiome('midgard', 'swamp', {
|
mapGenerator:registerBiome('midgard', 'swamp', {
|
||||||
tempPoint = 0,
|
tempPoint = 0,
|
||||||
humidityPoint = 80,
|
humidityPoint = 80,
|
||||||
@@ -303,6 +319,7 @@ mapGenerator:registerBiome('midgard', 'swamp', {
|
|||||||
generateRock = generateRock,
|
generateRock = generateRock,
|
||||||
generateTurf = generateTurf,
|
generateTurf = generateTurf,
|
||||||
generateSoil = generateSoil,
|
generateSoil = generateSoil,
|
||||||
|
postProcessing = postProcessing
|
||||||
})
|
})
|
||||||
|
|
||||||
return mapGenerator
|
return mapGenerator
|
||||||
Reference in New Issue
Block a user