Improve wall squashing further

This commit is contained in:
2026-03-26 20:25:59 +00:00
parent 62a37388e7
commit 0ddedf7fd6
9 changed files with 99 additions and 79 deletions
+10 -4
View File
@@ -1,5 +1,7 @@
-- | Deals with moving creature wall collisions.
module Dodge.WallCreatureCollisions (colCrsWalls) where
module Dodge.WallCreatureCollisions (colCrsWalls,
wlWlCrush
) where
import qualified Data.IntMap.Strict as IM
import Control.Lens
@@ -45,7 +47,8 @@ pushCr wls cr
& crPos . _xy .~ ap
| otherwise = ecr
where
twls = IM.elems $ IM.restrictKeys wls (ecr ^. crWallTouch)
stwls = IM.filter (\wl -> uncurry circOnSegNoEndpoints (wl ^. wlLine) sp r) wls
twls = IM.elems $ IM.restrictKeys wls (ecr ^. crWallTouch) -- `IM.union` stwls
ep = ecr ^. crPos . _xy
ap = cr ^. crOldPos . _xy
sp = cr ^. crPos . _xy
@@ -60,9 +63,12 @@ wlsCrush [] = False
wlsCrush (x:xs) = any (wlWlCrush x) xs || wlsCrush xs
wlWlCrush :: Wall -> Wall -> Bool
wlWlCrush w1 w2 = angleVV (f w1) (f w2) > 0.75 * pi
wlWlCrush w1 w2 = norm (f w1 + f w2) < 0.5
where
f = uncurry (-) . (^. wlLine)
f = normalizeV . uncurry (-) . (^. wlLine)
--wlWlCrush w1 w2 = angleVV (f w1) (f w2) > 0.75 * pi
-- where
-- f = uncurry (-) . (^. wlLine)
-- the amount to push creatures out from walls, extra to their radius
wallBuffer :: Float