Simplify block drawing

This commit is contained in:
2025-10-24 19:09:23 +01:00
parent ccb809a090
commit ffea3a1694
7 changed files with 16 additions and 30 deletions
+5 -14
View File
@@ -15,16 +15,8 @@ import Dodge.Path
import Geometry
import qualified IntMapHelp as IM
plBlock ::
-- | Block polygon
[Point2] ->
Block ->
-- | Base Pane
Wall ->
GenWorld ->
(Int, GenWorld)
plBlock [] _ _ _ = error "Trying to add a block with incomplete polygon"
plBlock (p : ps) bl wl w =
plBlock :: [Point2] -> Block -> Wall -> GenWorld -> (Int, GenWorld)
plBlock ps bl wl w =
(,) blid $
w
& gwWorld . cWorld . lWorld . blocks . at blid
@@ -32,19 +24,18 @@ plBlock (p : ps) bl wl w =
{ _blID = blid
, _blWallIDs = IS.fromList is
, _blShadows = []
, _blFootprint = p : ps
, _blFootprint = ps
}
& gwWorld %~ insertWalls wls
where
blid = IM.newKey $ w ^. gwWorld . cWorld . lWorld . blocks
lns = zip (p : ps) (ps ++ [p])
i = IM.newKey $ w ^. gwWorld . cWorld . lWorld . walls
is = [i .. i + length lns -1]
is = take (length ps) [i .. ]
wls =
zipWith
(\j ln -> wl & wlLine .~ ln & wlID .~ j & wlStructure .~ BlockPart blid)
is
lns
(loopPairs ps)
-- | Splits a line into many four cornered blocks.
plLineBlock ::