From 3eb26e86a8251bb5a3f1b7e54f9cd84a318d81fd Mon Sep 17 00:00:00 2001 From: justin Date: Fri, 1 Jul 2022 20:06:25 +0100 Subject: [PATCH] Redo zone size/update --- src/Dodge/Zone/Size.hs | 3 +++ src/Dodge/Zone/Update.hs | 15 ++++----------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/Dodge/Zone/Size.hs b/src/Dodge/Zone/Size.hs index 16fda43e3..1b4c1351a 100644 --- a/src/Dodge/Zone/Size.hs +++ b/src/Dodge/Zone/Size.hs @@ -1,5 +1,8 @@ module Dodge.Zone.Size where +pnZoneSize :: Float +pnZoneSize = 100 + wlZoneSize :: Float wlZoneSize = 50 diff --git a/src/Dodge/Zone/Update.hs b/src/Dodge/Zone/Update.hs index 1bbfa09be..c3fdba974 100644 --- a/src/Dodge/Zone/Update.hs +++ b/src/Dodge/Zone/Update.hs @@ -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