More cleverly set maximum view distance for rectangular window sizes
This commit is contained in:
@@ -75,7 +75,13 @@ moveZoomCamera cfig w = w
|
||||
| curZoom > idealZoom + 0.01 = ((zoomOutSpeed-1)*curZoom + idealZoom) / zoomOutSpeed
|
||||
| curZoom < idealZoom - 0.01 = ((zoomInSpeed -1)*curZoom + idealZoom) / zoomInSpeed
|
||||
| otherwise = idealZoom
|
||||
wallZoom = farWallDist newvf cfig w
|
||||
--wallZoom = farWallDist newvf cfig w
|
||||
wallZoom = min4 (_boundDist w)
|
||||
min4 (a,b,c,d) = minimum [hh/maxd a,hh/maxd (-b),hw/maxd c,hw/maxd (-d)]
|
||||
maxd = max distFromEqmnt
|
||||
distFromEqmnt = foldr max 1 $ IM.mapMaybe (_eqViewDist . _eqEq. _itUse) $ getCrEquipment $ you w
|
||||
hw = halfWidth cfig
|
||||
hh = halfHeight cfig
|
||||
-- = maybe clipZoom zoomFromItem (yourItem w ^? itZoom) wallZoom
|
||||
-- these speeds are inverted, larger means slower
|
||||
zoomInSpeed = 25
|
||||
@@ -201,22 +207,6 @@ setViewDistance cfig w = w & viewDistance
|
||||
.~ sqrt (halfWidth cfig ** 2 + halfHeight cfig ** 2) / _cameraZoom w
|
||||
-- .~ max (halfWidth cfig) (halfHeight cfig) / _cameraZoom w
|
||||
|
||||
|
||||
-- TODO consider adding visible/nearby creatures as view points
|
||||
farWallDist :: Point2 -> Configuration -> World -> Float
|
||||
--farWallDist p cfig w = (winFac /) . min maxViewDistance $ ssfold (> maxViewDistance) findMax 1 vps
|
||||
farWallDist p cfig w = (winFac /)
|
||||
. min maxViewDistance $ ssfold (> maxViewDistance) findMax distFromEqmnt vps
|
||||
where
|
||||
findMax curMax pout = max curMax $ dist p $ collidePointUpToIndirectMinDist p pout curMax wos
|
||||
hw = halfWidth cfig
|
||||
hh = halfHeight cfig
|
||||
winFac = min hw hh
|
||||
vps = concatMap _grViewpoints grs ++ extendedViewPoints p grs
|
||||
grs = filter (pointInOrOnPolygon p . _grBound) (_gameRooms w)
|
||||
wos = wallsOnScreen cfig w
|
||||
distFromEqmnt = foldr max 1 $ IM.mapMaybe (_eqViewDist . _eqEq. _itUse) $ getCrEquipment $ you w
|
||||
|
||||
streamViewpoints :: Monad m => Point2 -> World -> Stream (Of Point2) m ()
|
||||
{-# INLINE streamViewpoints #-}
|
||||
streamViewpoints p w = flip S.for (gameRoomViewpoints p)
|
||||
|
||||
Reference in New Issue
Block a user