Files
loop/src/Dodge/Viewpoints.hs
T
2023-01-06 16:55:17 +00:00

43 lines
1.3 KiB
Haskell

module Dodge.Viewpoints (
getViewpoints,
-- farWallPoints,
) where
import Dodge.Data.CWorld
import Dodge.GameRoom
import Geometry
--farWallPoints :: Point2 -> CWorld -> [Point2]
--farWallPoints p w = concatMap _grViewpoints grs ++ extendedViewPoints p grs
-- where
-- grs = filter (pointInOrOnPolygon p . _grBound) (_cwgGameRooms $ _cwGen w)
--
--extendedViewPoints :: Point2 -> [GameRoom] -> [Point2]
--extendedViewPoints p grs =
-- map
-- extend
-- ( concatMap _grViewpointsEx grs
-- ++ map addDir (concatMap _grLinkDirs grs)
-- )
-- where
-- extend outp = p +.+ maxViewDistance *.* squashNormalizeV (outp -.- p)
-- addDir a = p +.+ unitVectorAtAngle a
maxViewDistance :: Float
maxViewDistance = 800
getViewpoints :: Point2 -> CWorld -> [Point2]
{-# INLINE getViewpoints #-}
getViewpoints p w =
concatMap (gameRoomViewpoints p) $
filter (pointInOrOnPolygon p . _grBound) (_cwgGameRooms $ _cwGen w)
gameRoomViewpoints :: Point2 -> GameRoom -> [Point2]
{-# INLINE gameRoomViewpoints #-}
gameRoomViewpoints p gr =
_grViewpoints gr
<> map extend (_grViewpointsEx gr <> map addDir (_grLinkDirs gr))
where
extend outp = p +.+ maxViewDistance *.* squashNormalizeV (outp -.- p)
addDir a = p +.+ unitVectorAtAngle a