Cleanup door mounts, noticed space leak when no debug-display paths

This commit is contained in:
2025-10-25 22:49:37 +01:00
parent cbf0f47b9b
commit 61910785c4
16 changed files with 217550 additions and 864094 deletions
+24 -14
View File
@@ -55,13 +55,16 @@ getEdgesCrossing s e w = filter inedgecrosses $ nearSeg peZoneSize _incEdgeZonin
updateEdge ::
(Set.Set EdgeObstacle -> Set.Set EdgeObstacle) ->
(Int, Int) ->
V.Vector [(Int, SimpleEdge)] ->
V.Vector [(Int, SimpleEdge)]
updateEdge f (i, j) = ix i . each %~ g
where
g (k, o)
| j == k = (k, o & seObstacles %~ f)
| otherwise = (k, o)
-- V.Vector [(Int, SimpleEdge)] ->
-- V.Vector [(Int, SimpleEdge)]
V.Vector (IM.IntMap SimpleEdge) ->
V.Vector (IM.IntMap SimpleEdge)
updateEdge f (i, j) = ix i . ix j . seObstacles %~ f
--updateEdge f (i, j) = ix i . each %~ g
-- where
-- g (k, o)
-- | j == k = (k, o & seObstacles %~ f)
-- | otherwise = (k, o)
makePathUsing :: (Set.Set EdgeObstacle -> Bool) -> Point2 -> Point2 -> World -> Maybe [Int]
makePathUsing t s e w = do
@@ -70,10 +73,13 @@ 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
-- 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
getn i = w ^?! cWorld . incNode . ix i
makePathBetween :: Point2 -> Point2 -> World -> Maybe [Int]
@@ -107,7 +113,8 @@ pointTowardsImpulse a b w = find (flip (isWalkable a) w) =<< makePathBetweenPs b
pairsToIncGraph ::
Set.Set (Point2, Point2) ->
( UV.Vector Point2
, V.Vector [(Int, SimpleEdge)]
--, V.Vector [(Int, SimpleEdge)]
, V.Vector (IM.IntMap SimpleEdge)
, [(Int, Int)]
)
pairsToIncGraph pairs =
@@ -116,11 +123,14 @@ pairsToIncGraph pairs =
, Set.toList pairs & each . each %~ (\i -> pToNode ^?! ix i)
)
where
incgraph :: V.Vector (IM.IntMap SimpleEdge)
incgraph = V.generate (length im) (im IM.!)
im = IM.fromListWith (++) . fmap toedge $ Set.toList pairs
-- I'm not fully happy with using the monoidal instance of IntMap here
-- especially seeing as there are two levels of IntMaps.
im = IM.fromListWith (<>) . fmap toedge $ Set.toList pairs
toedge (x, y) =
( pToNode ^?! ix x
, [(pToNode ^?! ix y, SimpleEdge (distance x y) mempty)]
, IM.fromList [(pToNode ^?! ix y, SimpleEdge (distance x y) mempty)]
)
pToNode = IM.invertIntMapUnique . IM.fromDistinctAscList $ zip [0 ..] ps
inodes = UV.generate (length ps) (ps !!)