MapGen & mapGenerator: add param2_data
This commit is contained in:
@@ -551,7 +551,7 @@ end
|
||||
-- --- GENERATION METHODS ---
|
||||
|
||||
---@alias MapGen.nodeType 'AIR'|'WATER'|'CAVERN_AIR'|'TURF'|'SOIL'|'ROCK'|'BOTTOM'
|
||||
---@alias MapGen.postProcessingData {biome:MapGen.Biome, mapGenerator:MapGen, factors:MapGen.factors, data:number[], index:number, x:number, y:number, z:number, nodeType:MapGen.nodeType}
|
||||
---@alias MapGen.postProcessingData {biome:MapGen.Biome, mapGenerator:MapGen, factors:MapGen.factors, index:number, x:number, y:number, z:number, nodeType:MapGen.nodeType}
|
||||
|
||||
---@type table<number, MapGen.postProcessingData>
|
||||
local postProcessing = {}
|
||||
@@ -559,13 +559,12 @@ local postProcessing = {}
|
||||
---@param biome MapGen.Biome
|
||||
---@param mapGenerator MapGen
|
||||
---@param factors MapGen.factors
|
||||
---@param data number[]
|
||||
---@param index number
|
||||
---@param x integer
|
||||
---@param y integer
|
||||
---@param z integer
|
||||
---@param nodeType MapGen.nodeType
|
||||
local function addPostProccessing(biome, mapGenerator, factors, data, index, x, y, z, nodeType)
|
||||
local function addPostProccessing(biome, mapGenerator, factors, index, x, y, z, nodeType)
|
||||
if biome.postProcessing == nil then
|
||||
return
|
||||
end
|
||||
@@ -574,7 +573,6 @@ local function addPostProccessing(biome, mapGenerator, factors, data, index, x,
|
||||
biome = biome,
|
||||
mapGenerator = mapGenerator,
|
||||
factors = factors,
|
||||
data = data,
|
||||
index = index,
|
||||
x = x,
|
||||
y = y,
|
||||
@@ -589,11 +587,12 @@ end
|
||||
---@param layer MapGen.Layer
|
||||
---@param factors MapGen.factors
|
||||
---@param data number[]
|
||||
---@param data2 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 function generateNode(mapGenerator, layer, factors, data, data2, index, x, y, z)
|
||||
|
||||
local ids = mapGenerator.nodeIDs
|
||||
local waterLevel = layer.waterLevel
|
||||
@@ -629,39 +628,39 @@ local function generateNode(mapGenerator, layer, factors, data, index, x, y, z)
|
||||
-- If the block is above surface height and above water level...
|
||||
if y > height and y > waterLevel then
|
||||
-- ... then airspace is generated.
|
||||
biome:generateAir(mapGenerator, factors, data, index, x, y, z)
|
||||
addPostProccessing(biome, mapGenerator, factors, data, index, x, y, z, 'AIR')
|
||||
biome:generateAir(mapGenerator, factors, data, data2, index, x, y, z)
|
||||
addPostProccessing(biome, mapGenerator, factors, index, x, y, z, 'AIR')
|
||||
|
||||
-- If the block is above the surface height BUT below the water level...
|
||||
elseif y > height and y <= waterLevel then
|
||||
-- ... then underwater space is generated.
|
||||
biome:generateWater(mapGenerator, factors, data, index, x, y, z)
|
||||
addPostProccessing(biome, mapGenerator, factors, data, index, x, y, z, 'WATER')
|
||||
biome:generateWater(mapGenerator, factors, data, data2, index, x, y, z)
|
||||
addPostProccessing(biome, mapGenerator, factors, index, x, y, z, 'WATER')
|
||||
|
||||
-- If the block is below the surface height...
|
||||
elseif y <= height then
|
||||
-- ... and a cavern is generated in the block...
|
||||
if mapGenerator:isCavern(layer, x, y, z) then
|
||||
-- ... then airspace is generated.
|
||||
biome:generateCavernAir(mapGenerator, factors, data, index, x, y, z)
|
||||
addPostProccessing(biome, mapGenerator, factors, data, index, x, y, z, 'CAVERN_AIR')
|
||||
biome:generateCavernAir(mapGenerator, factors, data, data2, index, x, y, z)
|
||||
addPostProccessing(biome, mapGenerator, factors, index, x, y, z, 'CAVERN_AIR')
|
||||
|
||||
-- ... or if the surface height is above the water level...
|
||||
elseif height > waterLevel then
|
||||
--- ... and the height of the block is equal to the height of the surface...
|
||||
if y == height then
|
||||
-- ... then turf is generated.
|
||||
biome:generateTurf(mapGenerator, factors, data, index, x, y, z)
|
||||
addPostProccessing(biome, mapGenerator, factors, data, index, x, y, z, 'TURF')
|
||||
biome:generateTurf(mapGenerator, factors, data, data2, index, x, y, z)
|
||||
addPostProccessing(biome, mapGenerator, factors, index, x, y, z, 'TURF')
|
||||
-- ... or if the height of the block falls within the thickness of the soil layer...
|
||||
elseif y > height - biome.soilHeight then
|
||||
-- ... then soil is generated.
|
||||
biome:generateSoil(mapGenerator, factors, data, index, x, y, z)
|
||||
addPostProccessing(biome, mapGenerator, factors, data, index, x, y, z, 'SOIL')
|
||||
biome:generateSoil(mapGenerator, factors, data, data2, index, x, y, z)
|
||||
addPostProccessing(biome, mapGenerator, factors, index, x, y, z, 'SOIL')
|
||||
else
|
||||
-- ... else a stone is generated.
|
||||
biome:generateRock(mapGenerator, factors, data, index, x, y, z)
|
||||
addPostProccessing(biome, mapGenerator, factors, data, index, x, y, z, 'ROCK')
|
||||
biome:generateRock(mapGenerator, factors, data, data2, index, x, y, z)
|
||||
addPostProccessing(biome, mapGenerator, factors, index, x, y, z, 'ROCK')
|
||||
end
|
||||
|
||||
-- ... or if the surface height is below the water level...
|
||||
@@ -669,12 +668,12 @@ local function generateNode(mapGenerator, layer, factors, data, index, x, y, z)
|
||||
-- ... and if the height of the block falls within the thickness of the soil layer...
|
||||
if y > height - biome.soilHeight then
|
||||
-- ... then the river/ocean bottom is generated.
|
||||
biome:generateBottom(mapGenerator, factors, data, index, x, y, z)
|
||||
addPostProccessing(biome, mapGenerator, factors, data, index, x, y, z, 'BOTTOM')
|
||||
biome:generateBottom(mapGenerator, factors, data, data2, index, x, y, z)
|
||||
addPostProccessing(biome, mapGenerator, factors, index, x, y, z, 'BOTTOM')
|
||||
else
|
||||
-- ... else a stone is generated.
|
||||
biome:generateRock(mapGenerator, factors, data, index, x, y, z)
|
||||
addPostProccessing(biome, mapGenerator, factors, data, index, x, y, z, 'ROCK')
|
||||
biome:generateRock(mapGenerator, factors, data, data2, index, x, y, z)
|
||||
addPostProccessing(biome, mapGenerator, factors, index, x, y, z, 'ROCK')
|
||||
end
|
||||
end
|
||||
else
|
||||
@@ -828,15 +827,16 @@ end
|
||||
---@param mapGenerator MapGen
|
||||
---@param layer MapGen.Layer?
|
||||
---@param data number[]
|
||||
---@param data2 number[]
|
||||
---@param index number
|
||||
---@param x integer
|
||||
---@param y integer
|
||||
---@param z integer
|
||||
local function generatorHandler(mapGenerator, layer, data, index, x, y, z)
|
||||
local function generatorHandler(mapGenerator, layer, data, data2, index, x, y, z)
|
||||
-- If the node belongs to a static layer, then a static node is generated.
|
||||
local static = mapGenerator:getStaticByHeight(y)
|
||||
if static ~= nil then
|
||||
static:generateStaticNode(mapGenerator, data, index, x, y, z)
|
||||
static:generateStaticNode(mapGenerator, data, data2, index, x, y, z)
|
||||
|
||||
return
|
||||
end
|
||||
@@ -870,7 +870,7 @@ local function generatorHandler(mapGenerator, layer, data, index, x, y, z)
|
||||
humidity = humidity,
|
||||
}
|
||||
|
||||
generateNode(mapGenerator, layer, factors, data, index, x, y, z)
|
||||
generateNode(mapGenerator, layer, factors, data, data2, index, x, y, z)
|
||||
end
|
||||
|
||||
---Chunk generation handler.
|
||||
@@ -900,7 +900,7 @@ function MapGen:onMapGenerated(voxelManip, minPos, maxPos, blockseed)
|
||||
self:initCavernsNoise()
|
||||
end
|
||||
|
||||
local data = voxelManip:get_data()
|
||||
local data, data2 = voxelManip:get_data(), voxelManip:get_param2_data()
|
||||
-- local param2_data = voxelManip:get_param2_data()
|
||||
local area = VoxelArea:new({MinEdge = eMin, MaxEdge = eMax})
|
||||
|
||||
@@ -917,19 +917,19 @@ function MapGen:onMapGenerated(voxelManip, minPos, maxPos, blockseed)
|
||||
index = area:index(x, y, z)
|
||||
|
||||
if data[index] == AIR_ID then
|
||||
generatorHandler(self, layer, data, index, x, y, z)
|
||||
generatorHandler(self, layer, data, data2, index, x, y, z)
|
||||
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,
|
||||
data,
|
||||
data2,
|
||||
ppdata.index,
|
||||
ppdata.x,
|
||||
ppdata.y,
|
||||
@@ -941,17 +941,15 @@ function MapGen:onMapGenerated(voxelManip, minPos, maxPos, blockseed)
|
||||
|
||||
-- We make changes back to LVM and recalculate light & liquids
|
||||
voxelManip:set_data(data)
|
||||
voxelManip:set_param2_data(data2)
|
||||
|
||||
core.generate_ores(voxelManip, minPos, maxPos)
|
||||
core.generate_decorations(voxelManip, minPos, maxPos)
|
||||
|
||||
--voxelManip:set_param2_data()
|
||||
voxelManip:set_lighting({ day = 14, night = 0})
|
||||
voxelManip:calc_lighting()
|
||||
voxelManip:update_liquids()
|
||||
|
||||
pastTriangle = nil
|
||||
|
||||
if PROFILE_CHUNK then
|
||||
endTime = getUsTime()
|
||||
mglog('Chunk end:\n'..
|
||||
|
||||
Reference in New Issue
Block a user