diff --git a/src/Dodge/Config/Data.hs b/src/Dodge/Config/Data.hs index d78d025ea..3d2587373 100644 --- a/src/Dodge/Config/Data.hs +++ b/src/Dodge/Config/Data.hs @@ -28,6 +28,8 @@ data Configuration = Configuration , _debug_walls :: Bool , _debug_view_clip_bounds :: RoomClipping , _debug_pathing :: Bool + , _debug_remove_LOS :: Bool + , _debug_cull_more_lights :: Bool } deriving (Generic, Show) data ResFactor = FullRes | HalfRes | QuarterRes @@ -77,4 +79,6 @@ defaultConfig = Configuration , _debug_view_clip_bounds = NoRoomClipBoundaries , _debug_pathing = False , _debug_walls = False + , _debug_remove_LOS = False + , _debug_cull_more_lights = False } diff --git a/src/Dodge/CullBox.hs b/src/Dodge/CullBox.hs index 3418dcfbf..7184558bd 100644 --- a/src/Dodge/CullBox.hs +++ b/src/Dodge/CullBox.hs @@ -2,14 +2,14 @@ module Dodge.CullBox (cullBox ) where import Dodge.Data -import Dodge.GameRoom -import Dodge.Base -import Dodge.Zone +--import Dodge.GameRoom +--import Dodge.Base +--import Dodge.Zone import Geometry import Dodge.Update.Camera -import Shape +--import Shape -import Data.Maybe (mapMaybe) +--import Data.Maybe (mapMaybe) cullBox :: Configuration -> World -> [Point2] --cullBox cfig w = farWallPoints cp w diff --git a/src/Dodge/Data.hs b/src/Dodge/Data.hs index 748cee1a3..a91ec51f1 100644 --- a/src/Dodge/Data.hs +++ b/src/Dodge/Data.hs @@ -86,11 +86,12 @@ data World = World , _mousePos :: Point2 , _cameraCenter :: Point2 , _cameraRot :: Float - , _cameraZoom :: Float + , _cameraZoom :: Float -- smaller values zoom out , _itemZoom :: Float , _defaultZoom :: Float , _cameraViewFrom :: Point2 , _viewDistance :: Float + , _boundBox :: [Point2] , _creatures :: IM.IntMap Creature , _creaturesZone :: Zone (IM.IntMap Creature) , _creatureGroups :: IM.IntMap CrGroupParams diff --git a/src/Dodge/Default/World.hs b/src/Dodge/Default/World.hs index 6b1caa37a..4268decf4 100644 --- a/src/Dodge/Default/World.hs +++ b/src/Dodge/Default/World.hs @@ -6,6 +6,7 @@ import Dodge.Bounds --import Dodge.Menu --import Picture import Geometry.Data +import Geometry.Polygon --import Picture.Texture --import Data.Preload @@ -105,6 +106,7 @@ defaultWorld = World , _genRooms = IM.empty , _deathDelay = Nothing , _testFloat = 0 + , _boundBox = square 1000 } youLight :: TempLightSource youLight = TLS diff --git a/src/Dodge/Initialisation.hs b/src/Dodge/Initialisation.hs index 6220d5eb1..705f942d2 100644 --- a/src/Dodge/Initialisation.hs +++ b/src/Dodge/Initialisation.hs @@ -42,6 +42,7 @@ initialWorld = defaultWorld testStringInit :: World -> [String] testStringInit = const [] -- map (show . _mcTermMID) . IM.elems . _machines +--testStringInit w = [show $ _cameraZoom w] --testStringInit = (:[]) . show . _testFloat --testStringInit = map (concatMap $ \(_,ct,_,_) -> show ct) . invertListInvMult . yourInv --testStringInit w = fmap (show . _crHammerPosition) . IM.elems $ _creatures w diff --git a/src/Dodge/Menu.hs b/src/Dodge/Menu.hs index 636059c8f..2ad7c4678 100644 --- a/src/Dodge/Menu.hs +++ b/src/Dodge/Menu.hs @@ -90,6 +90,8 @@ debugMenuOptions = zipWith ($) , makeBoolOption debug_show_sound "SHOW VISUAL SOUNDS" , makeBoolOption debug_mouse_position "SHOW MOUSE POSITION" , makeBoolOption debug_walls "SHOW WALL INFO" + , makeBoolOption debug_remove_LOS "REMOVE LOS" + , makeBoolOption debug_cull_more_lights "CULL MORE LIGHTS" ] $ map Scancode [4 ..] gameplayMenu :: ScreenLayer diff --git a/src/Dodge/Render.hs b/src/Dodge/Render.hs index 7502ccc4f..f8c0b37de 100644 --- a/src/Dodge/Render.hs +++ b/src/Dodge/Render.hs @@ -107,10 +107,12 @@ doDrawing pdata u = do currentProgram $= Just (_shadProg lwShad) uniform (head $ _shadUnis lwShad) $= viewFrom3d bindVertexArrayObject $= Just (_vao $ _shadVAO lwShad) - glDrawArrays - (marshalEPrimitiveMode $ _shadPrim lwShad) - 0 - (fromIntegral nWalls) + if not (_debug_remove_LOS cfig) + then glDrawArrays + (marshalEPrimitiveMode $ _shadPrim lwShad) + 0 + (fromIntegral nWalls) + else return () --draw walls onto base buffer if cfig ^. graphics_wall_textured then renderTextureWalls pdata nWalls diff --git a/src/Dodge/Render/Lights.hs b/src/Dodge/Render/Lights.hs index cb5244cbe..7f78f3db4 100644 --- a/src/Dodge/Render/Lights.hs +++ b/src/Dodge/Render/Lights.hs @@ -17,12 +17,11 @@ lightsForGloom cfig w = mapMaybe getLS (IM.elems $ _lightSources w) cbox = cullBox cfig w cpos = _cameraCenter w getlsparam ls - | not (pointInPolygon lpos cbox) - && isNothing (intersectSegPolyFirst lpos (lpos +.+ rad *.* (normalizeV (cpos -.- lpos))) cbox) - = Nothing --- | dist (_cameraCenter w) (fst2 $ _lsPos ls) > _viewDistance w + _lsRad ls = Nothing + | not (pointInPolygon lpos cbox) && extraculltest = Nothing | otherwise = Just ( _lsPos ls, rad^(2::Int) , _lsCol ls) where lpos = xyV3 $ _lsPos ls rad = _lsRad ls - fst2 (V3 a b _) = V2 a b + extraculltest + | _debug_cull_more_lights cfig = True + | otherwise = isNothing (intersectSegPolyFirst lpos (lpos +.+ rad *.* (normalizeV (cpos -.- lpos))) cbox) diff --git a/src/Dodge/Render/ShapePicture.hs b/src/Dodge/Render/ShapePicture.hs index 34832451a..99c85df78 100644 --- a/src/Dodge/Render/ShapePicture.hs +++ b/src/Dodge/Render/ShapePicture.hs @@ -41,9 +41,13 @@ worldSPic cfig w = <> foldMap mcSPic (filtOn _mcPos _machines) where filtOn f g = IM.filter (pointIsClose . f) (g w) - pointIsClose p = dist camCen p < 30 + _viewDistance w + --pointIsClose p = dist camCen p < _viewDistance w + pointIsClose = cullPoint w camCen = _cameraCenter w +cullPoint :: World -> Point2 -> Bool +cullPoint w p = pointInPolygon p (_boundBox w) + extraShapes :: World -> Shape extraShapes = _foregroundShape diff --git a/src/Dodge/Update.hs b/src/Dodge/Update.hs index 4160bc6b6..4f97cc3e0 100644 --- a/src/Dodge/Update.hs +++ b/src/Dodge/Update.hs @@ -5,6 +5,7 @@ Description : Simulation update module Dodge.Update ( updateUniverse ) where import Dodge.Data import Dodge.Menu +import Dodge.CullBox import Dodge.Block import Dodge.Distortion import Dodge.SoundLogic @@ -84,6 +85,7 @@ functionalUpdate cfig w = checkEndGame -- . (youHammerPosition %~ moveHammerUp) . updateTerminal . updateRBList + . updateBoundBox cfig -- where should this go? next to update camera? $ updateCloseObjects w where --updatedLightSources = mapMaybe (\b -> _tlsUpdate b w b) $ _tempLightSources w @@ -92,6 +94,9 @@ functionalUpdate cfig w = checkEndGame where (x,y) = cloudZoneOfPoint $ stripZ $ _clPos cl +updateBoundBox :: Configuration -> World -> World +updateBoundBox cfig w = w & boundBox .~ cullBox cfig w + mcChooseUpdate :: Machine -> Machine -> World -> World mcChooseUpdate mc mc' | _mcHP mc > 0 = _mcUpdate mc mc' diff --git a/src/Dodge/Update/Camera.hs b/src/Dodge/Update/Camera.hs index 92705fbcc..ed3bf7640 100644 --- a/src/Dodge/Update/Camera.hs +++ b/src/Dodge/Update/Camera.hs @@ -188,6 +188,8 @@ clipZoom = min 20 . max 0.2 setViewDistance :: Configuration -> World -> World 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