Implement auto rotate camera when close to walls

This commit is contained in:
2021-09-11 19:55:46 +01:00
parent aa7413a29f
commit f2553ded0e
5 changed files with 52 additions and 69 deletions
+10 -4
View File
@@ -15,9 +15,7 @@ import qualified IntMapHelp as IM
import FoldableHelp
import Control.Lens
--import Control.Monad.State
--import Data.List
--import Data.Function
import qualified Control.Foldl as L
import Data.Maybe
--import Data.Bifunctor
--import qualified Data.IntSet as IS
@@ -219,7 +217,15 @@ collidePointFF = undefined
-- ip = intersectSegSeg p1 p2 p3 p4
-- ref = (_ffDeflect ff) <*> Just g <*> Just (p2 -.- p1) <*> Just ff
-- f p = (p, (ref, _ffID ff))
--
-- | Looks for first collision of a circle with walls.
-- If found, gives wall
collideCircWallsReturnWall :: Point2 -> Float -> IM.IntMap Wall -> Maybe Wall
collideCircWallsReturnWall p rad ws
= L.fold (safeMinimumOnMaybeL (fmap (dist p) . f . _wlLine))
ws
where
f (a,b) = intersectSegSeg p (p -.- rad *.* vNormal (normalizeV (a -.- b))) a b
-- | Looks for first collision of a circle with walls.
-- If found, gives point and reflection velocity, reflection damped in normal.