MapGen: add cavern type warped. Old caverns is now cheesed type
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
local mathRound, mathRandom, mathClamp, tableInsert
|
||||
= math.round, math.random, math.clamp, table.insert
|
||||
|
||||
local posToString, getUsTime = core.pos_to_string, core.get_us_time
|
||||
local corePosToString, coreGetUsTime = core.pos_to_string, core.get_us_time
|
||||
|
||||
local pairs, ipairs, assert = pairs, ipairs, assert
|
||||
|
||||
@@ -56,10 +56,10 @@ local Region = require('MapGen.Region')
|
||||
---@field nodes table<string, string>
|
||||
---@field nodeIDs table<string, number>
|
||||
local MapGen = {
|
||||
layersByName = {},
|
||||
layersList = {},
|
||||
staticsByName = {},
|
||||
staticsList = {},
|
||||
layersByName = {},
|
||||
layersList = {},
|
||||
staticsByName = {},
|
||||
staticsList = {},
|
||||
isLayersNoisesInitialized = false,
|
||||
isCavernsNoiseInitialized = false,
|
||||
isRunning = false,
|
||||
@@ -236,7 +236,7 @@ end
|
||||
function MapGen:isCavern(layer, x, y, z)
|
||||
for _, cavern in ipairs(layer.cavernsList) do
|
||||
if cavern.isRegional then
|
||||
local inRegion, distance = self:pointInRegion2D(layer, cavern.name, vector.new(x, y, z))
|
||||
local inRegion, distance = self:pointInRegion2D(layer, cavern.name, v(x, y, z))
|
||||
|
||||
if inRegion and distance ~= nil then
|
||||
if cavern:isCavern(x, y, z, distance) then
|
||||
@@ -766,7 +766,7 @@ end
|
||||
---@param z integer
|
||||
---@return number?, number?, number?
|
||||
function MapGen:getFactors(layer, x, y, z)
|
||||
local posString = posToString({x=x,y=0,z=z})
|
||||
local posString = corePosToString({x=x,y=0,z=z})
|
||||
|
||||
local factors = pastNoiseValues[layer.name][posString]
|
||||
if factors ~= nil then
|
||||
@@ -774,7 +774,7 @@ function MapGen:getFactors(layer, x, y, z)
|
||||
end
|
||||
|
||||
-- TODO: это сильно тормозит обычные чанки, но ускоряет те, что находятся за границей
|
||||
if not self:pointInRegion2D(layer, 'triangles_boundary', vector.new(x, y, z)) then
|
||||
if not self:pointInRegion2D(layer, 'triangles_boundary', v(x, y, z)) then
|
||||
return
|
||||
end
|
||||
|
||||
@@ -848,7 +848,7 @@ local function generatorHandler(mapGenerator, layer, data, data2, index, x, y, z
|
||||
return
|
||||
end
|
||||
|
||||
local endGetLayerTime = getUsTime()
|
||||
local endGetLayerTime = coreGetUsTime()
|
||||
local startNoiseCalcTime = endGetLayerTime
|
||||
-- If the value of the noise is `nil`,
|
||||
-- then the point does not fall within any of the triangles.
|
||||
@@ -879,7 +879,7 @@ end
|
||||
---@param maxPos MapVector
|
||||
---@param blockseed number
|
||||
function MapGen:onMapGenerated(voxelManip, minPos, maxPos, blockseed)
|
||||
local minPosStr, maxPosStr = posToString(minPos), posToString(maxPos)
|
||||
local minPosStr, maxPosStr = corePosToString(minPos), corePosToString(maxPos)
|
||||
local startTime, endTime = 0.0, 0.0
|
||||
|
||||
if LOG_PROFILE then
|
||||
@@ -887,7 +887,7 @@ function MapGen:onMapGenerated(voxelManip, minPos, maxPos, blockseed)
|
||||
'min_pos: %s\n'..
|
||||
'max_pos: %s\n',
|
||||
minPosStr, maxPosStr)
|
||||
startTime = getUsTime()
|
||||
startTime = coreGetUsTime()
|
||||
end
|
||||
|
||||
local eMin, eMax = voxelManip:get_emerged_area()
|
||||
@@ -951,7 +951,7 @@ function MapGen:onMapGenerated(voxelManip, minPos, maxPos, blockseed)
|
||||
voxelManip:update_liquids()
|
||||
|
||||
if PROFILE_CHUNK then
|
||||
endTime = getUsTime()
|
||||
endTime = coreGetUsTime()
|
||||
mglog('Chunk end:\n'..
|
||||
'min_pos: %s\n'..
|
||||
'max_pos: %s\n'..
|
||||
|
||||
Reference in New Issue
Block a user