Cleanup and various bugfixes
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user