Continue to work on pathfinding
This commit is contained in:
+12
-27
@@ -251,22 +251,20 @@ drawInspectWalls w = concat $ do
|
||||
)
|
||||
|
||||
drawInspectWall :: World -> Wall -> Picture
|
||||
drawInspectWall w wl =
|
||||
drawInspectWall _ wl =
|
||||
setLayer DebugLayer $
|
||||
color rose (thickLine 3 [a, b])
|
||||
<> foldMap (drawDoorPaths w) (wl ^? wlStructure . wsDoor)
|
||||
-- <> foldMap (drawDoorPaths w) (wl ^? wlStructure . wsDoor)
|
||||
where
|
||||
(a, b) = _wlLine wl
|
||||
|
||||
drawDoorPaths :: World -> Int -> Picture
|
||||
drawDoorPaths w drid = concat $ do
|
||||
paths <- w ^? cWorld . lWorld . doors . ix drid . drObstructs
|
||||
return $ foldMap' (drawPathEdge . (^. penPathEdge)) paths
|
||||
--drawDoorPaths :: World -> Int -> Picture
|
||||
--drawDoorPaths w drid = concat $ do
|
||||
-- paths <- w ^? cWorld . lWorld . doors . ix drid . drObstructs
|
||||
-- return $ foldMap' (drawPathEdge . (^. penPathEdge)) paths
|
||||
|
||||
drawPathEdge :: PathEdge -> Picture
|
||||
drawPathEdge pe =
|
||||
setLayer DebugLayer $
|
||||
multiArrow (_peStart pe) (_peEnd pe) green (S.map obstacleColor (_peObstacles pe))
|
||||
drawPathEdge :: Point2 -> Point2 -> S.Set EdgeObstacle -> Picture
|
||||
drawPathEdge x y pe = setLayer DebugLayer $ multiArrow x y green (S.map obstacleColor pe)
|
||||
|
||||
obstacleColor :: EdgeObstacle -> Color
|
||||
obstacleColor eo = case eo of
|
||||
@@ -403,16 +401,6 @@ drawWlIDs w = setLayer FixedCoordLayer $ foldMap f (w ^. cWorld . lWorld . walls
|
||||
where
|
||||
p = worldPosToScreen (w ^. wCam) $ 0.5 *.* uncurry (+.+) (_wlLine wl)
|
||||
|
||||
|
||||
drawPathing' :: Config -> World -> Picture
|
||||
drawPathing' cfig w =
|
||||
setLayer DebugLayer $
|
||||
foldMap (edgeToPic (screenPolygon cfig (w ^. wCam)) . (^?! _3)) (FGL.labEdges gr)
|
||||
<> foldMap dispInc (graphToIncidence gr)
|
||||
where
|
||||
dispInc (p, n) = setDepth 2 . uncurryV translate p . scale 0.1 0.1 $ text $ show n
|
||||
gr = w ^. cWorld . pathGraph
|
||||
|
||||
drawPathing :: Config -> World -> Picture
|
||||
drawPathing cfig w =
|
||||
setLayer DebugLayer $ ifoldMap f $ w ^. cWorld . incGraph
|
||||
@@ -420,12 +408,9 @@ drawPathing cfig w =
|
||||
inodes = w ^. cWorld . incNode
|
||||
f i = foldMap (g i)
|
||||
g i (j,se) = edgeToPic (screenPolygon cfig (w ^.wCam))
|
||||
(PathEdge (inodes ^?! ix i) (inodes ^?! ix j) 0 (se ^. seObstacles))
|
||||
(inodes ^?! ix i) (inodes ^?! ix j) (se ^. seObstacles)
|
||||
|
||||
edgeToPic :: [Point2] -> PathEdge -> Picture
|
||||
edgeToPic poly pe
|
||||
edgeToPic :: [Point2] -> Point2 -> Point2 -> S.Set EdgeObstacle -> Picture
|
||||
edgeToPic poly sp ep pe
|
||||
| not (pointInPoly sp poly) && not (pointInPoly ep poly) = mempty
|
||||
| otherwise = drawPathEdge pe
|
||||
where
|
||||
sp = _peStart pe
|
||||
ep = _peEnd pe
|
||||
| otherwise = drawPathEdge sp ep pe
|
||||
|
||||
Reference in New Issue
Block a user