Create post world load function

This commit is contained in:
2023-03-18 09:37:09 +00:00
parent d8fb7a1f99
commit 77c88f68a7
14 changed files with 80 additions and 48 deletions
+13 -9
View File
@@ -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 =