Improve room clip testing
This commit is contained in:
+10
-2
@@ -33,8 +33,16 @@ roomTreex = do
|
|||||||
struct' <- aTreeStrut
|
struct' <- aTreeStrut
|
||||||
let struct = Node [EndRoom] []
|
let struct = Node [EndRoom] []
|
||||||
let t' = padCorridors struct
|
let t' = padCorridors struct
|
||||||
t = treeTrunk [[StartRoom],[OrAno [--[DoorAno],[Corridor],
|
t = treeTrunk
|
||||||
[DoorNumAno 0,AirlockAno]] ],[FirstWeapon],[Corridor]] t'
|
[[StartRoom]
|
||||||
|
,[OrAno [[DoorAno]
|
||||||
|
,[Corridor]
|
||||||
|
,[DoorNumAno 0,AirlockAno]]
|
||||||
|
]
|
||||||
|
,[FirstWeapon]
|
||||||
|
,[Corridor]
|
||||||
|
]
|
||||||
|
t'
|
||||||
fmap (shiftExpandTree . expandTreeBy id) $ mapM annoToRoomTree t
|
fmap (shiftExpandTree . expandTreeBy id) $ mapM annoToRoomTree t
|
||||||
|
|
||||||
levx :: RandomGen g => State g [Room]
|
levx :: RandomGen g => State g [Room]
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ shiftRoomTreeSearchAll bs (Node r ts :<| ts')
|
|||||||
where
|
where
|
||||||
ls = init $ _rmLinks r
|
ls = init $ _rmLinks r
|
||||||
newBounds = _rmBound r : bs
|
newBounds = _rmBound r : bs
|
||||||
roomIsClipping = any (polysIntersect (_rmBound r)) bs
|
roomIsClipping = any (polysOverlap (_rmBound r)) bs
|
||||||
rm l = r & rmLinks %~ delete l
|
rm l = r & rmLinks %~ delete l
|
||||||
f l = applyToRoot (shiftRoomToLink l)
|
f l = applyToRoot (shiftRoomToLink l)
|
||||||
|
|
||||||
|
|||||||
+7
-2
@@ -226,9 +226,14 @@ polysIntersect (p:ps) (q:qs)
|
|||||||
where
|
where
|
||||||
pairs1 = zip (p:ps) (ps++[p])
|
pairs1 = zip (p:ps) (ps++[p])
|
||||||
pairs2 = zip (q:qs) (qs++[q])
|
pairs2 = zip (q:qs) (qs++[q])
|
||||||
|
polysIntersect _ _ = False
|
||||||
|
|
||||||
polysIntersect [] _ = False
|
-- | Test whether two polygons intersect or if one is contained in the other.
|
||||||
polysIntersect _ [] = False
|
polysOverlap :: [Point2] -> [Point2] -> Bool
|
||||||
|
polysOverlap (p:ps) (q:qs) = polysIntersect (p:ps) (q:qs)
|
||||||
|
|| pointInPolygon p (q:qs)
|
||||||
|
|| pointInPolygon q (p:ps)
|
||||||
|
polysOverlap _ _ = False
|
||||||
|
|
||||||
-- | Test whether any polygons from a first list intersect with any polygons from
|
-- | Test whether any polygons from a first list intersect with any polygons from
|
||||||
-- a second list.
|
-- a second list.
|
||||||
|
|||||||
Reference in New Issue
Block a user