Redo zone size/update

This commit is contained in:
2022-07-01 20:06:25 +01:00
parent 12f409fff3
commit 3eb26e86a8
2 changed files with 7 additions and 11 deletions
+3
View File
@@ -1,5 +1,8 @@
module Dodge.Zone.Size where
pnZoneSize :: Float
pnZoneSize = 100
wlZoneSize :: Float
wlZoneSize = 50
+4 -11
View File
@@ -1,4 +1,6 @@
module Dodge.Zone.Update where
module Dodge.Zone.Update
( updateZoning
) where
import Dodge.Data.Zoning
import StreamingHelp
import qualified Streaming.Prelude as S
@@ -7,20 +9,11 @@ import Geometry
import LensHelp
updateZoning :: Monoid (t a) => (a -> t a -> t a) -> a -> Zoning t a -> Zoning t a
{-# INLINE updateZoning #-}
updateZoning f obj zn = runIdentity (S.fold_ doinsert zn id (_znFunc zn (_znSize zn) obj))
where
doinsert znobs vxy = insertInZoneWith vxy (\_ -> f obj) (f obj mempty) znobs
--alterInZone :: (a -> Maybe (t a) -> Maybe (t a)) -> a -> Zoning
updateInZoning' :: Applicative t => (t a -> t a -> t a) -> a -> Zoning t a -> Zoning t a
updateInZoning' f obj zn = runIdentity (S.fold_ doinsert zn id (_znFunc zn (_znSize zn) obj))
where
doinsert znobs vxy = insertInZoneWith vxy f (pure obj) znobs
imInsert :: (a -> Int) -> a -> IM.IntMap a -> IM.IntMap a
imInsert getID x = IM.insert (getID x) x
insertInZoneWith
:: Int2
-> (t a -> t a -> t a) -- ^ Combining function