Flokey82 / go_gens

Various small attempts at procedural generation, AI, simulation and whatnot.
Apache License 2.0
19 stars 6 forks source link

Distance calculation of neighbor region to river segment might be wrong #11

Closed Flokey82 closed 2 years ago

Flokey82 commented 2 years ago

https://github.com/Flokey82/go_gens/blob/8fd9059e98d6f5da8b94fe2d0d4ae1d72c72d380/genworldvoronoi/geoErosion.go#L224

https://github.com/Flokey82/go_gens/blob/8fd9059e98d6f5da8b94fe2d0d4ae1d72c72d380/genmapvoronoi/erosion2.go#L132

We calculate the erosion of a neighbor 'rn' by calculating the distance 'd' of 'rn' to the current region 'r'. However, due to the neighbor not being located at 90 deg in relation to the river-segment (r->rdh), this will lead to false distances being used.

Expected:
 rn
 :\
d: \
 :__\
 r   rdh (downhill region)

Actual:
    rn
  / : \
 / d:  \
/___:___\
r        rdh

Alternatively, 'rn' can also be 'behind' the current river segment... since we probably visit 'rn' when processing the previous region/river segment (starting at 'ruh', the uphill region), we can simply use values[rn] = math.Max(values[rn], val).
    rn
    : \
   d:  \
    :___\___
  ruh   r   rdh