This commit is contained in:
2022-06-18 00:18:18 +01:00
parent a7c03671d3
commit 6a095d3de6
12 changed files with 49 additions and 36 deletions
+5 -2
View File
@@ -234,10 +234,13 @@ collidePointWalls p1 p2
findPoint (x,y) p = fromMaybe p $ intersectSegSeg p1 p x y
collidePointWallsFilter :: (Wall -> Bool) -> Point2 -> Point2 -> IM.IntMap Wall -> Point2
collidePointWallsFilter t p1 p2
= foldr findPoint p2 . fmap _wlLine . IM.filter t
collidePointWallsFilter t p1 p2 = foldr findPoint p2 . fmap _wlLine . IM.filter t
where
findPoint (x,y) p = fromMaybe p $ intersectSegSeg p1 p x y
collidePointWallsFilter' :: (Wall -> Bool) -> Point2 -> Point2 -> IM.IntMap Wall -> Point2
collidePointWallsFilter' t p1 p2 = foldl' findPoint p2 . fmap _wlLine . IM.filter t
where
findPoint p = fromMaybe p . uncurry (intersectSegSeg p1 p)
-- | Looks for first collision of a circle with walls.
-- If found, gives point and reflection velocity, reflection damped in normal.