Create post world load function
This commit is contained in:
+13
-9
@@ -4,10 +4,12 @@ module Shader.Poke (
|
||||
pokeArrayOff,
|
||||
pokeShape,
|
||||
pokeWallsWindowsFloor,
|
||||
pokeWallsWindows,
|
||||
memoTopPrismEdgeIndices,
|
||||
pokeFloors
|
||||
) where
|
||||
|
||||
import Shader.Poke.Triangulate
|
||||
import Control.Monad.Primitive
|
||||
import qualified Data.Vector as V
|
||||
import qualified Data.Vector.Fusion.Stream.Monadic as VFSM
|
||||
@@ -55,6 +57,17 @@ pokeWallsWindowsFloor wlptr wiptr flptr wls wis fls = do
|
||||
flcounts <- VFSM.foldlM' (pokeF flptr) 0 (VFSM.fromList fls)
|
||||
return (wlcounts1, wlcounts2, flcounts)
|
||||
|
||||
pokeWallsWindows ::
|
||||
Ptr Float ->
|
||||
Ptr Float ->
|
||||
[((Point2, Point2), Point4)] ->
|
||||
[((Point2, Point2), Point4)] ->
|
||||
IO (Int, Int)
|
||||
pokeWallsWindows wlptr wiptr wls wis = do
|
||||
wlcounts1 <- VFSM.foldlM' (pokeW wlptr) 0 (VFSM.fromList wls)
|
||||
wlcounts2 <- VFSM.foldlM' (pokeW wiptr) 0 (VFSM.fromList wis)
|
||||
return (wlcounts1, wlcounts2)
|
||||
|
||||
pokeFloors :: Ptr Float ->
|
||||
[(Point3, Point3)] ->
|
||||
IO Int
|
||||
@@ -240,15 +253,6 @@ pokeIndex nv eiptr ni ioff = do
|
||||
pokeElemOff eiptr ni (fromIntegral $ nv + ioff)
|
||||
return $ ni + 1
|
||||
|
||||
triangulate :: [Int] -> [Int]
|
||||
triangulate is = V.toList . V.backpermute (V.fromList is) . V.fromList $ triangulateIndices (length is)
|
||||
|
||||
triangulateIndices :: Int -> [Int]
|
||||
triangulateIndices i = concatMap f [0 .. i -3]
|
||||
where
|
||||
f x
|
||||
| even x = [0, x + 1, x + 2]
|
||||
| otherwise = [0, x + 2, x + 1]
|
||||
|
||||
memoFlatIndices :: V.Vector (UV.Vector Int)
|
||||
memoFlatIndices =
|
||||
|
||||
Reference in New Issue
Block a user