diff --git a/src/Dodge/Room/Corridor.hs b/src/Dodge/Room/Corridor.hs index 717f4a0b1..fa30f6237 100644 --- a/src/Dodge/Room/Corridor.hs +++ b/src/Dodge/Room/Corridor.hs @@ -23,8 +23,8 @@ corridor = _rmPath = foldMap (doublePairSet . (,) (V2 20 60)) [V2 20 70, V2 20 5] --, _rmPmnts = [spanLightI (V2 0 39.5) (V2 40 39.5)] , _rmPmnts = [] - , _rmBound = [rectNSWE 45 35 (-5) 45] --- , _rmBound = [rectNSWE 50 40 (-5) 45] +-- , _rmBound = [rectNSWE 45 35 (-5) 45] + , _rmBound = [rectNSWE 60 15 (-5) 45] , _rmFloor = Tiled [makeTileFromPoly poly 5] , _rmRandPSs = [psRandRanges (10, 30) (30, 60) (0, 2 * pi)] , _rmName = "Corridor" diff --git a/src/Dodge/Room/Room.hs b/src/Dodge/Room/Room.hs index 5302685bb..ab8d160f7 100644 --- a/src/Dodge/Room/Room.hs +++ b/src/Dodge/Room/Room.hs @@ -404,6 +404,7 @@ doorCor = do corDoor :: RandomGen g => State g (MetaTree Room String) corDoor = do cor <- shuffleLinks corridor <&> rmPmnts .~ [] +-- let cor = corridorN return $ tToBTree "corDoor" $ treePost [cor,cor, cleatOnward door] critsPillarRoom :: Int -> State LayoutVars Room diff --git a/src/Dodge/Room/Tutorial.hs b/src/Dodge/Room/Tutorial.hs index 33849b8c7..03ca40f95 100644 --- a/src/Dodge/Room/Tutorial.hs +++ b/src/Dodge/Room/Tutorial.hs @@ -55,20 +55,21 @@ tutAnoTree = do -- , return . tToBTree "door" $ treePost [corridor, cleatOnward door] , corDoor -- , tToBTree "cor" . return <$> shuffleLinks (cleatOnward corridor) ---aaa , lasCenRunClose ---aaa-- , passthroughLockKeyLists lockRoomKeyItems itemRooms ---aaa , tToBTree "cor" . return <$> shuffleLinks (cleatOnward corridor) ---aaa-- , tToBTree "cor" . return <$> shuffleLinks (cleatOnward corridor) ---aaa-- , tToBTree "cor" . return <$> shuffleLinks (cleatOnward corridor) ---aaa-- , passthroughLockKeyLists ---aaa-- [(sensorRoomRunPast ElectricSensor, takeOne ---aaa-- [-- CRAFT (ENERGYBALLCRAFT TeslaBall) , ---aaa-- HELD SPARKGUN])] ---aaa-- itemRooms ---aaa-- , tToBTree "cor" . return <$> shuffleLinks (cleatOnward corridor) ---aaa-- , tToBTree "cor" . return <$> shuffleLinks (cleatOnward corridor) ---aaa , tToBTree "sdr" . return . cleatOnward <$> ---aaa (shuffleLinks =<< distributerRoom BulletAmmo 100000) + , lasCenRunClose +-- , passthroughLockKeyLists lockRoomKeyItems itemRooms + , tToBTree "door" . return <$> return (cleatOnward door) + , tToBTree "cor" . return <$> shuffleLinks (cleatOnward corridor) +-- , tToBTree "cor" . return <$> shuffleLinks (cleatOnward corridor) +-- , tToBTree "cor" . return <$> shuffleLinks (cleatOnward corridor) +-- , passthroughLockKeyLists +-- [(sensorRoomRunPast ElectricSensor, takeOne +-- [-- CRAFT (ENERGYBALLCRAFT TeslaBall) , +-- HELD SPARKGUN])] +-- itemRooms +-- , tToBTree "cor" . return <$> shuffleLinks (cleatOnward corridor) +-- , tToBTree "cor" . return <$> shuffleLinks (cleatOnward corridor) + , tToBTree "sdr" . return . cleatOnward <$> + (shuffleLinks =<< distributerRoom BulletAmmo 100000) --aaa-- , return $ tToBTree "cor" $ return $ cleatOnward corridor --aaa-- --, tToBTree "sdr" . return . cleatOnward <$> slowDoorRoom --aaa---- , tToBTree "sr" . return . cleatOnward <$> tanksRoom [] [] diff --git a/src/Dodge/Tree/Shift.hs b/src/Dodge/Tree/Shift.hs index ee6e7d080..1244ef724 100644 --- a/src/Dodge/Tree/Shift.hs +++ b/src/Dodge/Tree/Shift.hs @@ -10,7 +10,7 @@ module Dodge.Tree.Shift ( PosRooms (..), ) where -import Data.Monoid +--import Data.Monoid import Control.Lens import Data.Bifunctor import Data.List (delete) @@ -67,9 +67,10 @@ posRms prs parenti@(parent, _) ((numChild, t@(Node childi _)) : its) tseq = do where tryChildLinks [] = tryParentLinks ls tryChildLinks ((numinlink, il) : ils) - | Just xs <- clipping' = do - putStrLn $ show xs - tryChildLinks ils +-- | Just xs <- clipping' = do +-- putStrLn $ show xs +-- tryChildLinks ils + | clipping = tryChildLinks ils | otherwise = do putStrLn $ show j ++ "-" ++ show numinlink mayrs <- @@ -86,7 +87,7 @@ posRms prs parenti@(parent, _) ((numChild, t@(Node childi _)) : its) tseq = do where newBounds = map pointsToPoly . _rmBound . doRoomShift . fst $ rootLabel shiftedt clipping = or (convexPolysOverlap <$> newBounds <*> _prBounds prs) - clipping' = getFirst . foldMap First $ convexPolysOverlapWitness <$> newBounds <*> _prBounds prs +-- clipping' = getFirst . foldMap First $ convexPolysOverlapWitness <$> newBounds <*> _prBounds prs updateparent rm = _rmLinkEff rm il child numChild outlnk rm & rmLinks %~ delete outlnk diff --git a/src/Geometry/Intersect.hs b/src/Geometry/Intersect.hs index 022009e71..b4f2ee038 100644 --- a/src/Geometry/Intersect.hs +++ b/src/Geometry/Intersect.hs @@ -139,22 +139,18 @@ intersectSegSegFullTest x y z w = {- | It is not always necessary to find a point of intersection, sometimes a test may suffice. +This should intersect on endpoints. -} -intersectSegSegTest :: - Point2 -> - Point2 -> - Point2 -> - Point2 -> - Bool +intersectSegSegTest :: Point2 -> Point2 -> Point2 -> Point2 -> Bool {-# INLINE intersectSegSegTest #-} intersectSegSegTest x y z w = f x y z w && f z w x y && x /= y && z /= w where - f a b c d = + f a b c d = compareLHS a b c /= compareLHS a b d -- (not (isRHS a b c) && not (isLHS a b d)) -- || (not (isLHS a b c) && not (isRHS a b d)) - (isRHS a b c && isLHS a b d) - || (isLHS a b c && isRHS a b d) +-- (isRHS a b c && isLHS a b d) +-- || (isLHS a b c && isRHS a b d) intersectSegSegPreTest :: Point2 -> diff --git a/src/Geometry/LHS.hs b/src/Geometry/LHS.hs index 663ff44e3..c777424b2 100644 --- a/src/Geometry/LHS.hs +++ b/src/Geometry/LHS.hs @@ -1,6 +1,7 @@ module Geometry.LHS ( isLHS, isRHS, + compareLHS, ) where import Geometry.Data @@ -26,6 +27,17 @@ isLHS (V2 x y) (V2 x' y') (V2 x'' y'') b1 = x'' - x b2 = y'' - y +compareLHS :: Point2 -> Point2 -> Point2 -> Ordering +{-# INLINE compareLHS #-} +compareLHS (V2 x y) (V2 x' y') (V2 x'' y'') + | (x, y) == (x', y') = EQ + | otherwise = compare (a1 * b2 - a2 * b1) 0 + where + a1 = x' - x + a2 = y' - y + b1 = x'' - x + b2 = y'' - y + {- | Test whether a point is on the RHS of a line. Returns False if the line is of zero length. -}