Tweak view distances

This commit is contained in:
2023-01-06 16:55:17 +00:00
parent 5b9e0c39b5
commit 87ea7da1d4
6 changed files with 65 additions and 70 deletions
+42
View File
@@ -0,0 +1,42 @@
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