Mapgen: write SuperUltraSigmaMapgen part 7 (async)

This commit is contained in:
Van
2025-11-23 19:06:37 +03:00
parent 54cc31e14e
commit 1e430aaeb0
11 changed files with 169 additions and 162 deletions

View File

@@ -62,3 +62,5 @@ function Mod:getModClassExtended(ChildClass)
return childClass return childClass
end end
return Mod

View File

@@ -34,3 +34,5 @@ function Require.getModRequire(modName, modPath)
return require return require
end end
return Require

View File

@@ -37,7 +37,7 @@ local pastNoise2DCalc = {
} }
} }
local modInfo = Mod.getInfo() local modInfo = Mod.getInfo('smc__core__map_gen')
local require = modInfo.require local require = modInfo.require
---@type MapGen.Layer ---@type MapGen.Layer
@@ -70,7 +70,7 @@ local MapGen = {
isRunning = false, isRunning = false,
} }
---@param nodeIDs table<string, string> ---@param nodeIDs table<string, number>
---@return MapGen ---@return MapGen
function MapGen:new(nodeIDs) function MapGen:new(nodeIDs)
---@type MapGen ---@type MapGen
@@ -623,12 +623,15 @@ local function generatorHandler(mapGenerator, data, index, x, y, z)
generateNode(mapGenerator, layer, noiseHeightValue, noiseTempValue, noiseHumidityValue, data, index, x, y, z) generateNode(mapGenerator, layer, noiseHeightValue, noiseTempValue, noiseHumidityValue, data, index, x, y, z)
end end
---@param voxelManip VoxelManip
---@param minPos table ---@param minPos table
---@param maxPos table ---@param maxPos table
---@param blockseed number ---@param blockseed number
function MapGen:onMapGenerated(minPos, maxPos, blockseed) function MapGen:onMapGenerated(voxelManip, minPos, maxPos, blockseed)
-- We obtain a generation area for further manipulations -- We obtain a generation area for further manipulations
local voxelManip, eMin, eMax = core.get_mapgen_object('voxelmanip') --local voxelManip, eMin, eMax = core.get_mapgen_object('voxelmanip')
local eMin, eMax = voxelManip:get_emerged_area()
if not self.peaksMultinoiseInitialized then if not self.peaksMultinoiseInitialized then
self:initPeaksMultinoise() self:initPeaksMultinoise()
@@ -665,7 +668,7 @@ function MapGen:onMapGenerated(minPos, maxPos, blockseed)
voxelManip:calc_lighting() voxelManip:calc_lighting()
voxelManip:update_liquids() voxelManip:update_liquids()
voxelManip:write_to_map() --voxelManip:write_to_map() -- Async edit
end end

View File

@@ -63,9 +63,9 @@ function Cavern:new(name, def)
end end
function instance:initNoise() function instance:initNoise()
if not table.is_empty(_noise) then --if not table.is_empty(_noise) then
minetest.log('warning', 'Cavern noise has already been initialized. Re-initialization is not recommended.') -- minetest.log('warning', 'Cavern noise has already been initialized. Re-initialization is not recommended.')
end --end
_noise = core.get_value_noise(_noiseParams) _noise = core.get_value_noise(_noiseParams)
end end

View File

@@ -66,9 +66,9 @@ function Peak:new(peakPos, multinoiseParams, groups)
end end
function instance:initMultinoise() function instance:initMultinoise()
if not table.is_empty(_multinoise) then --if not table.is_empty(_multinoise) then
minetest.log('warning', 'Multinoise has already been initialized. Re-initialization is not recommended.') -- minetest.log('warning', 'Multinoise has already been initialized. Re-initialization is not recommended.')
end --end
_multinoise = multinoiseParamsToMultinoise(_multinoiseParams) _multinoise = multinoiseParamsToMultinoise(_multinoiseParams)
end end

View File

@@ -1,6 +1,6 @@
local mathAbs = math.abs local mathAbs = math.abs
local modInfo = Mod.getInfo() local modInfo = Mod.getInfo('smc__core__map_gen')
local require = modInfo.require local require = modInfo.require
---@type MapGen.Triangle ---@type MapGen.Triangle

View File

@@ -1,7 +1,7 @@
local mathSqrt, mathAbs local mathSqrt, mathAbs
= math.sqrt, math.abs = math.sqrt, math.abs
local modInfo = Mod.getInfo() local modInfo = Mod.getInfo('smc__core__map_gen')
local require = modInfo.require local require = modInfo.require
---@type MapGen.Triangulation.Edge ---@type MapGen.Triangulation.Edge

View File

@@ -12,7 +12,7 @@
local assert, mathMax, tableRemove local assert, mathMax, tableRemove
= assert, math.max, table.remove = assert, math.max, table.remove
local modInfo = Mod.getInfo() local modInfo = Mod.getInfo('smc__core__map_gen')
local require = modInfo.require local require = modInfo.require
---@type MapGen.Triangle ---@type MapGen.Triangle

View File

@@ -1,4 +1,4 @@
local modInfo = Mod.getInfo() local modInfo = Mod.getInfo('smc__core__map_gen')
local require = modInfo.require local require = modInfo.require
---@type MapGen.Peak ---@type MapGen.Peak

View File

@@ -0,0 +1,146 @@
-- MAPGEN ENVIROMENT ONLY
local id = core.get_content_id
Require = dofile(core.get_modpath('smc__api__require')..'/init.lua')
---@type Mod
Mod = dofile(core.get_modpath('smc__api__mod')..'/init.lua')
print(core.get_modpath('smc__api__mod')..'/init.lua')
local mapGenRequire = Mod.getInfo('smc__core__map_gen').require
---@type MapGen
local MapGen = mapGenRequire('MapGen')
---@type MapGen
local mapGenerator = MapGen:new({
-- Special nodes
air = id("air"),
-- Rocks
sylite = id("rocks:sylite"),
tauitite = id("rocks:tauitite"),
iyellite = id("rocks:iyellite"),
falmyte = id("rocks:falmyte"),
hapcoryte = id("rocks:hapcoryte"),
burcite = id("rocks:burcite"),
felhor = id("rocks:felhor"),
malachite = id("rocks:malachite"),
-- Liquids
water = id("liquids:water_source"),
})
mapGenerator:RegisterLayer("world", -1000, 500)
local land1 = {
offset = -20,
scale = 5,
spread = {x = 10, y = 10, z = 10},
seed = 47,
octaves = 3,
persistence = 0.4,
lacunarity = 2,
}
local land2 = {
offset = 20,
scale = 5,
spread = {x = 10, y = 10, z = 10},
seed = 47,
octaves = 3,
persistence = 0.4,
lacunarity = 2,
}
local climat1 = {
offset = 80,
scale = 10,
spread = {x = 10, y = 10, z = 10},
seed = 47,
octaves = 8,
persistence = 0.6,
lacunarity = 2,
}
local climat2 = {
offset = 30,
scale = 10,
spread = {x = 10, y = 10, z = 10},
seed = 47,
octaves = 8,
persistence = 0.6,
lacunarity = 2,
}
local climat0 = {
offset = 50,
scale = 0,
spread = {x = 10, y = 10, z = 10},
seed = 47,
octaves = 8,
persistence = 0.4,
lacunarity = 2,
}
local v = vector.new
mapGenerator:register2DPeaks("world",
{
landscapeNoise = land1,
tempNoise = climat2,
humidityNoise = climat2,
},{
v(500, 0, 500),
v(-500, 0, -500),
v(-500, 0, 500),
v(500, 0, -500),
})
mapGenerator:register2DPeaks("world",
{
landscapeNoise = land2,
tempNoise = climat1,
humidityNoise = climat1,
},{
v(-300, 0, 300),
v(200, 0, -400),
})
mapGenerator:register2DPeaks("world",
{
landscapeNoise = land2,
tempNoise = climat2,
humidityNoise = climat2,
},{
v(200, 0, 100),
v(-300, 0, -200),
})
mapGenerator:registerCavern('world', 'cavern1', {
minY = -100,
maxY = -10,
smoothDistance = 20,
noiseParams ={
offset = 0,
scale = 1,
spread = {x = 25, y = 25, z = 25},
seed = 5934,
octaves = 3,
persistence = 0.5,
lacunarity = 2.0
},
})
mapGenerator:registerBiome('world', "biome1", 0, 0, {
soil = "soils:clay_soil_baren",
turf = "soils:clay_soil_baren",
}, 1)
mapGenerator:registerBiome('world', "biome2", 100, 100, {
soil = "soils:rocky_soil_baren",
turf = "soils:rocky_soil_baren",
}, 1)
mapGenerator:run()

View File

@@ -1,147 +1 @@
local id = core.get_content_id core.register_mapgen_script(core.get_modpath(core.get_current_modname())..'/MapGenerator.lua')
---@type MapGen
local mapGenerator = Core.MapGen.Class:new({
-- Special nodes
air = id("air"),
-- Rocks
sylite = id("rocks:sylite"),
tauitite = id("rocks:tauitite"),
iyellite = id("rocks:iyellite"),
falmyte = id("rocks:falmyte"),
hapcoryte = id("rocks:hapcoryte"),
burcite = id("rocks:burcite"),
felhor = id("rocks:felhor"),
malachite = id("rocks:malachite"),
-- Liquids
water = id("liquids:water_source"),
})
mapGenerator:RegisterLayer("world", -1000, 500)
local land1 = {
offset = -20,
scale = 5,
spread = {x = 10, y = 10, z = 10},
seed = 47,
octaves = 3,
persistence = 0.4,
lacunarity = 2,
}
local land2 = {
offset = 20,
scale = 5,
spread = {x = 10, y = 10, z = 10},
seed = 47,
octaves = 3,
persistence = 0.4,
lacunarity = 2,
}
local climat1 = {
offset = 80,
scale = 10,
spread = {x = 10, y = 10, z = 10},
seed = 47,
octaves = 8,
persistence = 0.6,
lacunarity = 2,
}
local climat2 = {
offset = 30,
scale = 10,
spread = {x = 10, y = 10, z = 10},
seed = 47,
octaves = 8,
persistence = 0.6,
lacunarity = 2,
}
local climat0 = {
offset = 50,
scale = 0,
spread = {x = 10, y = 10, z = 10},
seed = 47,
octaves = 8,
persistence = 0.4,
lacunarity = 2,
}
local v = vector.new
mapGenerator:register2DPeaks("world",
{
landscapeNoise = land1,
tempNoise = climat2,
humidityNoise = climat2,
},{
v(500, 0, 500),
v(-500, 0, -500),
v(-500, 0, 500),
v(500, 0, -500),
})
mapGenerator:register2DPeaks("world",
{
landscapeNoise = land2,
tempNoise = climat1,
humidityNoise = climat1,
},{
v(-300, 0, 300),
v(200, 0, -400),
})
mapGenerator:register2DPeaks("world",
{
landscapeNoise = land2,
tempNoise = climat2,
humidityNoise = climat2,
},{
v(200, 0, 100),
v(-300, 0, -200),
})
mapGenerator:registerCavern('world', 'cavern1', -100, -10, 20, {
offset = 0,
scale = 1,
spread = {x = 25, y = 25, z = 25},
seed = 5934,
octaves = 3,
persistence = 0.5,
lacunarity = 2.0
})
mapGenerator:registerBiome('world', "biome1", 0, 0, {
soil = "soils:clay_soil_baren",
turf = "soils:clay_soil_baren",
}, 1)
mapGenerator:registerBiome('world', "biome2", 100, 100, {
soil = "soils:rocky_soil_baren",
turf = "soils:rocky_soil_baren",
}, 1)
mapGenerator:run()
minetest.register_ore({
ore_type = "blob",
ore = "soils:clay_soil_baren",
wherein = {"rocks:iyellite", "rocks:falmyte"},
clust_scarcity = 16 * 16 * 16,
clust_size = 5,
y_max = 0,
y_min = -3100,
noise_threshold = 0.0,
noise_params = {
offset = 1,
scale = 0.5,
spread = {x = 5, y = 5, z = 5},
seed = 2316,
octaves = 1,
persist = 0.0
},
})