Generate walls using points, fix at least some potential errors

This commit is contained in:
2021-03-29 02:12:14 +02:00
parent 34ddd01825
commit 9608655947
3 changed files with 112 additions and 129 deletions
+13 -1
View File
@@ -11,6 +11,7 @@ import Dodge.RandomHelp
import Dodge.Path
import Dodge.Layout.Tree
import Dodge.Room.Data
import Dodge.Default
import Geometry
@@ -60,8 +61,19 @@ generateFromTree t w = zoning $ placeSpots plmnts
makePath :: Tree Room -> [(Point2,Point2)]
makePath = concat . map _rmPath . flatten
-- consider nubbing walls after dividing them
wallsFromTree :: Tree Room -> IM.IntMap Wall
wallsFromTree t = createInnerWalls $ nubWalls $ divideWalls $ foldr cutWalls IM.empty (concatMap _rmPolys $ flatten t)
wallsFromTree t =
createInnerWalls
. divideWalls
. assignKeys
. foldr cutWalls [] -- $ map (map (g . roundPoint2))
. map (map roundPoint2)
$ (concatMap _rmPolys $ flatten t)
where
assignKeys = IM.fromList . zip [0..] . zipWith f [0..]
f i (x,y) = defaultWall {_wlLine = [x,y] , _wlID = i}
g (x,y) = (x-3855,y - 2613)
divideWall :: Wall -> [Wall]
divideWall wl