Fix inherited tile positioning

This commit is contained in:
2026-04-01 18:01:11 +01:00
parent c504d3c511
commit e50fdb8807
6 changed files with 62 additions and 42 deletions
+3 -2
View File
@@ -17,11 +17,12 @@ data Tile = Tile
{ _tilePoly :: [Point2]
, -- | point in the world where tile texture is 0,0
_tileZero :: Point2
, -- | world position one along in the X direction, note this also set the scale of the
-- texture
, -- | world position one along in the X direction
-- note this also sets the scale of the texture
-- this has to be a position because it is shifted
_tileTangentPos :: Point2
, _tileArrayZ :: Float
, _tileZeroShift :: Maybe Point2A
}
deriving (Eq, Ord, Show)
+9 -3
View File
@@ -73,9 +73,15 @@ setTile r gw = case _rmFloor r of
InheritFloor ->
gw & genRooms . ix (fromJust (_rmMID r)) . rmFloor .~ Tiled [t & tilePoly .~ poly]
where
t = case _rmMParent r of
Nothing -> Tile poly (V2 0 0) (V2 1 0) 16
Just pid -> head $ _tiles $ _rmFloor $ _genRooms gw IM.! pid
t = fromMaybe (Tile poly (V2 0 0) (V2 1 0) 16 Nothing) $ do
pid <- r ^. rmMParent
rm <- gw ^? genRooms . ix pid
(gw ^? genRooms . ix pid . rmFloor . tiles . ix 0)
<&> tileZeroShift ?~ _rmShift rm
-- t = case _rmMParent r of
-- Nothing -> Tile poly (V2 0 0) (V2 1 0) 16
-- Just pid -> head $ _tiles $ _rmFloor $ _genRooms gw IM.! pid
poly =
orderPolygon
. convexHullSafe
+16 -6
View File
@@ -42,14 +42,24 @@ shiftRoomBy shift r =
& rmPath %~ S.map (shiftPathBy shift)
& rmBound %~ fmap (map (shiftPointBy shift))
& rmShift %~ shiftPosDirBy shift
& rmFloor . tiles
%~ map
( (tilePoly %~ map (shiftPointBy shift))
. (tileZero %~ shiftPointBy shift)
. (tileTangentPos %~ shiftPointBy shift)
)
& rmFloor . tiles . each %~ shiftTile shift
-- %~ map
-- ( (tilePoly %~ map (shiftPointBy shift))
-- . (tileZero %~ shiftPointBy shift)
-- . (tileTangentPos %~ shiftPointBy shift)
-- )
& rmViewpoints %~ map (shiftPointBy shift)
shiftTile :: Point2A -> Tile -> Tile
shiftTile shift tl = case tl ^. tileZeroShift of
Nothing -> tl & tilePoly . each %~ shiftPointBy shift
& tileZero %~ shiftPointBy shift
& tileTangentPos %~ shiftPointBy shift
Just s -> tl & tilePoly . each %~ shiftPointBy shift
& tileZero %~ shiftPointBy s
& tileTangentPos %~ shiftPointBy s
moveRoomBy :: (Point2, Float) -> Room -> Room
moveRoomBy shift r =
r
+1
View File
@@ -56,6 +56,7 @@ roomRect x y xn yn =
, _tileZero = 0
, _tileTangentPos = V2 baseFloorTileSize 0
, _tileArrayZ = 16
, _tileZeroShift = Nothing
}
]
, _rmRandPSs = [psRandRanges (10, x -10) (10, y -10) (0, 2 * pi)]
+1
View File
@@ -38,6 +38,7 @@ makeTileFromPoly poly z =
, _tileZero = c
, _tileTangentPos = c + (baseFloorTileSize *.* normalizeV (d -.- c))
, _tileArrayZ = z
, _tileZeroShift = Nothing
}
where
(c : d : _) = poly