Files
loop/src/Dodge/Render/Lights.hs
T

29 lines
962 B
Haskell

module Dodge.Render.Lights (
lightsToRender,
) where
import Data.Maybe
import Dodge.Data.Universe
import Geometry
import qualified IntMapHelp as IM
import Control.Lens
lightsToRender :: Configuration -> World -> [(Point3, Float, Point3)]
lightsToRender cfig w =
mapMaybe getLS (IM.elems $ _lightSources (_cWorld w))
++ mapMaybe getTLS (_tempLightSources (_cWorld w))
where
getLS = getlsparam . _lsParam
getTLS = getlsparam . _tlsParam
cbox = w ^. cWorld . cwCam . cwcBoundBox
cpos = w ^. cWorld . cwCam . cwcCenter
getlsparam ls
| not (pointInPolygon lpos cbox) && extraculltest = Nothing
| otherwise = Just (_lsPos ls, rad ^ (2 :: Int), _lsCol ls)
where
lpos = xyV3 $ _lsPos ls
rad = _lsRad ls
extraculltest
| debugOn Cull_more_lights cfig = True
| otherwise = isNothing (intersectSegPolyFirst lpos (lpos +.+ rad *.* normalizeV (cpos -.- lpos)) cbox)