Remove more (dead) Streaming code
This commit is contained in:
@@ -13,17 +13,12 @@
|
||||
-}
|
||||
module Dodge.Base.Collide (
|
||||
collidePoint,
|
||||
collideSegCrs,
|
||||
collidePointWallsFilterStream,
|
||||
collidePointWallsFilter,
|
||||
collidePointTestFilter,
|
||||
overlapSegWalls,
|
||||
overlapSegCrs,
|
||||
overlap1SegCrs,
|
||||
bounceBall,
|
||||
bouncePoint,
|
||||
sortStreamOn,
|
||||
minStreamOn,
|
||||
collideCircWallsStream,
|
||||
circOnSomeWall,
|
||||
circOnAnyCr,
|
||||
overlapCircWalls,
|
||||
@@ -49,16 +44,6 @@ import Dodge.Zoning
|
||||
import FoldableHelp
|
||||
import Geometry
|
||||
import qualified IntMapHelp as IM
|
||||
import qualified Streaming.Prelude as S
|
||||
import StreamingHelp
|
||||
|
||||
--collidePoint :: Point2 -> Point2
|
||||
-- -> StreamOf Wall
|
||||
-- -> (Point2, Maybe Wall)
|
||||
--{-# INLINE collidePoint #-}
|
||||
--collidePoint sp ep = runIdentity . S.fold_ findPoint (ep, Nothing) id
|
||||
-- where
|
||||
-- findPoint (p,mwl) wl = maybe (p,mwl) (,Just wl) . uncurry (intersectSegSeg sp p) . _wlLine $ wl
|
||||
|
||||
collidePoint ::
|
||||
Point2 ->
|
||||
@@ -70,39 +55,15 @@ collidePoint sp ep = foldl' findPoint (ep, Nothing)
|
||||
where
|
||||
findPoint (p, mwl) wl = maybe (p, mwl) (,Just wl) . uncurry (intersectSegSeg sp p) . _wlLine $ wl
|
||||
|
||||
overlap1SegCrs ::
|
||||
overlapSegCrs ::
|
||||
Point2 ->
|
||||
Point2 ->
|
||||
[Creature] ->
|
||||
[(Point2, Creature)]
|
||||
{-# INLINE overlap1SegCrs #-}
|
||||
overlap1SegCrs sp ep =
|
||||
mapMaybe
|
||||
(\cr -> (,cr) <$> listToMaybe (intersectCircSeg (_crPos cr) (_crRad cr) sp ep))
|
||||
|
||||
overlapSegCrs ::
|
||||
Point2 ->
|
||||
Point2 ->
|
||||
StreamOf Creature ->
|
||||
StreamOf ([Point2], Creature)
|
||||
{-# INLINE overlapSegCrs #-}
|
||||
overlapSegCrs sp ep =
|
||||
S.mapMaybe
|
||||
(\cr -> f cr $ intersectCircSeg (_crPos cr) (_crRad cr) sp ep)
|
||||
where
|
||||
f _ [] = Nothing
|
||||
f cr ps = Just (ps, cr)
|
||||
|
||||
collideSegCrs ::
|
||||
Point2 ->
|
||||
Point2 ->
|
||||
StreamOf Creature ->
|
||||
(Point2, Maybe Creature)
|
||||
{-# INLINE collideSegCrs #-}
|
||||
collideSegCrs sp ep = runIdentity . S.fold_ findPoint (ep, Nothing) id
|
||||
where
|
||||
findPoint (p, mcr) cr =
|
||||
maybe (p, mcr) (,Just cr) $ listToMaybe (intersectCircSeg (_crPos cr) (_crRad cr) sp p)
|
||||
mapMaybe
|
||||
(\cr -> (,cr) <$> listToMaybe (intersectCircSeg (_crPos cr) (_crRad cr) sp ep))
|
||||
|
||||
doBounce :: Float -> Point2 -> Point2 -> (Point2, Maybe Wall) -> Maybe (Point2, Point2)
|
||||
{-# INLINE doBounce #-}
|
||||
@@ -124,7 +85,7 @@ bounceBall x sp ep r = doBounce x sp ep . collideCircWalls sp ep r
|
||||
|
||||
bouncePoint :: (Wall -> Bool) -> Float -> Point2 -> Point2 -> World -> Maybe (Point2, Point2)
|
||||
{-# INLINE bouncePoint #-}
|
||||
bouncePoint t x sp ep = doBounce x sp ep . collidePointWallsFilterStream t sp ep
|
||||
bouncePoint t x sp ep = doBounce x sp ep . collidePointWallsFilter t sp ep
|
||||
|
||||
-- this COULD be written in terms of collidePointWallsFilterStream, TODO test
|
||||
-- whether this is actually faster
|
||||
@@ -142,9 +103,9 @@ collidePointTestFilter t sp ep =
|
||||
-- . S.any_ (isJust . uncurry (intersectSegSeg sp ep) . _wlLine)
|
||||
-- . S.filter t
|
||||
|
||||
collidePointWallsFilterStream :: (Wall -> Bool) -> Point2 -> Point2 -> World -> (Point2, Maybe Wall)
|
||||
{-# INLINE collidePointWallsFilterStream #-}
|
||||
collidePointWallsFilterStream t sp ep =
|
||||
collidePointWallsFilter :: (Wall -> Bool) -> Point2 -> Point2 -> World -> (Point2, Maybe Wall)
|
||||
{-# INLINE collidePointWallsFilter #-}
|
||||
collidePointWallsFilter t sp ep =
|
||||
collidePoint sp ep
|
||||
. filter t
|
||||
. wlsNearSeg sp ep
|
||||
@@ -225,31 +186,6 @@ collideCircWalls sp ep rad = foldl' findPoint (ep, Nothing)
|
||||
where
|
||||
f = (+.+) (rad *.* normalizeV (vNormal $ a -.- b))
|
||||
|
||||
-- | note that this does not push the circle away from the wall at all
|
||||
collideCircWallsStream ::
|
||||
Point2 ->
|
||||
Point2 ->
|
||||
Float ->
|
||||
StreamOf Wall ->
|
||||
(Point2, Maybe Wall)
|
||||
{-# INLINE collideCircWallsStream #-}
|
||||
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 -> [Wall] -> Maybe (Point2, Wall)
|
||||
{-# INLINE overlapCircWallsClosest #-}
|
||||
overlapCircWallsClosest p r =
|
||||
|
||||
Reference in New Issue
Block a user