Cleanup
This commit is contained in:
+5
-2
@@ -234,10 +234,13 @@ collidePointWalls p1 p2
|
|||||||
findPoint (x,y) p = fromMaybe p $ intersectSegSeg p1 p x y
|
findPoint (x,y) p = fromMaybe p $ intersectSegSeg p1 p x y
|
||||||
|
|
||||||
collidePointWallsFilter :: (Wall -> Bool) -> Point2 -> Point2 -> IM.IntMap Wall -> Point2
|
collidePointWallsFilter :: (Wall -> Bool) -> Point2 -> Point2 -> IM.IntMap Wall -> Point2
|
||||||
collidePointWallsFilter t p1 p2
|
collidePointWallsFilter t p1 p2 = foldr findPoint p2 . fmap _wlLine . IM.filter t
|
||||||
= foldr findPoint p2 . fmap _wlLine . IM.filter t
|
|
||||||
where
|
where
|
||||||
findPoint (x,y) p = fromMaybe p $ intersectSegSeg p1 p x y
|
findPoint (x,y) p = fromMaybe p $ intersectSegSeg p1 p x y
|
||||||
|
collidePointWallsFilter' :: (Wall -> Bool) -> Point2 -> Point2 -> IM.IntMap Wall -> Point2
|
||||||
|
collidePointWallsFilter' t p1 p2 = foldl' findPoint p2 . fmap _wlLine . IM.filter t
|
||||||
|
where
|
||||||
|
findPoint p = fromMaybe p . uncurry (intersectSegSeg p1 p)
|
||||||
|
|
||||||
-- | Looks for first collision of a circle with walls.
|
-- | Looks for first collision of a circle with walls.
|
||||||
-- If found, gives point and reflection velocity, reflection damped in normal.
|
-- If found, gives point and reflection velocity, reflection damped in normal.
|
||||||
|
|||||||
@@ -166,13 +166,13 @@ ssfold :: Foldable t => (a -> Bool) -> (a -> b -> a) -> a -> t b -> a
|
|||||||
{-# INLINABLE ssfold #-}
|
{-# INLINABLE ssfold #-}
|
||||||
ssfold p f a0 xs = foldr (\x g a -> if p a then a else g (f a x)) id xs a0
|
ssfold p f a0 xs = foldr (\x g a -> if p a then a else g (f a x)) id xs a0
|
||||||
|
|
||||||
collidePointIndirect :: Point2 -> Point2 -> IM.IntMap Wall -> Maybe Point2
|
--collidePointIndirect :: Point2 -> Point2 -> IM.IntMap Wall -> Maybe Point2
|
||||||
{-# INLINE collidePointIndirect #-}
|
--{-# INLINE collidePointIndirect #-}
|
||||||
collidePointIndirect p1 p2 = test . foldr f p2 . IM.filter wlIsOpaque
|
--collidePointIndirect p1 p2 = test . foldr f p2 . IM.filter wlIsOpaque
|
||||||
where
|
-- where
|
||||||
f wl p = fromMaybe p $ uncurry (intersectSegSeg p1 p) $ _wlLine wl
|
-- f wl p = fromMaybe p $ uncurry (intersectSegSeg p1 p) $ _wlLine wl
|
||||||
test p | p == p2 = Nothing
|
-- test p | p == p2 = Nothing
|
||||||
| otherwise = Just p
|
-- | otherwise = Just p
|
||||||
|
|
||||||
collidePointIndirect' :: Point2 -> Point2 -> IM.IntMap Wall -> Maybe Point2
|
collidePointIndirect' :: Point2 -> Point2 -> IM.IntMap Wall -> Maybe Point2
|
||||||
{-# INLINE collidePointIndirect' #-}
|
{-# INLINE collidePointIndirect' #-}
|
||||||
@@ -260,7 +260,8 @@ canSee i j w = hasLOS p1 p2 w
|
|||||||
-- jpos = _crPos (_creatures w IM.! j)
|
-- jpos = _crPos (_creatures w IM.! j)
|
||||||
|
|
||||||
canSeeIndirect :: Int -> Int -> World -> Bool
|
canSeeIndirect :: Int -> Int -> World -> Bool
|
||||||
canSeeIndirect i j w = isNothing . collidePointIndirect ipos jpos $ wallsAlongLine ipos jpos w
|
canSeeIndirect i j w = any (isJust . uncurry (intersectSegSeg ipos jpos) . _wlLine)
|
||||||
|
$ IM.filter wlIsOpaque $ wallsAlongLine ipos jpos w
|
||||||
where
|
where
|
||||||
ipos = _crPos (_creatures w IM.! i)
|
ipos = _crPos (_creatures w IM.! i)
|
||||||
jpos = _crPos (_creatures w IM.! j)
|
jpos = _crPos (_creatures w IM.! j)
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ halfWidth w = _windowX w / 2
|
|||||||
halfHeight w = _windowY w / 2
|
halfHeight w = _windowY w / 2
|
||||||
-- | A box of the size of the screen in screen centered coordinates
|
-- | A box of the size of the screen in screen centered coordinates
|
||||||
screenBox :: Configuration -> [Point2]
|
screenBox :: Configuration -> [Point2]
|
||||||
screenBox w = reverse $ rectNSWE hh (-hh) (-hw) hw
|
screenBox w = rectNSWE hh (-hh) (-hw) hw
|
||||||
where
|
where
|
||||||
hw = halfWidth w
|
hw = halfWidth w
|
||||||
hh = halfHeight w
|
hh = halfHeight w
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import Data.Aeson
|
|||||||
import qualified Data.Set as S
|
import qualified Data.Set as S
|
||||||
import GHC.Generics
|
import GHC.Generics
|
||||||
import Control.Lens
|
import Control.Lens
|
||||||
|
{-# ANN module "HLint: ignore Use camelCase" #-}
|
||||||
data Configuration = Configuration
|
data Configuration = Configuration
|
||||||
{ _volume_master :: Float
|
{ _volume_master :: Float
|
||||||
, _volume_sound :: Float
|
, _volume_sound :: Float
|
||||||
@@ -24,8 +25,8 @@ data Configuration = Configuration
|
|||||||
}
|
}
|
||||||
deriving (Generic, Show)
|
deriving (Generic, Show)
|
||||||
data DebugBool
|
data DebugBool
|
||||||
= Show_sound
|
= Show_ms_frame
|
||||||
| Show_ms_frame
|
| Show_sound
|
||||||
| Noclip
|
| Noclip
|
||||||
| Cr_status
|
| Cr_status
|
||||||
| Cr_awareness
|
| Cr_awareness
|
||||||
@@ -35,6 +36,9 @@ data DebugBool
|
|||||||
| Pathing
|
| Pathing
|
||||||
| Remove_LOS
|
| Remove_LOS
|
||||||
| Cull_more_lights
|
| Cull_more_lights
|
||||||
|
| Close_shape_culling
|
||||||
|
| Show_bound_box
|
||||||
|
| Bound_box_screen
|
||||||
deriving (Generic, Eq,Ord,Bounded, Enum, Show)
|
deriving (Generic, Eq,Ord,Bounded, Enum, Show)
|
||||||
data ResFactor = FullRes | HalfRes | QuarterRes
|
data ResFactor = FullRes | HalfRes | QuarterRes
|
||||||
deriving (Generic, Show, Eq, Ord, Enum, Bounded)
|
deriving (Generic, Show, Eq, Ord, Enum, Bounded)
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ module Dodge.CullBox
|
|||||||
) where
|
) where
|
||||||
import Dodge.Data
|
import Dodge.Data
|
||||||
--import Dodge.GameRoom
|
--import Dodge.GameRoom
|
||||||
--import Dodge.Base
|
import Dodge.Base.Window
|
||||||
--import Dodge.Zone
|
--import Dodge.Zone
|
||||||
import Geometry
|
import Geometry
|
||||||
import Dodge.Update.Camera
|
import Dodge.Update.Camera
|
||||||
@@ -13,8 +13,10 @@ import Dodge.Update.Camera
|
|||||||
|
|
||||||
cullBox :: Configuration -> World -> [Point2]
|
cullBox :: Configuration -> World -> [Point2]
|
||||||
--cullBox cfig w = farWallPoints cp w
|
--cullBox cfig w = farWallPoints cp w
|
||||||
cullBox cfig w' = let (n,s,e,w) = farWallDistDirection (_cameraCenter w') cfig w'
|
cullBox cfig w'
|
||||||
in map ((+.+ _cameraCenter w') . rotateV (_cameraRot w') ) $ rectNSWE n (negate s) (negate w) e
|
| debugOn Bound_box_screen cfig = screenPolygon cfig w'
|
||||||
|
| otherwise = let (n,s,e,w) = farWallDistDirection (_cameraCenter w') cfig w'
|
||||||
|
in map ((+.+ _cameraCenter w') . rotateV (_cameraRot w') ) $ rectNSWE n (negate s) (negate w) e
|
||||||
-- --mapMaybe (fmap (fst . _wlLine . snd) . f) $ screenPolygon cfig w
|
-- --mapMaybe (fmap (fst . _wlLine . snd) . f) $ screenPolygon cfig w
|
||||||
-- where
|
-- where
|
||||||
-- grs = filter (pointInOrOnPolygon cp . _grBound) (_gameRooms w)
|
-- grs = filter (pointInOrOnPolygon cp . _grBound) (_gameRooms w)
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ lineOnScreenCone cfig w p1 p2 = pointInPolygon p1 sp
|
|||||||
sps = zip sp (tail sp ++ [head sp])
|
sps = zip sp (tail sp ++ [head sp])
|
||||||
|
|
||||||
pointOnScreen :: Configuration -> World -> Point2 -> Bool
|
pointOnScreen :: Configuration -> World -> Point2 -> Bool
|
||||||
pointOnScreen cfig w p = pointInPolygon p . reverse $ screenPolygon cfig w
|
pointOnScreen cfig w p = pointInPolygon p $ screenPolygon cfig w
|
||||||
|
|
||||||
drawWallFace :: Configuration -> World -> Wall -> Picture
|
drawWallFace :: Configuration -> World -> Wall -> Picture
|
||||||
drawWallFace cfig w wall
|
drawWallFace cfig w wall
|
||||||
@@ -58,7 +58,7 @@ extendConeToScreenEdge :: Configuration -> World -> Point2 -> (Point2,Point2) ->
|
|||||||
extendConeToScreenEdge cfig w c (x,y) = orderPolygon $ wallScreenIntersect ++ [x,y] ++ borderPs ++ cornerPs
|
extendConeToScreenEdge cfig w c (x,y) = orderPolygon $ wallScreenIntersect ++ [x,y] ++ borderPs ++ cornerPs
|
||||||
where
|
where
|
||||||
borderPs = mapMaybe (intersectLinefromScreen cfig w c) [x,y]
|
borderPs = mapMaybe (intersectLinefromScreen cfig w c) [x,y]
|
||||||
scpoly = screenPolygon cfig w
|
scpoly = reverse $ screenPolygon cfig w
|
||||||
cornerPs = filter (pointIsInCone c (x,y)) scpoly
|
cornerPs = filter (pointIsInCone c (x,y)) scpoly
|
||||||
wallScreenIntersect = mapMaybe (uncurry $ intersectSegSeg y ((2*.*y) -.- x))
|
wallScreenIntersect = mapMaybe (uncurry $ intersectSegSeg y ((2*.*y) -.- x))
|
||||||
. loopPairs $ scpoly
|
. loopPairs $ scpoly
|
||||||
|
|||||||
+2
-2
@@ -39,7 +39,7 @@ doDrawing pdata u = do
|
|||||||
wins@(V2 winx winy) = V2 (_windowX cfig) (_windowY cfig)
|
wins@(V2 winx winy) = V2 (_windowX cfig) (_windowY cfig)
|
||||||
resFact = resFactorNum $ cfig ^. graphics_resolution_factor
|
resFact = resFactorNum $ cfig ^. graphics_resolution_factor
|
||||||
(wallPointsCol,windowPoints,wallSPics) = wallsToDrawStreams cfig w
|
(wallPointsCol,windowPoints,wallSPics) = wallsToDrawStreams cfig w
|
||||||
lightPoints = lightsForGloom cfig w
|
lightPoints = lightsToRender cfig w
|
||||||
viewFroms@(V2 vfx vfy) = _cameraViewFrom w
|
viewFroms@(V2 vfx vfy) = _cameraViewFrom w
|
||||||
viewFrom3d = Vector3 vfx vfy 20
|
viewFrom3d = Vector3 vfx vfy 20
|
||||||
shadV = _pictureShaders pdata
|
shadV = _pictureShaders pdata
|
||||||
@@ -107,7 +107,7 @@ doDrawing pdata u = do
|
|||||||
currentProgram $= Just (_shadProg lwShad)
|
currentProgram $= Just (_shadProg lwShad)
|
||||||
uniform (head $ _shadUnis lwShad) $= viewFrom3d
|
uniform (head $ _shadUnis lwShad) $= viewFrom3d
|
||||||
bindVertexArrayObject $= Just (_vao $ _shadVAO lwShad)
|
bindVertexArrayObject $= Just (_vao $ _shadVAO lwShad)
|
||||||
when (not (debugOn Remove_LOS cfig)) $ glDrawArrays
|
unless (debugOn Remove_LOS cfig) $ glDrawArrays
|
||||||
(marshalEPrimitiveMode $ _shadPrim lwShad)
|
(marshalEPrimitiveMode $ _shadPrim lwShad)
|
||||||
0
|
0
|
||||||
(fromIntegral nWalls)
|
(fromIntegral nWalls)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
module Dodge.Render.Lights
|
module Dodge.Render.Lights
|
||||||
( lightsForGloom
|
( lightsToRender
|
||||||
) where
|
) where
|
||||||
import Dodge.Data
|
import Dodge.Data
|
||||||
import Dodge.CullBox
|
import Dodge.CullBox
|
||||||
@@ -8,8 +8,8 @@ import Geometry
|
|||||||
import Data.Maybe
|
import Data.Maybe
|
||||||
import qualified Data.IntMap.Lazy as IM
|
import qualified Data.IntMap.Lazy as IM
|
||||||
|
|
||||||
lightsForGloom :: Configuration -> World -> [(Point3,Float,Point3)]
|
lightsToRender :: Configuration -> World -> [(Point3,Float,Point3)]
|
||||||
lightsForGloom cfig w = mapMaybe getLS (IM.elems $ _lightSources w)
|
lightsToRender cfig w = mapMaybe getLS (IM.elems $ _lightSources w)
|
||||||
++ mapMaybe getTLS (_tempLightSources w)
|
++ mapMaybe getTLS (_tempLightSources w)
|
||||||
where
|
where
|
||||||
getLS = getlsparam . _lsParam
|
getLS = getlsparam . _lsParam
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ optionValueOffset u mo = case _moString mo u of
|
|||||||
Right (s,_) -> length s
|
Right (s,_) -> length s
|
||||||
|
|
||||||
darkenBackground :: Configuration -> Picture
|
darkenBackground :: Configuration -> Picture
|
||||||
darkenBackground = color (withAlpha 0.5 black) . polygon . screenBox
|
darkenBackground = color (withAlpha 0.5 black) . polygon . reverse . screenBox
|
||||||
|
|
||||||
drawTitle :: Configuration -> String -> Picture
|
drawTitle :: Configuration -> String -> Picture
|
||||||
drawTitle cfig = placeString (-hw + 30) (hh - 50) 0.4
|
drawTitle cfig = placeString (-hw + 30) (hh - 50) 0.4
|
||||||
|
|||||||
@@ -41,12 +41,12 @@ worldSPic cfig w =
|
|||||||
<> foldMap mcSPic (filtOn _mcPos _machines)
|
<> foldMap mcSPic (filtOn _mcPos _machines)
|
||||||
where
|
where
|
||||||
filtOn f g = IM.filter (pointIsClose . f) (g w)
|
filtOn f g = IM.filter (pointIsClose . f) (g w)
|
||||||
--pointIsClose p = dist camCen p < _viewDistance w
|
pointIsClose = cullPoint cfig w
|
||||||
pointIsClose = cullPoint w
|
|
||||||
--camCen = _cameraCenter w
|
|
||||||
|
|
||||||
cullPoint :: World -> Point2 -> Bool
|
cullPoint :: Configuration -> World -> Point2 -> Bool
|
||||||
cullPoint w p = pointInPolygon p (_boundBox w)
|
cullPoint cfig w p
|
||||||
|
| debugOn Close_shape_culling cfig = pointInPolygon p (_boundBox w)
|
||||||
|
| otherwise = dist (_cameraCenter w) p < _viewDistance w
|
||||||
|
|
||||||
extraShapes :: World -> Shape
|
extraShapes :: World -> Shape
|
||||||
extraShapes = _foregroundShape
|
extraShapes = _foregroundShape
|
||||||
@@ -69,9 +69,15 @@ extraPics cfig w = pictures (_decorations w)
|
|||||||
<> drawWallIDs cfig w
|
<> drawWallIDs cfig w
|
||||||
<> drawPathing cfig w
|
<> drawPathing cfig w
|
||||||
<> drawCrInfo cfig w
|
<> drawCrInfo cfig w
|
||||||
|
<> drawBoundingBox cfig w
|
||||||
|
|
||||||
testPic :: Configuration -> World -> Picture
|
testPic :: Configuration -> World -> Picture
|
||||||
testPic cfig w = setLayer DebugLayer $ color green $ line $ (x:xs) ++ [x]
|
testPic _ _ = mempty
|
||||||
|
|
||||||
|
drawBoundingBox :: Configuration -> World -> Picture
|
||||||
|
drawBoundingBox cfig w
|
||||||
|
| debugOn Show_bound_box cfig = setLayer DebugLayer $ color green $ line $ (x:xs) ++ [x]
|
||||||
|
| otherwise = mempty
|
||||||
where
|
where
|
||||||
(x:xs) = cullBox cfig w
|
(x:xs) = cullBox cfig w
|
||||||
|
|
||||||
|
|||||||
@@ -210,7 +210,7 @@ farWallDistDirection :: Point2 -> Configuration -> World -> (Float,Float,Float,F
|
|||||||
--farWallDist p cfig w = (winFac /) . min maxViewDistance $ ssfold (> maxViewDistance) findMax 1 vps
|
--farWallDist p cfig w = (winFac /) . min maxViewDistance $ ssfold (> maxViewDistance) findMax 1 vps
|
||||||
farWallDistDirection p cfig w = foldr (m . f) (0,0,0,0) vps
|
farWallDistDirection p cfig w = foldr (m . f) (0,0,0,0) vps
|
||||||
where
|
where
|
||||||
f q = g $ rotateV (negate $ _cameraRot w) $ collidePointWallsFilter wlIsOpaque p q wos -.- p
|
f q = g $ rotateV (negate $ _cameraRot w) $ collidePointWallsFilter' wlIsOpaque p q wos -.- p
|
||||||
g (V2 x y) = (y, negate y, x, negate x)
|
g (V2 x y) = (y, negate y, x, negate x)
|
||||||
m (a,b,c,d) (x,y,z,w') = (max a x, max b y, max c z, max d w')
|
m (a,b,c,d) (x,y,z,w') = (max a x, max b y, max c z, max d w')
|
||||||
vps = concatMap _grViewpoints grs ++ extendedViewPoints p grs
|
vps = concatMap _grViewpoints grs ++ extendedViewPoints p grs
|
||||||
|
|||||||
+1
-4
@@ -11,10 +11,7 @@ isLHS
|
|||||||
-> Point2 -- ^ Point not on line.
|
-> Point2 -- ^ Point not on line.
|
||||||
-> Bool
|
-> Bool
|
||||||
{-# INLINE isLHS #-}
|
{-# INLINE isLHS #-}
|
||||||
isLHS
|
isLHS (V2 x y) (V2 x' y') (V2 x'' y'')
|
||||||
(V2 x y)
|
|
||||||
(V2 x' y')
|
|
||||||
(V2 x'' y'')
|
|
||||||
| (x,y) == (x',y') = False
|
| (x,y) == (x',y') = False
|
||||||
| otherwise = a1 * b2 - a2 * b1 > 0
|
| otherwise = a1 * b2 - a2 * b1 > 0
|
||||||
where
|
where
|
||||||
|
|||||||
Reference in New Issue
Block a user