Cleanup
This commit is contained in:
@@ -22,15 +22,15 @@ type WallP = (Point2,Point2)
|
||||
cutWalls :: [Point2] -> [WallP] -> [WallP]
|
||||
cutWalls ps wls = case mapMaybe (flip checkWallRight newWalls) newWalls of
|
||||
[] -> newWalls
|
||||
errs -> error $ "cutWalls: when cutting poly:\n" ++ show ps
|
||||
errs -> error $ "during level generation function cutWalls: when cutting poly:\n" ++ show ps
|
||||
++ "\nRight corner errors:\n"
|
||||
++ unlines (map show errs)
|
||||
++ "\nStart walls:\n"
|
||||
++ unlines (map show wls)
|
||||
++ "\nEnd walls:\n"
|
||||
++ unlines (map show newWalls)
|
||||
++ "\nLeft corner errors:\n"
|
||||
++ unlines (map show errsL)
|
||||
++ "\nWalls before cut:\n"
|
||||
++ unlines (map show wls)
|
||||
++ "\nWalls after cut:\n"
|
||||
++ unlines (map show newWalls)
|
||||
where
|
||||
newWalls = cutWalls' ps wls
|
||||
errsL = mapMaybe (flip checkWallLeft newWalls) newWalls
|
||||
@@ -144,30 +144,27 @@ fusePoint ps p = fromMaybe p $ findClosePoint ps p
|
||||
-- if either wall point is not moved, this point gets added to the list
|
||||
fuseWall :: ([Point2], WallP) -> ([Point2], WallP)
|
||||
fuseWall (ps, (x,y)) = ( nub (x':y':ps) , (x',y') )
|
||||
where x' = fusePoint ps x
|
||||
y' = fusePoint (x':ps) y
|
||||
where
|
||||
x' = fusePoint ps x
|
||||
y' = fusePoint (x':ps) y
|
||||
|
||||
-- given list of points and collection of walls, fuses the wall ends if
|
||||
-- they are close to the list of points or each other
|
||||
fuseWallsWith :: [Point2] -> [WallP] -> [WallP]
|
||||
fuseWallsWith zs ws = snd $ foldr fuseWalls' (zs, []) ws
|
||||
where fuseWalls' w (ps, ws) = let (qs, w') = fuseWall (ps, w)
|
||||
in (qs, w' : ws)
|
||||
where
|
||||
fuseWalls' w (ps, ws) =
|
||||
let (qs, w') = fuseWall (ps, w)
|
||||
in (qs, w' : ws)
|
||||
|
||||
wallIsZeroLength (x,y) = x == y
|
||||
|
||||
removeWallsInPolygon :: [Point2] -> [WallP] -> [WallP]
|
||||
removeWallsInPolygon ps walls = filter (not . cond) walls
|
||||
where cond wall = pointInsidePolygon (fst wall) ps
|
||||
where
|
||||
cond wall = pointInsidePolygon (fst wall) ps
|
||||
&& pointInsidePolygon (snd wall) ps
|
||||
|
||||
pointInsidePolygon :: Point2 -> [Point2] -> Bool
|
||||
pointInsidePolygon p (x:xs) = all (\l -> not (uncurry isRHS l (p +.+ normalizeV s))) pairs
|
||||
|| any (\l -> uncurry isOnLine l p) pairs
|
||||
where pairs = zip (x:xs) (xs ++ [x])
|
||||
s = ((1/fromIntegral (length (x:xs))) *.* (foldr1 (+.+) (x:xs)))
|
||||
-.- p
|
||||
|
||||
------------------------------------------------------------------------------------
|
||||
-- idea: create inner walls to draw and to cast shadows
|
||||
createInnerWalls :: IM.IntMap Wall -> IM.IntMap Wall
|
||||
|
||||
Reference in New Issue
Block a user