Commit before trying IntMap instead of vector for incidence graph

This commit is contained in:
2025-10-26 08:31:54 +00:00
parent 61910785c4
commit b8536e2929
7 changed files with 369291 additions and 187170 deletions
+2 -1
View File
@@ -210,7 +210,8 @@ collidePointWallsFilter t sp ep = collidePoint sp ep . filter t . wlsNearSeg sp
overlapSegWalls :: Point2 -> Point2 -> [Wall] -> [(Point2, Wall)]
{-# INLINE overlapSegWalls #-}
overlapSegWalls sp ep = mapMaybe $ \wl -> uncurry (intersectSegSeg sp ep) (_wlLine wl) <&> (,wl)
overlapSegWalls sp ep = mapMaybe
$ \wl -> uncurry (intersectSegSeg sp ep) (_wlLine wl) <&> (,wl)
visibleWalls :: Point2 -> Point2 -> World -> [(Point2, Wall)]
{-# INLINE visibleWalls #-}
+1 -7
View File
@@ -55,16 +55,10 @@ 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)]
V.Vector (IM.IntMap SimpleEdge) ->
V.Vector (IM.IntMap SimpleEdge)
{-# INLINE updateEdge #-}
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
+1 -3
View File
@@ -141,9 +141,7 @@ wlsHit sp ep = sortOn (dist sp . fst) . wlsHitUnsorted sp ep
wlsHitUnsorted :: Point2 -> Point2 -> World -> [(Point2, Wall)]
wlsHitUnsorted sp ep
| sp == ep = const mempty
| otherwise =
overlapSegWalls sp ep
. wlsNearSeg sp ep
| otherwise = overlapSegWalls sp ep . wlsNearSeg sp ep
wlsHitRadial :: Point2 -> Float -> World -> [(Point2, Wall)]
wlsHitRadial p r = mapMaybe f . wlsNearCirc p r
+2 -1
View File
@@ -76,7 +76,8 @@ doLoop spf window worldSideEffects eventFn startWorld = do
maybeUpdatedWorld <- pollEvents >>= foldM (applyEventIO eventFn) (Just worldAfterSimStep)
case maybeUpdatedWorld of
Just updatedWorld -> do
performGC
performGC -- potentially use performMinorGC
-- https://stackoverflow.com/questions/30244139/how-to-keep-very-big-elements-on-memory-without-exhausting-the-garbage-collector
endTicks <- ticks -- it might be better to use System.Clock (monotonic)
let theDelay = max 0 (spf + fromIntegral startTicks - fromIntegral endTicks)
threadDelay (theDelay * 1000)