Refactor window size, update selection cursor on new screen

This commit is contained in:
2023-03-25 09:27:27 +00:00
parent 20c05be23f
commit ea0c942887
57 changed files with 346 additions and 310 deletions
+6 -6
View File
@@ -39,11 +39,11 @@ lineOnScreenCone cfig w p1 p2 =
|| pointInPolygon p2 sp
|| any (isJust . uncurry (intersectSegSeg p1 p2)) sps
where
sp' = screenPolygon cfig (w ^. cWorld . camPos)
vp = w ^. cWorld . camPos . camViewFrom
sp' = screenPolygon cfig (w ^. cWorld . cwCamPos)
vp = w ^. cWorld . cwCamPos . camViewFrom
sp
| pointInPolygon vp sp' = sp'
| otherwise = orderPolygon ((w ^. cWorld . camPos . camViewFrom) : sp')
| otherwise = orderPolygon ((w ^. cWorld . cwCamPos . camViewFrom) : sp')
sps = zip sp (tail sp ++ [head sp])
pointOnScreen :: Configuration -> CamPos -> Point2 -> Bool
@@ -56,13 +56,13 @@ drawWallFace cfig w wall
where
(x, y) = _wlLine wall
points = extendConeToScreenEdge cfig w sightFrom (x, y)
sightFrom = w ^. cWorld . camPos . camViewFrom
sightFrom = w ^. cWorld . cwCamPos . camViewFrom
extendConeToScreenEdge :: Configuration -> World -> Point2 -> (Point2, Point2) -> [Point2]
extendConeToScreenEdge cfig w c (x, y) = orderPolygon $ wallScreenIntersect ++ [x, y] ++ borderPs ++ cornerPs
where
borderPs = mapMaybe (intersectLinefromScreen cfig w c) [x, y]
scpoly = reverse $ screenPolygon cfig (w ^. cWorld . camPos)
scpoly = reverse $ screenPolygon cfig (w ^. cWorld . cwCamPos)
cornerPs = filter (pointIsInCone c (x, y)) scpoly
wallScreenIntersect =
mapMaybe (uncurry $ intersectSegSeg y ((2 *.* y) -.- x))
@@ -77,4 +77,4 @@ intersectLinefromScreen cfig w a b =
listToMaybe
. mapMaybe (\(x, y) -> intersectSegLineFrom x y b (b +.+ b -.- a))
. loopPairs
$ screenPolygon cfig (w ^. cWorld . camPos)
$ screenPolygon cfig (w ^. cWorld . cwCamPos)