Refactor wall points from lists to pairs
This commit is contained in:
+7
-7
@@ -61,12 +61,12 @@ generateFromTree t w = updateWallZoning $ placeSpots plmnts
|
||||
updateWallZoning :: World -> World
|
||||
updateWallZoning w = set wallsZone (IM.foldr wallInZone IM.empty (_walls w)) w
|
||||
where
|
||||
wallInZone wl | dist (_wlLine wl !! 0) (_wlLine wl !! 1) <= 2*zoneSize
|
||||
wallInZone wl | uncurry dist (_wlLine wl) <= 2*zoneSize
|
||||
= insertIMInZone x y wlid wl
|
||||
| otherwise = flip (foldr (\(a,b) -> insertIMInZone a b wlid wl)) ips
|
||||
where (x,y) = zoneOfPoint $ (pHalf (_wlLine wl !! 0) (_wlLine wl !! 1))
|
||||
where (x,y) = zoneOfPoint $ (uncurry pHalf (_wlLine wl))
|
||||
wlid = _wlID wl
|
||||
ips = map zoneOfPoint $ divideLine (2*zoneSize) (_wlLine wl !! 0) (_wlLine wl !! 1)
|
||||
ips = map zoneOfPoint $ uncurry (divideLine (2*zoneSize)) (_wlLine wl)
|
||||
|
||||
|
||||
makePath :: Tree Room -> [(Point2,Point2)]
|
||||
@@ -84,7 +84,7 @@ wallsFromTree t =
|
||||
$ (concatMap _rmPolys $ flatten t)
|
||||
where
|
||||
assignKeys = IM.fromList . zip [0..] . zipWith f [0..]
|
||||
f i (x,y) = defaultWall {_wlLine = [x,y] , _wlID = i}
|
||||
f i (x,y) = defaultWall {_wlLine = (x,y) , _wlID = i}
|
||||
g (x,y) = (x-3855,y - 2613)
|
||||
|
||||
wallsFromRooms :: [Room] -> IM.IntMap Wall
|
||||
@@ -93,14 +93,14 @@ wallsFromRooms =
|
||||
IM.fromList . zip [0..] . zipWith f [0..] . removeInverseWalls
|
||||
. foldr cutWalls [] . concatMap _rmPolys
|
||||
where
|
||||
f i (x,y) = defaultWall {_wlLine = [x,y] , _wlID = i}
|
||||
f i (x,y) = defaultWall {_wlLine = (x,y) , _wlID = i}
|
||||
|
||||
divideWall :: Wall -> [Wall]
|
||||
divideWall wl
|
||||
= let (a:b:_) = _wlLine wl
|
||||
= let (a,b) = _wlLine wl
|
||||
--ps = divideLine (zoneSize * 2) a b
|
||||
ps = divideLine (zoneSize * 2) a b
|
||||
in map (\(x,y) -> wl {_wlLine = [x,y]}) $ zip (init ps) (tail ps)
|
||||
in map (\(x,y) -> wl {_wlLine = (x,y)}) $ zip (init ps) (tail ps)
|
||||
|
||||
divideWallIn :: Wall -> IM.IntMap Wall -> IM.IntMap Wall
|
||||
divideWallIn wl wls =
|
||||
|
||||
Reference in New Issue
Block a user