Bug fixes

pull/1/head
Bram van den Heuvel 2024-04-29 18:19:23 +02:00
parent 588ed956b1
commit d111364b0f
1 changed files with 13 additions and 6 deletions

View File

@ -291,12 +291,12 @@ function internal.clean_shape_def(def)
return d
end
-- Get the most nearby cave shape
-- Get the most nearby cave biome
function internal.closest_cave_biome(heat, humidity)
local biome = internal.default_biome()
local d = internal.biome_def_distance(biome, heat, humidity)
for key, def in pairs(noordstar_caves.registered_biomes) do
for _, def in pairs(noordstar_caves.registered_biomes) do
local new_d = internal.biome_def_distance(def, heat, humidity)
if new_d <= d then
@ -305,7 +305,7 @@ function internal.closest_cave_biome(heat, humidity)
end
end
return shape
return biome
end
-- Get the most nearby cave shape
@ -453,10 +453,17 @@ function internal.flat_from_cave_bools(minp, maxp)
noise[key] = internal.flat_from_shape_def(shape, minp, maxp)
end
local default = internal.default_shape()
noise[default.name] = internal.flat_from_shape_def(default, minp, maxp)
-- Create a flat array of bools
local bools = Flat3dArray:from_func(minp, maxp, function (i, pos)
local key = reduced:get_pos(internal.reduced_shape_pos(pos))
if noise[key] == nil then
error("Key " .. key .. " gave no value on noise")
end
local n = noise[key]:get_index(i)
local v = internal.cave_vastness(pos)
@ -566,6 +573,8 @@ function internal.flat_from_shape_def(def, minp, maxp)
internal.iter_3d_area(minp, maxp, function (i, pos)
noise_flat_map[i] = def.func(pos, noise_flat_map[i])
end)
return Flat3dArray:new(minp, maxp, noise_flat_map)
end
-- Convert 3d relative coordinates to an index on a flat array
@ -643,9 +652,7 @@ function internal.generate_caves(data, minp, maxp)
local heat = heat_points:get_index(i)
local humidity = humidity_points:get_index(i)
local name = internal.closest_cave_biome(heat, humidity)
local def = noordstar_caves.registered_biomes[name] or internal.default_biome()
local def = internal.closest_cave_biome(heat, humidity)
if nt == internal.node_types.floor then
place(def.node_floor)