Prop reification/splitting

This commit is contained in:
2022-07-24 13:45:05 +01:00
parent 5a2f529182
commit ac069d08f6
31 changed files with 585 additions and 458 deletions
+13 -14
View File
@@ -16,36 +16,35 @@ import ShapePicture
import Control.Lens
import Data.Maybe
propLSThen :: (Prop -> World -> World)
-> (Prop -> World -> LightSource -> LightSource)
propLSThen :: PropUpdate
-> PrWdLsLs --(Prop -> World -> LightSource -> LightSource)
-> LightSource
-> Prop
-> (Placement -> Placement -> Maybe Placement) -- ^ continuation, access to ls and prop placements
-> Placement
propLSThen propf lsf ls prop cont = pt0 (PutLS ls)
$ \lspl -> Just $ pt0 (PutProp $ prop & pjUpdate .~ theupdate (fromJust $ _plMID lspl))
$ \lspl -> Just $ pt0 (PutProp $ prop & prUpdate .~ PropUpdates [propf,PropUpdateLS (fromJust $ _plMID lspl) lsf])
-- theupdate (fromJust $ _plMID lspl))
$ cont lspl
where
theupdate lsid pr w = propf pr w & lightSources . ix lsid %~ lsf pr w
--theupdate lsid pr w = propf pr w & lightSources . ix lsid %~ lsf pr w
moveLSThen :: (World -> (Point2,Float))
moveLSThen :: WdP2f --(World -> (Point2,Float))
-> Point3 -- ^ light source offset
-> Shape
-> (Placement -> Placement -> Maybe Placement)
-> Placement
moveLSThen posf off sh = propLSThen propupdate lsupdate thels theprop
moveLSThen posf off sh = propLSThen (PropUpdatePosition posf) (PrWdLsSetPosition posf off) thels theprop
where
propupdate pr w = w
& props . ix (_pjID pr) . prPos .~ fst (posf w)
& props . ix (_pjID pr) . pjRot .~ snd (posf w)
lsupdate _ w = lsParam . lsPos .~ addZ 0 (fst (posf w)) +.+.+ rotate3z (snd (posf w)) off
--lsupdate _ w = lsParam . lsPos .~ addZ 0 (fst (posf w)) +.+.+ rotate3z (snd (posf w)) off
thels = defaultLS
theprop = ShapeProp
{ _prPos = 0
, _pjID = 0
, _pjRot = 0
, _pjUpdate = const id
, _prDraw = \pr -> noPic $ uncurryV translateSHf (_prPos pr) $ rotateSH (_pjRot pr) sh
, _prID = 0
, _prRot = 0
, _prUpdate = PropUpdateId
--, _prDraw = PropDrawSPic $ noPic $ uncurryV translateSHf (_prPos pr) $ rotateSH (_pjRot pr) sh
, _prDraw = PropDrawFlatTranslate $ PropDrawSPic $ noPic sh
, _prToggle = True
}