Hack solution to path graph space leak: evaluate all edge obstacles

This commit is contained in:
2025-10-26 11:38:22 +00:00
parent b8536e2929
commit c55c3e874d
9 changed files with 19608 additions and 399694 deletions
+4 -16
View File
@@ -8,7 +8,7 @@ module Dodge.Path (
walkableNodeNear,
snapToGrid,
pairsToIncGraph,
updateEdge,
-- updateEdge,
getEdgesCrossing,
) where
@@ -35,16 +35,8 @@ import Geometry
import qualified IntMapHelp as IM
import Linear
getNodePos :: Int -> World -> Maybe Point2
getNodePos i w = w ^? cWorld . incNode . ix i
--getEdgesCrossingPoly :: [Point2] -> World -> [(Int,Int)]
--getEdgesCrossingPoly ps w = filter tcross $ zonesExtract (w ^. incEdgeZoning)
-- $ Set.toList $ foldMap (uncurry $ zoneOfSegSet peZoneSize) $ pairs
-- where
-- pairs = loopPairs ps
-- tcross (i,j) = any (isJust . uncurry (intersectSegSeg (f i) (f j))) pairs
-- f i = w ^?! cWorld . incNode . ix i
getNodePos :: Int -> World -> Point2
getNodePos i w = w ^?! cWorld . incNode . ix i
getEdgesCrossing :: Point2 -> Point2 -> World -> [(Int,Int)]
getEdgesCrossing s e w = filter inedgecrosses $ nearSeg peZoneSize _incEdgeZoning s e w
@@ -67,10 +59,6 @@ makePathUsing t s e w = do
let h i = distance (getn nb) (getn i)
(na :) . snd <$> AS.aStarAssoc getes h (== nb) na
where
-- g (i, SimpleEdge c o)
-- | t o = Just (i, c)
-- | otherwise = Nothing
--getes i = mapMaybe g $ w ^?! cWorld . incGraph . ix i
getes i = IM.toList
. IM.map (^. seDist)
. IM.filter (^. seObstacles . to t) $ w ^?! cWorld . incGraph . ix i
@@ -98,7 +86,7 @@ smallSnailInt2 =
[V2 x y | x <- [-2 .. 2], y <- [-2 .. 2]]
makePathBetweenPs :: Point2 -> Point2 -> World -> Maybe [Point2]
makePathBetweenPs a b w = traverse (`getNodePos` w) =<< makePathBetween a b w
makePathBetweenPs a b w = fmap (`getNodePos` w) <$> makePathBetween a b w
-- assumes that pathfinding is symmetric
pointTowardsImpulse :: Point2 -> Point2 -> World -> Maybe Point2