Refactor modules

This commit is contained in:
jgk
2021-07-25 01:29:43 +02:00
parent e453065afe
commit 84a9badea8
38 changed files with 77 additions and 48 deletions
+2 -9
View File
@@ -5,10 +5,10 @@ module Dodge.Base.Collide
import Dodge.Data
import Dodge.Base.Zone
import Geometry
import FoldableHelp
--import Data.List
import Data.Maybe
import Data.Foldable
import qualified Data.IntMap.Strict as IM
import Control.Lens
@@ -26,13 +26,6 @@ safeMinimumOn' f (x:xs) = g x (f x) xs
| otherwise = g v mv ys
where my = f y
safeMinimumOn :: (Foldable t,Ord b) => (a -> b) -> t a -> Maybe a
safeMinimumOn f = foldl' g Nothing
where
g (Just x) y
| f x < f y = Just x
| otherwise = Just y
g Nothing y = Just y
hasLOS :: Point2 -> Point2 -> World -> Bool
{-# INLINE hasLOS #-}
@@ -46,7 +39,7 @@ hitPointLines
hitPointLines p1 p2
= safeMinimumOn (dist p1 . fst)
. mapMaybe
(\(x,y) -> (, (x,y)) <$> (intersectSegSeg' p1 p2 x y))
(\(x,y) -> (, (x,y)) <$> intersectSegSeg' p1 p2 x y)
-- | looks for first collision of a point with walls
-- if found, gives point and reflection velocity