Make thingsHit use streaming
This commit is contained in:
@@ -13,8 +13,10 @@ module Dodge.Base.Collide
|
||||
( collidePoint
|
||||
, collidePointWallsFilterStream
|
||||
, collidePointTestFilter
|
||||
, overlapSegWalls
|
||||
, bounceBall
|
||||
, bouncePoint
|
||||
, sortStreamOn
|
||||
-- , wallsOnCirc
|
||||
-- , wallsOnCirc'
|
||||
, wallsOnLineHit
|
||||
@@ -95,8 +97,9 @@ collidePointWallsFilterStream t sp ep = collidePoint sp ep
|
||||
. wallsAlongLine sp ep
|
||||
|
||||
--orderStreamOn :: Ord b => (a -> b) -> Stream (Of a) Identity () -> Identity (Of (M.Map b a) ())
|
||||
orderStreamOn :: Ord a => (b -> a) -> Stream (Of b) Identity () -> Stream (Of b) Identity ()
|
||||
orderStreamOn f = S.each . runIdentity . L.purely S.fold_ L.map . S.map g
|
||||
sortStreamOn :: Ord a => (b -> a) -> Stream (Of b) Identity () -> Stream (Of b) Identity ()
|
||||
{-# INLINE sortStreamOn #-}
|
||||
sortStreamOn f = S.each . runIdentity . L.purely S.fold_ L.map . S.map g
|
||||
where
|
||||
g x = (f x,x)
|
||||
|
||||
@@ -107,7 +110,7 @@ overlapSegWalls sp ep = S.mapMaybe $ \wl -> uncurry (intersectSegSeg sp ep) (_wl
|
||||
visibleWalls :: Point2 -> Point2 -> World -> Stream (Of (Point2,Wall)) Identity ()
|
||||
visibleWalls sp ep = S.take 1 <=< -- hlint, was using join and fmap
|
||||
( S.span (not . wlIsOpaque . snd)
|
||||
. orderStreamOn (dist sp . fst)
|
||||
. sortStreamOn (dist sp . fst)
|
||||
. overlapSegWalls sp ep
|
||||
. wallsAlongLine sp ep )
|
||||
|
||||
|
||||
Reference in New Issue
Block a user