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

Rework river generation #38894

Conversation

Diabolus-Engi
Copy link

@Diabolus-Engi Diabolus-Engi commented Mar 19, 2020

Summary

SUMMARY: Bugfixes "Reworks river generation on overmap."

Purpose of change

Reworks river generation so that they cross overmap boundaries better and flow more realistically.

Fixes: #36630
Fixes: #38036

Describe the solution

  1. Adds river nodes for the overmap to track entry/exit points of rivers so that they can be continued with more accuracy to adjacent overmaps. Also includes the size of the river. This provides some method continuity for rivers and can later be used to maintain other properties for the river such as fish populations, contaminates perhaps.

  2. Reworks plotting of the river and generation by using a quadratic bezier curve, coupled with part of the original weighted random walk method that helps to create varied river sizes while the bezier curve allows bends in the river. The control points probably still need some work, but hoping to catch the eye of someone who knows more math than myself for that.

  3. Changes the polishing of rivers to apply terrain mask based on adjacent tiles. I found this implementation to be a little cleaned than the original.

  4. Rivers have a chance to generate branches of a smaller scale that will merge into the river further down and also generate branches to a random nearby point.

  5. Rivers will 'pool up' creating small lakes if they haven't terminated on the overmap boundary.

TODO:

  • Remember river scales between overmaps to allow different river sizes to cross.
  • Add streams, smaller versions of rivers. Requires mapgen work in a future PR.

Describe alternatives you've considered

Well, I originally set out just to fix overmap river borders. After many days of wrestling with the current implementation and testing various alternative methods, I found it was unfeasible to continue without rewriting a lot of the river generation.

Once elevations are added, then we can advance further into erosion models etc that would provide realistic rivers. While I played with the idea of using perlin noise, I opted against it in favor of waiting for elevations.

Testing

Generate a new map, teleport to adjacent overmaps and follow the rivers between overmaps.

Additional context

(Slightly outdated pre-random branches)
o_10

(Updated)
o_10

src/overmap.cpp Outdated Show resolved Hide resolved
src/overmap.cpp Outdated Show resolved Hide resolved
src/overmap.cpp Outdated Show resolved Hide resolved
src/overmap.cpp Outdated Show resolved Hide resolved
src/overmap.cpp Outdated Show resolved Hide resolved
src/overmap.cpp Outdated Show resolved Hide resolved
size_t instead of int for loops.

Co-Authored-By: anothersimulacrum <[email protected]>
@ZhilkinSerg ZhilkinSerg added <Enhancement / Feature> New features, or enhancements on existing [JSON] Changes (can be) made in JSON Map / Mapgen Overmap, Mapgen, Map extras, Map display [C++] Changes (can be) made in C++. Previously named `Code` labels Apr 7, 2020
@Diabolus-Engi Diabolus-Engi changed the title [WIP] Rework river generation Rework river generation Apr 8, 2020
@akirashirosawa
Copy link
Contributor

akirashirosawa commented Apr 8, 2020

Does this fix #39382?

@ralreegorganon
Copy link
Contributor

ralreegorganon commented Apr 9, 2020

Does this fix #39382?

No, it's entirely unrelated. This PR changes how the rivers are placed, but that issue is about the local mapgen for lake shores in that particular overmap layout.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[C++] Changes (can be) made in C++. Previously named `Code` <Enhancement / Feature> New features, or enhancements on existing [JSON] Changes (can be) made in JSON Map / Mapgen Overmap, Mapgen, Map extras, Map display
Projects
Status: Abandoned PRs with no one to pick them up
Development

Successfully merging this pull request may close these issues.

Rivers don't connect smoothly across overmap boundaries River meets lake bad mapgen
6 participants