Implement randomness at the placement datatype level
This commit is contained in:
@@ -28,12 +28,17 @@ placeSpot w (shift, plmnt@Placement{}) =
|
||||
let (i,w') = placeSpotID (shiftPSBy shift (_placementSpot plmnt)) (_psType plmnt) w
|
||||
in maybe w' (curry (placeSpot w') shift) (_idPlacement plmnt i)
|
||||
placeSpot w (shift, PlacementUsingPos p subpl) = placeSpot w (shift, subpl (shiftPoint3By shift p))
|
||||
-- random placements SHOULD be dealt with already (see assignPlacementSpots)
|
||||
placeSpot w (shift, RandomPlacement rplmnt) = placeSpot (w & randGen .~ g) (shift, plmnt)
|
||||
where
|
||||
(plmnt, g) = runState rplmnt (_randGen w)
|
||||
|
||||
shiftPlacement :: (Point2,Float) -> Placement -> Placement
|
||||
shiftPlacement shift (Placement ps pt f) = Placement (shiftPSBy shift ps) pt
|
||||
(fmap (fmap $ shiftPlacement shift) f)
|
||||
shiftPlacement shift (PlacementUsingPos p f) = PlacementUsingPos (shiftPoint3By shift p)
|
||||
(fmap (shiftPlacement shift) f)
|
||||
shiftPlacement shift (RandomPlacement rpl) = RandomPlacement $ fmap (shiftPlacement shift) rpl
|
||||
|
||||
shiftPSBy :: (Point2,Float) -> PlacementSpot -> PlacementSpot
|
||||
shiftPSBy (pos,rot) ps = ps
|
||||
|
||||
Reference in New Issue
Block a user