Use Fold for rendering
This commit is contained in:
@@ -48,6 +48,7 @@ dependencies:
|
|||||||
- directory
|
- directory
|
||||||
- QuickCheck
|
- QuickCheck
|
||||||
- extra
|
- extra
|
||||||
|
#- streaming
|
||||||
|
|
||||||
library:
|
library:
|
||||||
source-dirs: src
|
source-dirs: src
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ fromV3 :: V3 a -> (a,a,a)
|
|||||||
fromV3 (V3 a b c) = (a,b,c)
|
fromV3 (V3 a b c) = (a,b,c)
|
||||||
|
|
||||||
uncurryV :: (a -> a -> b) -> V2 a -> b
|
uncurryV :: (a -> a -> b) -> V2 a -> b
|
||||||
|
{-# INLINE uncurryV #-}
|
||||||
uncurryV f (V2 x y) = f x y
|
uncurryV f (V2 x y) = f x y
|
||||||
|
|
||||||
fstV2 :: V2 a -> a
|
fstV2 :: V2 a -> a
|
||||||
|
|||||||
+1
-1
@@ -171,7 +171,7 @@ pokeBindFoldableLayer
|
|||||||
pokeBindFoldableLayer pdata m = do
|
pokeBindFoldableLayer pdata m = do
|
||||||
let shads = _pictureShaders pdata
|
let shads = _pictureShaders pdata
|
||||||
|
|
||||||
slist'' <- pokeLayVerxsPart (fmap (_vaoVBO . _vshaderVAO) shads) m (pure $ pure 0)
|
slist'' <- pokeLayVerxsFold (fmap (_vaoVBO . _vshaderVAO) shads) m
|
||||||
bindShaderLay shads slist''
|
bindShaderLay shads slist''
|
||||||
|
|
||||||
return slist''
|
return slist''
|
||||||
|
|||||||
+18
-6
@@ -7,6 +7,7 @@ module Shader.Poke
|
|||||||
, pokePoint33s
|
, pokePoint33s
|
||||||
, pokeVerxs
|
, pokeVerxs
|
||||||
, pokeLayVerxs
|
, pokeLayVerxs
|
||||||
|
, pokeLayVerxsFold
|
||||||
, pokeLayVerxsPart
|
, pokeLayVerxsPart
|
||||||
, pokeLayVerxsPartM
|
, pokeLayVerxsPartM
|
||||||
, pokeLayVerxsM
|
, pokeLayVerxsM
|
||||||
@@ -18,19 +19,24 @@ import Picture.Data
|
|||||||
import Geometry.Data
|
import Geometry.Data
|
||||||
import Layers
|
import Layers
|
||||||
|
|
||||||
|
--import qualified Streaming.Prelude as SP
|
||||||
--import Data.Maybe
|
--import Data.Maybe
|
||||||
--import Data.List
|
--import Data.List
|
||||||
import Foreign
|
import Foreign
|
||||||
import Control.Monad
|
import Control.Monad
|
||||||
--import qualified Control.Foldl as F
|
import qualified Control.Foldl as F
|
||||||
--import qualified Data.IntMap.Strict as IM
|
--import qualified Data.IntMap.Strict as IM
|
||||||
--import Control.Lens
|
--import Control.Lens
|
||||||
|
|
||||||
pokeVerxs :: PicShads VBO -> [Verx] -> IO (PicShads Int)
|
pokeVerxs :: PicShads VBO -> [Verx] -> IO (PicShads Int)
|
||||||
pokeVerxs vbos vxs0 = go vxs0 (pure 0)
|
pokeVerxs vbos = F.foldM $ F.FoldM
|
||||||
where
|
(\count vx -> pokeVerx vbos count vx >> return (addCountVerx count vx))
|
||||||
go [] !count = return count
|
(pure $ pure 0)
|
||||||
go (!vx:vxs) !count = pokeVerx vbos count vx >> (go vxs $! addCountVerx count vx)
|
return
|
||||||
|
--pokeVerxs vbos vxs0 = go vxs0 (pure 0)
|
||||||
|
-- where
|
||||||
|
-- go [] !count = return count
|
||||||
|
-- go (!vx:vxs) !count = pokeVerx vbos count vx >> (go vxs $! addCountVerx count vx)
|
||||||
|
|
||||||
-- this is very brittle, but want to optimise speed if possible here
|
-- this is very brittle, but want to optimise speed if possible here
|
||||||
pokeVerx :: PicShads VBO -> PicShads Int -> Verx -> IO ()
|
pokeVerx :: PicShads VBO -> PicShads Int -> Verx -> IO ()
|
||||||
@@ -121,6 +127,12 @@ pokePoint3s ptr vals0 = go vals0 0
|
|||||||
where
|
where
|
||||||
off i = n*3 + i
|
off i = n*3 + i
|
||||||
|
|
||||||
|
pokeLayVerxsFold :: PicShads VBO -> [Verx] -> IO (Layers (PicShads Int))
|
||||||
|
pokeLayVerxsFold !vbos = F.foldM $ F.FoldM
|
||||||
|
(\counts vx -> pokeLayVerx vbos counts vx >> return (addLayCountVerx counts vx))
|
||||||
|
(pure $ pure $ pure 0)
|
||||||
|
return
|
||||||
|
|
||||||
pokeLayVerxsM :: PicShads VBO -> [Verx] -> IO (Layers (PicShads Int))
|
pokeLayVerxsM :: PicShads VBO -> [Verx] -> IO (Layers (PicShads Int))
|
||||||
pokeLayVerxsM !vbos = foldM f (pure $ pure 0)
|
pokeLayVerxsM !vbos = foldM f (pure $ pure 0)
|
||||||
where
|
where
|
||||||
@@ -145,7 +157,7 @@ pokeLayVerxs !vbos vxs0 = go vxs0 (pure (pure 0))
|
|||||||
|
|
||||||
-- this is very brittle, but want to optimise speed if possible here
|
-- this is very brittle, but want to optimise speed if possible here
|
||||||
pokeLayVerx :: PicShads VBO -> Layers (PicShads Int) -> Verx -> IO ()
|
pokeLayVerx :: PicShads VBO -> Layers (PicShads Int) -> Verx -> IO ()
|
||||||
{-# INLINE pokeLayVerx #-}
|
--{-# INLINE pokeLayVerx #-}
|
||||||
pokeLayVerx vbos imoffsets Verx{_vxPos=thePos,_vxCol=theCol,_vxType=theType, _vxLayer = theLay} = case theType of
|
pokeLayVerx vbos imoffsets Verx{_vxPos=thePos,_vxCol=theCol,_vxType=theType, _vxLayer = theLay} = case theType of
|
||||||
PolyV -> poke34 (plusPtr (_vboPtr $ _psPoly vbos) ((_psPoly offsets + layOff) * 7 * floatSize)) thePos theCol
|
PolyV -> poke34 (plusPtr (_vboPtr $ _psPoly vbos) ((_psPoly offsets + layOff) * 7 * floatSize)) thePos theCol
|
||||||
PolyzV x -> poke34 thePtr thePos theCol
|
PolyzV x -> poke34 thePtr thePos theCol
|
||||||
|
|||||||
Reference in New Issue
Block a user