Cleanup and various bugfixes

This commit is contained in:
2021-11-16 21:31:53 +00:00
parent ebe9ad6b90
commit 5d0b48829c
12 changed files with 103 additions and 39 deletions
-8
View File
@@ -92,14 +92,6 @@ data RoomPos
| LabPos Int RoomPos
deriving (Eq,Ord,Show)
extractRoomPos :: RoomPos -> (Point2,Float)
extractRoomPos rp = case rp of
OutLink _ p a -> (p,a)
InLink p a -> (p,a)
UnusedLink p a -> (p,a)
PosPl p a -> (p,a)
LabPos _ rp' -> extractRoomPos rp'
makeLenses ''Room
makeLenses ''PSType
makeLenses ''PlacementSpot
+8
View File
@@ -7,6 +7,7 @@ module Dodge.LevelGen.StaticWalls
, removeInverseWalls
, expandPolyByFixed
, cutPoly
, expandPolyCorners
)
where
import Geometry
@@ -96,6 +97,13 @@ expandPolyByFixed :: Float -> [Point2] -> [Point2]
expandPolyByFixed x ps = map f ps
where
f p = p +.+ x *.* safeNormalizeV (p -.- centroid ps)
-- | Given a value and a poly, pushes points out by a fixed amount along an
-- angle determined by the corner, i.e. by the two other neighbour points
expandPolyCorners :: Float -> [Point2] -> [Point2]
expandPolyCorners d (x:y:z:xs) = zipWith3 f (x:y:z:xs) (y:z:xs++[x]) (z:xs ++ [x,y])
where
f l c r = c +.+ d *.* normalizeV (normalizeV (c -.- r) +.+ normalizeV (c -.- l))
expandPolyCorners _ _ = error "trying to expand poly corners of 2 or fewer points"
-- | Given a polygon expressed as a list of points and a collection of walls,
-- returns:
-- fst: points of the polygon's intersection with walls