Simplify Foreground

This commit is contained in:
2025-10-25 13:12:00 +01:00
parent 5fce0772f8
commit ff03efc41f
8 changed files with 6 additions and 21 deletions
+1 -3
View File
@@ -10,10 +10,8 @@ import Geometry
import ShapePicture import ShapePicture
data ForegroundShape = ForegroundShape data ForegroundShape = ForegroundShape
{ _fsID :: Int { _fsPos :: Point2
, _fsPos :: Point2
, _fsDir :: Float , _fsDir :: Float
, _fsRad :: Float -- This should probably be a bounding box
, _fsSPic :: SPic , _fsSPic :: SPic
} }
deriving (Eq, Ord, Show, Read) --Generic, Flat) deriving (Eq, Ord, Show, Read) --Generic, Flat)
+1 -1
View File
@@ -127,7 +127,7 @@ data LWorld = LWorld
, _worldEvents :: [WdWd] , _worldEvents :: [WdWd]
, _delayedEvents :: [(Int, WdWd)] , _delayedEvents :: [(Int, WdWd)]
, _buttons :: IM.IntMap Button , _buttons :: IM.IntMap Button
, _foreShapes :: IM.IntMap ForegroundShape , _foreShapes :: [ForegroundShape]
, _lightSources :: IM.IntMap LightSource , _lightSources :: IM.IntMap LightSource
, _lights :: [LSParam] , _lights :: [LSParam]
, _seenLocations :: IM.IntMap (WdP2, String) , _seenLocations :: IM.IntMap (WdP2, String)
-2
View File
@@ -36,8 +36,6 @@ data Debris = DebrisChunk
, _dbSpin :: Q.Quaternion Float , _dbSpin :: Q.Quaternion Float
} }
--data PropType = FallingBlock Material
data PropDraw data PropDraw
= PropDrawFlatTranslate SPic = PropDrawFlatTranslate SPic
| PropDoubleLampCover Float | PropDoubleLampCover Float
+2 -2
View File
@@ -1,6 +1,6 @@
module Dodge.Default.ForegroundShape where module Dodge.Default.ForegroundShape (defaultForeground) where
import Dodge.Data.ForegroundShape import Dodge.Data.ForegroundShape
defaultForeground :: ForegroundShape defaultForeground :: ForegroundShape
defaultForeground = ForegroundShape 0 0 0 0 mempty defaultForeground = ForegroundShape 0 0 mempty
+1 -5
View File
@@ -126,11 +126,7 @@ placeSpotID rid ps pt w = case pt of
) )
PutCrit cr -> plNewUpID (gwWorld . cWorld . lWorld . creatures) crID (mvCr p rot cr) w PutCrit cr -> plNewUpID (gwWorld . cWorld . lWorld . creatures) crID (mvCr p rot cr) w
PutForeground fs -> PutForeground fs ->
plNewUpID (0, w & gwWorld . cWorld . lWorld . foreShapes .:~ mvFS p rot fs)
(gwWorld . cWorld . lWorld . foreShapes)
fsID
(mvFS p rot fs)
w
PutMachine pps mc mitm -> plMachine (map doShift pps) mc mitm p rot w PutMachine pps mc mitm -> plMachine (map doShift pps) mc mitm p rot w
PutLS ls -> plNewUpID (gwWorld . cWorld . lWorld . lightSources) lsID (mvLS p' rot ls) w PutLS ls -> plNewUpID (gwWorld . cWorld . lWorld . lightSources) lsID (mvLS p' rot ls) w
RandPS _ -> error "RandPS should not be reachable here" --evaluateRandPS rid rgn ps w RandPS _ -> error "RandPS should not be reachable here" --evaluateRandPS rid rgn ps w
+1 -1
View File
@@ -29,7 +29,7 @@ worldSPic cfig u =
-- <> foldup (shiftDraw _blPos _blDir (const $ drawBlock . _blDraw)) -- <> foldup (shiftDraw _blPos _blDir (const $ drawBlock . _blDraw))
<> foldup (shiftDraw _blPos _blDir (const $ noPic . _blDraw)) <> foldup (shiftDraw _blPos _blDir (const $ noPic . _blDraw))
(filtOn _blPos _blocks) (filtOn _blPos _blocks)
<> foldup (shiftDraw _fsPos _fsDir (const _fsSPic)) (filtOn _fsPos _foreShapes) <> foldMap' (shiftDraw _fsPos _fsDir (const _fsSPic)) (filtOn' _fsPos _foreShapes)
<> foldup (drawCreature (lw ^. items)) (filtOn (^. crPos . _xy) _creatures) <> foldup (drawCreature (lw ^. items)) (filtOn (^. crPos . _xy) _creatures)
<> foldup <> foldup
(Prelude.uncurry floorItemSPic) (Prelude.uncurry floorItemSPic)
-5
View File
@@ -136,7 +136,6 @@ putShape sh =
PutForeground $ PutForeground $
defaultForeground defaultForeground
& fsPos .~ m & fsPos .~ m
& fsRad .~ radBounds bnds
& fsSPic .~ noPic (uncurryV translateSHxy (- m) sh) & fsSPic .~ noPic (uncurryV translateSHxy (- m) sh)
where where
bnds = shapeBounds sh bnds = shapeBounds sh
@@ -151,9 +150,6 @@ shapeBounds = fromMaybe (0, 0, 0, 0) . boundPoints . shapePoints
midBounds :: (Float, Float, Float, Float) -> Point2 midBounds :: (Float, Float, Float, Float) -> Point2
midBounds (n, s, e, w) = V2 ((n + s) / 2) ((e + w) / 2) midBounds (n, s, e, w) = V2 ((n + s) / 2) ((e + w) / 2)
radBounds :: (Float, Float, Float, Float) -> Float
radBounds (n, s, e, w) = max (n - s) (e - w) / 2
girderV' :: girderV' ::
-- | height -- | height
Float -> Float ->
@@ -167,7 +163,6 @@ girderV' ::
girderV' h d w x y = girderV' h d w x y =
defaultForeground defaultForeground
& fsPos .~ m & fsPos .~ m
& fsRad .~ dist m x
& fsSPic .~ noPic sh & fsSPic .~ noPic sh
where where
m = midPoint x y m = midPoint x y
-2
View File
@@ -14,7 +14,6 @@ floorWire :: Point2 -> Point2 -> ForegroundShape
floorWire a b = floorWire a b =
defaultForeground defaultForeground
& fsPos .~ m & fsPos .~ m
& fsRad .~ dist m a
& fsSPic .~ noPic (colorSH yellow $ thinHighBar 0 a' b') & fsSPic .~ noPic (colorSH yellow $ thinHighBar 0 a' b')
where where
m = midPoint a b m = midPoint a b
@@ -25,7 +24,6 @@ verticalWire :: Point2 -> Float -> Float -> ForegroundShape
verticalWire p h1 h2 = verticalWire p h1 h2 =
defaultForeground defaultForeground
& fsPos .~ p & fsPos .~ p
& fsRad .~ 2
& fsSPic .~ noPic (colorSH yellow $ barPP 1.5 (V3 0 0 h1) (V3 0 0 h2)) & fsSPic .~ noPic (colorSH yellow $ barPP 1.5 (V3 0 0 h1) (V3 0 0 h2))
putWireEnd :: Int -> (Point2, Float) -> Float -> Room -> Room putWireEnd :: Int -> (Point2, Float) -> Float -> Room -> Room