found the particle leak!

This commit is contained in:
nek0 2017-02-25 17:23:28 +01:00
parent 896a64a6fc
commit 46f51d1334
1 changed files with 10 additions and 7 deletions

View File

@ -1,4 +1,5 @@
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE BangPatterns #-}
-- | This module introduces a simple particle system to Affection
module Affection.Particle
@ -116,7 +117,7 @@ updateParticleSystem
-> (G.GeglBuffer -> G.GeglNode -> Particle -> Affection us ())
-> Affection us ParticleSystem
updateParticleSystem sys sec upd draw = do
x <- catMaybes <$> mapM (updateParticle sec upd) (partStorList $ partSysParts sys)
!x <- catMaybes <$> mapM (updateParticle sec upd) (partStorList $ partSysParts sys)
-- liftIO $ traceIO $ show $ length x
-- x <- catMaybes <$> foldM (updateParticle sec upd) [] (reverse $ psParts sys)
if (not $ null x)
@ -125,17 +126,19 @@ updateParticleSystem sys sec upd draw = do
-- liftIO $ traceIO "linking last node to output"
liftIO $ G.gegl_node_link (particleStackCont $ head x) (partSysNode sys)
mapM_ (draw (partSysBuffer sys) (partSysNode sys)) x
return $ sys
return sys
{ partSysParts = (partSysParts sys)
{ partStorList = x
, partStorLatest =
if null x
then Nothing
else partStorLatest (partSysParts sys)
}
}
else
else do
_ <- liftIO $ G.gegl_node_disconnect (partSysNode sys) "input"
return sys
{ partSysParts = ParticleStorage
{ partStorList = []
, partStorLatest = Nothing
}
}
-- | Function for inserting a new 'Particle' into its 'PartileSystem'
insertParticle