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
Changes from 1 commit
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
Prev Previous commit
Next Next commit
ported silts thinning; some code cleanup/bugfixing in sand dunes
  • Loading branch information
dsecrieru committed Oct 28, 2024
commit 0662e61d8e536ae50bd83ea521ed96288d5d902a
20 changes: 10 additions & 10 deletions sote/libsote/soils/gen-sand-dunes.lua
Original file line number Diff line number Diff line change
@@ -13,7 +13,6 @@ local true_dune
local potential_dune
local dune_terminated
local true_water
local permeability
local silt_stash
local mineral_stash
local tag_num
@@ -167,6 +166,8 @@ local function process_dune_source(dune, expansion_iterations)
local new_layer = {}
local all_influenced = {}

-- local eruption_rand = rng:random()
-- local etid = dune[math.floor(eruption_rand * #dune) + 1]
local eruption_rand = rng:random_int_max(#dune) + 1
local etid = dune[eruption_rand]
table.insert(old_layer, etid)
@@ -284,7 +285,6 @@ function gsd.run(world_obj)
potential_dune = world.tmp_bool_2
dune_terminated = world.tmp_bool_3
true_water = world.tmp_float_2
permeability = world.tmp_float_3
silt_stash = world.tmp_float_4
mineral_stash = world.tmp_float_5
tag_num = world.tmp_int_1
@@ -298,7 +298,6 @@ function gsd.run(world_obj)
world:fill_ffi_array(potential_dune, false)
world:fill_ffi_array(dune_terminated, false)
world:fill_ffi_array(true_water, 0)
world:fill_ffi_array(permeability, 0)
world:fill_ffi_array(silt_stash, 0)
world:fill_ffi_array(mineral_stash, 0)
world:fill_ffi_array(tag_num, 0)
@@ -324,9 +323,9 @@ function gsd.run(world_obj)
local true_water_calc = world.jan_rainfall[ti] + world.jul_rainfall[ti] + water_movement_contribution
local wind_factor = world.jan_wind_speed[ti] --*+ world.jul_wind_speed[ti]
wind_factor = math.min(25, wind_factor)
wind_factor = ((1 - wind_factor / 25) * 0.65) + 0.35
permeability[ti] = wgu.permiation_calc_dune(world.sand[ti], world.silt[ti], world.clay[ti])
true_water[ti] = true_water_calc * permeability[ti] * wind_factor
wind_factor = (1 - wind_factor / 25) * 0.65 + 0.35
local permeability = wgu.permiation_calc_dune(world.sand[ti], world.silt[ti], world.clay[ti])
true_water[ti] = true_water_calc * permeability * wind_factor

if true_water[ti] > 40 then return end

@@ -361,10 +360,11 @@ function gsd.run(world_obj)

--* Iterate through all pertinent tiles and add silt and minerals
world:for_each_tile(function(ti)
if silt_stash[ti] > 0 then
world.silt[ti] = world.silt[ti] + math.floor(silt_stash[ti])
world.mineral_richness[ti] = world.mineral_richness[ti] + math.floor(mineral_stash[ti])
end
if not world.is_land[ti] then return end

world.silt[ti] = world.silt[ti] + math.floor(silt_stash[ti])
world.mineral_richness[ti] = world.mineral_richness[ti] + math.floor(mineral_stash[ti])
-- logger:log(ti .. ": " .. world.silt[ti] .. " " .. world.mineral_richness[ti])
end)
end

37 changes: 37 additions & 0 deletions sote/libsote/soils/thinning-silts.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
local ts = {}

local wgu = require "libsote.world-gen-utils"

function ts.run(world)
world:for_each_tile(function(ti)
if not world.is_land[ti] then return end

local water_movement_contribution = math.max(0, math.sqrt(world.water_movement[ti]) - 10)
local true_water_calc = world.jan_rainfall[ti] + world.jul_rainfall[ti] + water_movement_contribution
local wind_factor = world.jan_wind_speed[ti] --*+ world.jul_wind_speed[ti]
wind_factor = math.min(25, wind_factor)
wind_factor = (1 - wind_factor / 25) * 0.65 + 0.35
local permeability = wgu.permiation_calc(world.sand[ti], world.silt[ti], world.clay[ti])
true_water_calc = true_water_calc * permeability * wind_factor

local new_silt = world.silt[ti]

if true_water_calc <= 60 then
new_silt = new_silt * (true_water_calc / 60)
end
if true_water_calc <= 30 then
new_silt = new_silt * math.pow(true_water_calc / 30, 2)
end
if true_water_calc <= 15 then
new_silt = new_silt * math.pow(true_water_calc / 15, 2)
end

local total_material = world.sand[ti] + world.silt[ti] + world.clay[ti]
local modified_material = total_material - (world.silt[ti] - new_silt)

world.silt[ti] = math.floor(new_silt)
world.mineral_richness[ti] = math.floor(world.mineral_richness[ti] * (modified_material / total_material))
end)
end

return ts
1 change: 1 addition & 0 deletions sote/libsote/world-generator.lua
Original file line number Diff line number Diff line change
@@ -203,6 +203,7 @@ local function gen_phase_02()
run_with_profiling(function() override_water_movement_data() end, "override_waterflow_data")
end
run_with_profiling(function() require "libsote.soils.gen-sand-dunes".run(wg.world) end, "gen-sand-dunes")
run_with_profiling(function() require "libsote.soils.thinning-silts".run(wg.world) end, "thinning_silts")
end

local libsote_cpp = require "libsote.libsote"