Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Worldgen 9, 10 and 11 - Rivers and Soils #224

Draft
wants to merge 42 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
8816bf2
- getting started with the rivers
dsecrieru Sep 28, 2024
c41cd4f
minor change on logging
dsecrieru Sep 29, 2024
9097435
- refactored square tile to hex tile mapping
dsecrieru Sep 29, 2024
990920f
making progress on rivers, done with drainage basins
dsecrieru Sep 29, 2024
b759486
- making progress on rivers, got up to tributaries
dsecrieru Oct 6, 2024
cda7d96
more cleanup of validity checks on waterbodies
dsecrieru Oct 6, 2024
37c28c1
Merge branch 'Calandiel:master' into worldgen_09
dsecrieru Oct 7, 2024
e469cfa
finished rivers port; added watersheds map export; some minor refacto…
dsecrieru Oct 9, 2024
7d27b59
forgot a debug flag
dsecrieru Oct 9, 2024
bd64a3e
minor cleanup
dsecrieru Oct 18, 2024
bd608d5
glaciation categ for debug in debug-control-panel
dsecrieru Oct 18, 2024
f280138
enabled debug for next stage(s) port
dsecrieru Oct 18, 2024
284f081
basic skeleton for volcanic silts
dsecrieru Oct 18, 2024
a89545d
finalized volcanic silt port
dsecrieru Oct 19, 2024
66a0564
started port for sand dunes; added override for soils for debugging
dsecrieru Oct 19, 2024
1f0f9ab
more debug stuff
dsecrieru Oct 26, 2024
e23a4b7
refactored align_rng, updated docs, made slope_retention_factor_stora…
dsecrieru Oct 26, 2024
8e1956c
finished port of sand dunes silt; refactored align_rng
dsecrieru Oct 26, 2024
0662e61
ported silts thinning; some code cleanup/bugfixing in sand dunes
dsecrieru Oct 28, 2024
0337cea
ported GenBedrockBuffer
dsecrieru Oct 30, 2024
65b958f
bug fix
dsecrieru Oct 30, 2024
8d36a32
disabled debug mode
dsecrieru Oct 30, 2024
7ac66a4
desperate for even a small speed-up
dsecrieru Oct 31, 2024
12db874
refactored to reduce execution time from over 1min to around 7s
dsecrieru Nov 1, 2024
8bbd415
refactor to get rid of for_each_neighbor
dsecrieru Nov 1, 2024
b6b0df5
another wave of replacing for_each_neighbor; some minor refactoring
dsecrieru Nov 2, 2024
b8baa01
refactor for_each_neighbor out of lakes
dsecrieru Nov 2, 2024
03a2c83
refactor for_each_neighbor out of rivers and waterbody perimeter
dsecrieru Nov 2, 2024
78deb1e
getting rid of more for_each (waterbodies)
dsecrieru Nov 2, 2024
b7f6188
and finally, refactored for_each_neighbor out of glacial-formation
dsecrieru Nov 2, 2024
1f15194
minor
dsecrieru Nov 2, 2024
a56e5e4
still trying to further improve lua performance on this, without much…
dsecrieru Nov 3, 2024
4abc6f4
minor
dsecrieru Nov 3, 2024
830ce04
refactoring
dsecrieru Nov 6, 2024
31e9ce8
LoadWaterbodies port
dsecrieru Nov 6, 2024
c6285ed
added debug map to take a peek at soils at this stage
dsecrieru Nov 8, 2024
242b4e2
bugfixing
dsecrieru Nov 11, 2024
f301798
WeatherAlluvialTexture port
dsecrieru Nov 12, 2024
1c2e3ec
renamed load-waterbodies
dsecrieru Nov 13, 2024
8bfd39d
some refactoring
dsecrieru Nov 17, 2024
c97cb41
GenAlluvialSoils port
dsecrieru Nov 17, 2024
3d6a7cd
going out of debug mode, ready for pr
dsecrieru Nov 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions sote/game/climate/sun.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,8 @@ function sun.yearly_irradiance(latitude_in_degrees)
end
end

function sun.yearly_irradiance_from_colat(colat)
return math.max(0.0, (-1.0) * colat * (colat - 3.1415) + 1.7)
end

return sun
16 changes: 5 additions & 11 deletions sote/game/scenes/world-gen.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,31 +23,25 @@ local function map_tiles_to_hex()
local lat, lon = tile:latlon()
local q, r, face = hex.latlon_to_hex_coords(lat, lon, wg.world.size)

wg.world:cache_tile_coord(tile.tile_id, q, r, face)
wg.world:cache_square_ti_by_hex_coords(q, r, face)
end
end

local function load_mapping_from_file(file)
for row in require("game.file-utils").csv_rows(file) do
local tile_id = tonumber(row[1])
local q = tonumber(row[2])
local r = tonumber(row[3])
local face = tonumber(row[4])

wg.world:cache_tile_coord(tile_id, q, r, face)
wg.world:cache_square_ti_by_hex_ti(tonumber(row[2]))
end
end

local function cache_tile_coord()
local function cache_cube_world_tiles()
print("Caching tile coordinates...")

if debug.map_tiles_from_file then
-- it's faster to load the pre-calculated coordinates from a file than to calculate them on the fly
load_mapping_from_file("d:\\temp\\hex_mapping.csv")
load_mapping_from_file("d:\\temp\\hex_mapping2.csv")
else
map_tiles_to_hex()
end
-- wg.world:map_hex_coords()

print("Done caching tile coordinates")
end
Expand Down Expand Up @@ -119,7 +113,7 @@ function wg.generate_coro()
coroutine.yield()

wg.message = "Caching tile coordinates"
prof.run_with_profiling(function() cache_tile_coord() end, "[scenes.world-gen]", "cache_tile_coord")
prof.run_with_profiling(function() cache_cube_world_tiles() end, "[scenes.world-gen]", "cache_cube_world_tiles")
coroutine.yield()
end

Expand Down
30 changes: 25 additions & 5 deletions sote/libsote/debug-control-panel.lua
Original file line number Diff line number Diff line change
@@ -1,8 +1,26 @@
local dcp = {}

dcp.align_to_sote_coords = false -- this will align hex world storage to match the order from original sote, very useful when debugging/validating port
dcp.map_tiles_from_file = false -- this will load cube world tile IDs mapping to hex coordinates from a file, as it's faster than computing them from lat lon
dcp.use_sote_climate_data = false -- climate model was ported from sote, but with some changes; this will enable import of original sote climate data from a csv file, to aid in debugging/validating port
-- these will load cube world tile IDs mapping to hex from a file, as it's faster than computing them from lat lon
dcp.map_tiles_from_file = false
dcp.use_sote_climate_data = false
dcp.use_sote_ice_data = false
dcp.use_sote_soils_data = false
dcp.use_sote_water_movement = false

-- this will align hex world storage to match the order from original SotE, very useful when debugging/validating port
dcp.align_to_sote_coords =
dcp.use_sote_climate_data
or dcp.use_sote_ice_data
or dcp.use_sote_soils_data
or dcp.use_sote_water_movement

-- these will align RNG seed to match original SotE seed
dcp.glaciation = {
align_rng = false
}
dcp.soils = {
align_rng = false
}

dcp.save_maps = false -- this will export maps to PNG
dcp.maps_selection = {
Expand All @@ -11,7 +29,9 @@ dcp.maps_selection = {
climate = false,
waterflow = false,
waterbodies = false,
debug = false
watersheds = false,
debug1 = false,
debug2 = false
}

-- seed = 58738 -- climate integration was done on this one
Expand All @@ -20,7 +40,7 @@ dcp.maps_selection = {
-- seed = 6618 -- tiny islands?
-- seed = 49597 -- interesting looking one, huge northern ice cap (with lua climate model)
-- seed = 91170 -- huge lake
dcp.fixed_seed = nil
-- dcp.fixed_seed = 12177
-- dcp.fixed_seed = 53104 -- got sand dunes

return dcp
29 changes: 19 additions & 10 deletions sote/libsote/debug-loggers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,6 @@ function logger:log(message, do_flush)
end
end

local loggers = {}

local latlon_logger = nil
local neighbors_logger = nil
local waterflow_logger = nil
local parent_material_logger = nil
local glacial_logger = nil
local climate_logger = nil
local lakes_logger = nil

local function get_logger(logger_instance, logname, path, unique)
if logger_instance == nil then
logger_instance = logger:new(logname, path, unique)
Expand All @@ -62,32 +52,51 @@ local function get_logger(logger_instance, logname, path, unique)
return logger_instance
end

local loggers = {}

local latlon_logger = nil
function loggers.get_latlon_logger(path)
return get_logger(latlon_logger, "latlon", path)
end

local neighbors_logger = nil
function loggers.get_neighbors_logger(path)
return get_logger(neighbors_logger, "neighbours", path)
end

local waterflow_logger = nil
function loggers.get_waterflow_logger(path)
return get_logger(waterflow_logger, "waterflow", path)
end

local parent_material_logger = nil
function loggers.get_parent_material_logger(path)
return get_logger(parent_material_logger, "parent_material", path)
end

local glacial_logger = nil
function loggers.get_glacial_logger(path)
return get_logger(glacial_logger, "glacial", path)
end

local climate_logger = nil
function loggers.get_climate_logger(path)
return get_logger(climate_logger, "climate", path)
end

local lakes_logger = nil
function loggers.get_lakes_logger(path)
return get_logger(lakes_logger, "lakes", path)
end

local rivers_logger = nil
function loggers.get_rivers_logger(path)
return get_logger(rivers_logger, "rivers", path)
end

local soils_logger = nil
function loggers.get_soils_logger(path)
return get_logger(soils_logger, "soils", path)
end

return loggers
Loading