@@ -9,8 +9,8 @@ import { buildRegionGridMap } from './region'
99
1010const SURFACE_NOISE_RATIO = .6
1111const SURFACE_GRID_CACHE = new FIFOCache ( 256 )
12- const REGION_WATER = 0
13- const REGION_LAND = 1
12+ const REGION_WATER = false
13+ const REGION_LAND = true
1414
1515
1616export function buildModel ( context ) {
@@ -20,33 +20,31 @@ export function buildModel(context) {
2020 return SURFACE_GRID_CACHE . get ( hash )
2121 }
2222 const regionGridContext = buildRegionGridMap ( context )
23- const regionSurfaceMap = buildRegionSurfaceMap ( { ... context , ... regionGridContext } )
23+ const regionSurfaceMap = buildDirectionTypeMap ( context )
2424 const landMaskGrid = buildLandMaskGrid ( { ...context , ...regionGridContext , regionSurfaceMap} )
2525 const model = { landMaskGrid, ...regionGridContext }
2626 SURFACE_GRID_CACHE . set ( hash , model )
2727 return model
2828}
2929
3030
31- function buildRegionSurfaceMap ( context ) {
31+ function buildDirectionTypeMap ( context ) {
3232 const { world, worldPoint} = context
33- const surfaceTypeMap = new Map ( )
33+ const directionTypeMap = new Map ( )
3434 const isWorldPointLand = world . surface . isLand ( worldPoint )
3535
36- Point . around ( worldPoint , ( sidePoint , direction ) => {
36+ Point . adjacents ( worldPoint , ( sidePoint , direction ) => {
37+ const isSideLand = world . surface . isLand ( sidePoint )
3738 if ( isWorldPointLand ) {
38- if ( world . surface . isLand ( sidePoint ) ) {
39- if ( isWaterChannel ( context , direction ) ) {
40- surfaceTypeMap . set ( direction . id , REGION_WATER )
41- } else {
42- surfaceTypeMap . set ( direction . id , REGION_LAND )
43- }
39+ if ( isSideLand ) {
40+ const type = isWaterChannel ( context , direction ) ? REGION_WATER : REGION_LAND
41+ directionTypeMap . set ( direction . id , type )
4442 }
45- } else {
46- surfaceTypeMap . set ( direction . id , REGION_WATER )
43+ } else if ( ! isSideLand ) {
44+ directionTypeMap . set ( direction . id , REGION_WATER )
4745 }
4846 } )
49- return surfaceTypeMap
47+ return directionTypeMap
5048}
5149
5250
0 commit comments