Turn shapeObject's vertices into a stream
This commit is contained in:
+7
-3
@@ -19,6 +19,7 @@ import qualified Data.Vector.Unboxed as UV
|
||||
import qualified Data.Vector.Unboxed.Mutable as UMV
|
||||
import qualified Data.Vector.Mutable as MV
|
||||
import qualified Data.Vector.Fusion.Stream.Monadic as VS
|
||||
import Data.Vector.Fusion.Util
|
||||
import Control.Monad.Primitive
|
||||
--import qualified Control.Monad.Parallel as MP
|
||||
|
||||
@@ -102,21 +103,22 @@ pokeShapeObj ptr iptr ieptr counts (ShapeObj shType shVerts) = case shType of
|
||||
pokeTopPrism :: Int -> Ptr Float -> Ptr GLushort
|
||||
-> Ptr GLushort
|
||||
-> (Int,Int,Int)
|
||||
-> [ShapeV]
|
||||
-> VS.Stream IO ShapeV
|
||||
-> IO (Int,Int,Int)
|
||||
{-# INLINE pokeTopPrism #-}
|
||||
pokeTopPrism size ptr iptr ieptr (nv,nshapeindices,nedgeindices) svs = do
|
||||
nv' <- VS.foldM (pokeJustV ptr) nv (VS.fromList svs)
|
||||
nv' <- VS.foldM (pokeJustV ptr) nv svs
|
||||
nshapeindices' <- UV.foldM (pokeTopPrismIndex nv iptr) nshapeindices
|
||||
(memoTopPrismIndices V.! size)
|
||||
nedgeindices' <- UV.foldM (pokeTopPrismEdgeIndex nv ieptr) nedgeindices
|
||||
(memoTopPrismEdgeIndices V.! size)
|
||||
return ( nv', nshapeindices', nedgeindices')
|
||||
return (nv', nshapeindices', nedgeindices')
|
||||
|
||||
pokeTopPrismEdgeIndex :: Int -> Ptr GLushort
|
||||
-> Int
|
||||
-> Int
|
||||
-> IO Int
|
||||
{-# INLINE pokeTopPrismEdgeIndex #-}
|
||||
pokeTopPrismEdgeIndex nv eiptr nedgeindices ioff = do
|
||||
pokeElemOff eiptr nedgeindices (fromIntegral $ nv + ioff)
|
||||
return $ nedgeindices + 1
|
||||
@@ -125,6 +127,7 @@ pokeTopPrismIndex :: Int -> Ptr GLushort
|
||||
-> Int
|
||||
-> Int
|
||||
-> IO Int
|
||||
{-# INLINE pokeTopPrismIndex #-}
|
||||
pokeTopPrismIndex nv iptr nshapeindices ioff = do
|
||||
pokeElemOff iptr nshapeindices (fromIntegral $ nv + ioff)
|
||||
return $ nshapeindices + 1
|
||||
@@ -165,6 +168,7 @@ pokeJustV :: Ptr Float
|
||||
-> Int
|
||||
-> ShapeV
|
||||
-> IO Int
|
||||
{-# INLINE pokeJustV #-}
|
||||
pokeJustV ptr nv sh = do
|
||||
let off i = nv*7 + i
|
||||
pokeElemOff ptr (off 0) a
|
||||
|
||||
Reference in New Issue
Block a user