Continue streaming refactor
This commit is contained in:
@@ -18,6 +18,7 @@ module Dodge.Base.Collide
|
||||
, wallsOnCirc
|
||||
, wallsOnCirc'
|
||||
, wallsOnLineHit
|
||||
, collideCircWallsStream
|
||||
, collideCircWalls
|
||||
, collideCircWallsList
|
||||
-- , collideCircWalls'
|
||||
@@ -320,6 +321,21 @@ overlapCircWalls p r = S.mapMaybe dointersect
|
||||
dointersect wl = f (_wlLine wl) <&> (,wl)
|
||||
f (a,b) = intersectSegSeg p (p -.- r *.* vNormal (normalizeV (a -.- b))) a b
|
||||
|
||||
collideCircWallsStream :: Point2 -> Point2 -> Float -> Stream (Of Wall) Identity ()
|
||||
-> (Point2, Maybe Wall)
|
||||
collideCircWallsStream sp ep rad = runIdentity
|
||||
. S.fold_ findPoint (ep, Nothing) id
|
||||
where
|
||||
findPoint (p,mwl) wl = maybe (p,mwl) (,Just wl) . uncurry (intersectSegSeg sp p)
|
||||
. shiftbyrad
|
||||
. _wlLine $ wl
|
||||
shiftbyrad (a,b) = bimap f f
|
||||
(a +.+ rad *.* normalizeV (a -.-b)
|
||||
,b +.+ rad *.* normalizeV (b -.-a)
|
||||
)
|
||||
where
|
||||
f = ((rad *.* normalizeV (vNormal $ a -.- b)) +.+)
|
||||
|
||||
overlapCircWallsClosest :: Point2 -> Float -> Stream (Of Wall) Identity () -> Maybe (Point2,Wall)
|
||||
overlapCircWallsClosest p r = runIdentity
|
||||
. L.purely S.fold_ (L.minimumBy (compare `on` (dist p . fst)))
|
||||
|
||||
Reference in New Issue
Block a user