Skip to content

Commit

Permalink
Fix issue with rivers being disjoint
Browse files Browse the repository at this point in the history
We now add a point or two backwards during river generation to be sure
they line up nicely
  • Loading branch information
augustus committed Sep 29, 2021
1 parent 2edc980 commit 38b881d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pkg/landscape/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func DefaultConfig() *Config {
EquatorWidth: 0.05, // % of height
},
Rivers: &riverSettings{
Number: 1,
Number: 30,
OriginMinDist: 70,
ForceNorthSouthSections: true,
},
Expand Down
14 changes: 13 additions & 1 deletion pkg/landscape/rivers.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,18 @@ func drawRiver(hmap, out *MapImage, path [][]*Pixel) *MapImage {
}
hmap.SetValue(int(p.X), int(p.Y), riverbed)
}

// fill river point backwards just to be sure our points line up
for i, p := range geo.PointsAlongLine(to.Point.Round(), from.Point.Round()) {
if i > 1 {
break
}

// record the river
rvr.SetValue(int(p.X), int(p.Y), 255)
out.SetValue(int(p.X), int(p.Y), 255)
}

rvr.SetValue(to.X(), to.Y(), 255)
out.SetValue(to.X(), to.Y(), 255)
hmap.SetValue(to.X(), to.Y(), riverbed)
Expand Down Expand Up @@ -413,7 +425,7 @@ func riverOrigins(hmap *MapImage, cfg *riverSettings) []*Pixel {
)

// figure out all places we can start rivers
var min uint8 = 200 // fairly high up
var min uint8 = 220 // fairly high up
var max uint8 = 240 // but not on a mountain peak ..
origins := []*Pixel{}
for {
Expand Down

0 comments on commit 38b881d

Please sign in to comment.