Fix bug in line zoning by using less ambitious algorithm

This commit is contained in:
2022-02-13 09:24:27 +00:00
parent 0a860e6f68
commit 9af636aa83
10 changed files with 65 additions and 22 deletions
+6 -3
View File
@@ -143,7 +143,7 @@ updateInstantParticles w = case _instantParticles w of
in updateInstantParticles $ w' & particles %~ (catMaybes ps' ++)
updateMIM :: ASetter' World (IM.IntMap a) -> (a -> a -> Maybe a) -> World -> World
updateMIM f up w = w & f %~ IM.mapMaybe (dbArg up)
updateMIM f up = f %~ IM.mapMaybe (dbArg up)
-- Note that this updates the randgen
--updateCreatures :: World -> World
@@ -160,12 +160,15 @@ updateMIM f up w = w & f %~ IM.mapMaybe (dbArg up)
ppEvents :: World -> World
ppEvents w = IM.foldl' (flip $ \pp -> _ppEvent pp pp) w $ _pressPlates w
-- this is not working correctly, maybe a problem with wallsAlongLine
updateSeenWalls :: World -> World
updateSeenWalls w = foldl' markWallSeen w wallsToUpdate
where
vPos = _cameraViewFrom w
wallsToUpdate = concatMap (\p -> visibleWalls vPos (vPos +.+p) $ wallsAlongLine vPos (vPos +.+ p) w)
$ nRays 20
-- wallsToUpdate = concatMap (\p -> visibleWalls vPos (vPos +.+p) $ _walls w)
-- $ nRays 20
markWallSeen :: World -> Wall -> World
markWallSeen w wl = w { _walls = IM.adjust mw (_wlID wl) $ _walls w }
@@ -269,7 +272,7 @@ crCrSpring c1 c2 w
{- Finds the visible walls from a point to another point. -}
visibleWalls :: Point2 -> Point2 -> IM.IntMap Wall -> [Wall]
visibleWalls p1 p2 ws
= takeUntil theTest
= takeUntil isOpaque
. map snd
. sortOn (dist p1 . fromJust . fst)
. filter (isJust . fst)
@@ -277,7 +280,7 @@ visibleWalls p1 p2 ws
$ IM.elems ws
where
f wl = (uncurry intersectSegSeg (_wlLine wl) p1 p2, wl)
theTest wl = _wlOpacity wl /= Opaque
isOpaque wl = _wlOpacity wl == Opaque
updateDelayedEvents :: World -> World
updateDelayedEvents w = let (neww,newde) = mapAccumR f w (_delayedEvents w)