de-parallelize

This commit is contained in:
nek0 2017-11-04 20:37:49 +01:00
parent 2a9f7ffebc
commit 2c731bea97
2 changed files with 4 additions and 6 deletions

View file

@ -23,7 +23,6 @@ import Data.IORef
import System.Clock import System.Clock
import Control.Monad.Loops import Control.Monad.Loops
import qualified Control.Monad.Parallel as MP
import Control.Monad.State import Control.Monad.State
import Foreign.C.Types (CInt(..)) import Foreign.C.Types (CInt(..))
@ -129,7 +128,7 @@ withAffection AffectionConfig{..} = do
now <- liftIO $ getTime Monotonic now <- liftIO $ getTime Monotonic
let lastTime = sysTime ad let lastTime = sysTime ad
-- clean draw requests from last run -- clean draw requests from last run
MP.mapM_ (invalidateDrawRequest (drawStride ad) (drawCPP ad)) (drawStack ad) mapM_ (invalidateDrawRequest (drawStride ad) (drawCPP ad)) (drawStack ad)
-- clean the renderer form last time -- clean the renderer form last time
-- SDL.clear renderer -- SDL.clear renderer
-- compute dt and update elapsedTime -- compute dt and update elapsedTime
@ -150,7 +149,7 @@ withAffection AffectionConfig{..} = do
-- handle all new draw requests -- handle all new draw requests
ad2 <- get ad2 <- get
clear <- catMaybes <$> clear <- catMaybes <$>
MP.mapM (handleDrawRequest (drawStride ad) (drawCPP ad)) (drawStack ad2) mapM (handleDrawRequest (drawStride ad) (drawCPP ad)) (drawStack ad2)
-- save all draw requests to clear in next run -- save all draw requests to clear in next run
put $ ad2 put $ ad2
{ drawStack = clear } { drawStack = clear }

View file

@ -13,7 +13,6 @@ import Affection.Types
import Control.Monad import Control.Monad
import Control.Monad.State (get) import Control.Monad.State (get)
import qualified Control.Monad.Parallel as MP
import Data.Maybe import Data.Maybe
@ -34,7 +33,7 @@ updateParticle
-> Affection us [Particle] -> Affection us [Particle]
-- ^ processed 'Particle's -- ^ processed 'Particle's
updateParticle time func l = updateParticle time func l =
catMaybes <$> MP.mapM (\p -> do catMaybes <$> mapM (\p -> do
now <- elapsedTime <$> get now <- elapsedTime <$> get
if particleCreation p + particleTimeToLive p < now if particleCreation p + particleTimeToLive p < now
then do then do
@ -124,7 +123,7 @@ drawParticleSystem sys draw =
if not (null parts) if not (null parts)
then do then do
liftIO $ G.gegl_node_link (particleStackCont $ head parts) (partSysNode sys) liftIO $ G.gegl_node_link (particleStackCont $ head parts) (partSysNode sys)
MP.mapM_ (draw (partSysBuffer sys) (partSysNode sys)) parts mapM_ (draw (partSysBuffer sys) (partSysNode sys)) parts
else do else do
_ <- liftIO $ G.gegl_node_disconnect (partSysNode sys) "input" _ <- liftIO $ G.gegl_node_disconnect (partSysNode sys) "input"
return () return ()