module Dodge.CullBox ( updateBounds, ) where import Control.Lens import Data.Maybe import Dodge.Base.Window import Dodge.Data.Universe import Dodge.Update.Camera import Geometry findBoundDists :: Configuration -> World -> (Float, Float, Float, Float) findBoundDists cfig w | debugOn Bound_box_screen cfig = (hh, - hh, hw, - hw) | otherwise = fromMaybe (0, 0, 0, 0) $ farWallDistDirection (w ^. cWorld . lWorld . camPos . camCenter) w where hw = halfWidth cfig hh = halfHeight cfig updateBounds :: Universe -> Universe updateBounds uv = uv & uvWorld . cWorld . lWorld . camPos . camBoundDist .~ bdists & uvWorld . cWorld . lWorld . camPos . camBoundBox .~ map ((+.+ w ^. cWorld . lWorld . camPos . camCenter) . rotateV (w ^. cWorld . lWorld . camPos . camRot)) (rectNSWE n s w' e) where w = _uvWorld uv cfig = _uvConfig uv bdists@(n, s, e, w') = findBoundDists cfig w