@@ -75,7 +75,7 @@ function buildBasinGrid(context) {
7575 const type = detectLandBasinType ( world , survey )
7676 surveyMap . set ( basinId , survey )
7777 model . type . set ( basinId , type . id )
78- landFillMap . set ( basinId , { origin : point } )
78+ landFillMap . set ( basinId , { origin : point , type } )
7979 basinId ++
8080 } else if ( isBorder && world . surface . isWater ( point ) ) {
8181 const type = WaterBasin
@@ -157,7 +157,10 @@ class LandBasinFill extends ConcurrentFill {
157157 if ( basinGrid . get ( fillPoint ) !== EMPTY ) return false
158158 // avoid erosion flow on land borders
159159 if ( world . surface . isBorder ( fillPoint ) ) return false
160- if ( fill . level >= basin . reach ) return false
160+ if ( fill . level >= basin . reach ) {
161+ // basinGrid.set(fillPoint, fill.id)
162+ return false
163+ }
161164 const target = world . surface . get ( fillPoint )
162165 const parent = world . surface . get ( parentPoint )
163166 // avoid fill if different types
@@ -189,13 +192,10 @@ class WaterBasinFill extends ConcurrentFill {
189192 basinGrid . set ( fillPoint , fill . id ) // basin id is the same as fill id
190193 // discover adjacent river and water tiles
191194 Point . adjacents ( fillPoint , ( sidePoint , direction ) => {
192- const sideId = basinGrid . get ( sidePoint )
193- const sideType = Basin . parse ( model . type . get ( sideId ) )
194- const isLand = world . surface . isLand ( sidePoint )
195- if ( isLand ) {
195+ if ( world . surface . isLand ( sidePoint ) ) {
196196 const sideDirection = Direction . fromId ( model . erosion . get ( sidePoint ) )
197197 const mouth = Point . atDirection ( sidePoint , sideDirection )
198- if ( sideType . hasRivers && Point . equals ( mouth , fillPoint ) ) {
198+ if ( Point . equals ( mouth , fillPoint ) ) {
199199 model . directionBitmask . add ( fillPoint , direction )
200200 model . erosion . set ( fillPoint , direction . id )
201201 }
@@ -220,14 +220,14 @@ class WaterBasinFill extends ConcurrentFill {
220220
221221 onFill ( fill , fillPoint , parentPoint ) {
222222 const { world, model, basinGrid } = fill . context
223+ const upstream = Point . directionBetween ( fillPoint , parentPoint )
224+ model . erosion . set ( fillPoint , upstream . id )
225+ // calculate downstream directions
223226 Point . adjacents ( fillPoint , ( sidePoint , direction ) => {
224227 if ( world . surface . isWater ( sidePoint ) ) {
225228 model . directionBitmask . add ( fillPoint , direction )
226229 }
227230 } )
228- const upstream = Point . directionBetween ( fillPoint , parentPoint )
229- // model.directionBitmask.add(parentPoint, downstream)
230- model . erosion . set ( fillPoint , upstream . id )
231231 basinGrid . set ( fillPoint , fill . id )
232232 }
233233}
0 commit comments