Refactor path zoning
This commit is contained in:
+6
-5
@@ -11,9 +11,10 @@ module Dodge.Path
|
||||
, bfsNodePoints
|
||||
, fusePairs
|
||||
) where
|
||||
import Dodge.Zoning.Pathing
|
||||
import Dodge.Zoning.Base
|
||||
import Dodge.Data
|
||||
import Dodge.Base.Collide
|
||||
import Dodge.Zone
|
||||
import Geometry.Data
|
||||
import Geometry
|
||||
|
||||
@@ -52,7 +53,7 @@ walkableNodeNear :: World -> Point2 -> Maybe Int
|
||||
walkableNodeNear w p = fmap fst . find (flip (isWalkable p) w . snd) $ nodesNear
|
||||
where
|
||||
--nodesNear = runIdentity . S.toList_ $ nearPoint _pnZoning p w
|
||||
nodesNear = runIdentity . S.toList_ $ aroundPoint _pnZoning p w
|
||||
nodesNear = zonesExtract (w ^. pnZoning) $ zonesAroundPoint pnZoneSize p
|
||||
|
||||
makePathBetweenPs :: Point2 -> Point2 -> World -> Maybe [Point2]
|
||||
makePathBetweenPs a b w = mapMaybe (lab $ _pathGraph w) <$> makePathBetween a b w
|
||||
@@ -137,12 +138,12 @@ addEdges nodemap gr = runIdentity . S.fold_ f (mempty,gr) id
|
||||
obstructPathsCrossing :: EdgeObstacle -> Point2 -> Point2 -> World -> ( World, [(Int,Int,PathEdge)])
|
||||
obstructPathsCrossing obstacletype sp' ep w =
|
||||
( w & pathGraph %~ updateedges
|
||||
, runIdentity $ S.toList_ es
|
||||
, es
|
||||
)
|
||||
where
|
||||
es = S.filter edgecrosses $ nearSeg _peZoning sp' ep w
|
||||
es = filter edgecrosses $ pesNearSeg sp' ep w
|
||||
edgecrosses (_,_,pe) = isJust $ intersectSegSeg sp' ep (_peStart pe) (_peEnd pe)
|
||||
updateedges gr = runIdentity $ S.fold_ updateedge gr id es
|
||||
updateedges gr = foldl' updateedge gr es
|
||||
updateedge gr (x,y,pe)
|
||||
= insEdge (x,y,pe & peObstacles . at obstacletype ?~ ()) $ delEdge (x,y) gr
|
||||
|
||||
|
||||
Reference in New Issue
Block a user