Cleanup, remove old cylinder cap poke code

This commit is contained in:
2024-12-21 16:44:05 +00:00
parent 67fa50e2f8
commit 978bf864cc
2 changed files with 94 additions and 109 deletions
+8 -23
View File
@@ -182,7 +182,7 @@ pokeCylinder ::
{-# INLINE pokeCylinder #-}
pokeCylinder sfid col size ptr iptr ieptr (nv, nsi, nei) (tc : bc : svs) = do
nv' <- pokeRoundedCurve xdata col ptr tc bc svs nv
>>= pokeCylinderCaps xdata col ptr tc bc svs
>>= pokeCylinderCaps xdata col ptr svs
nsi' <-
UV.foldM'
(pokeIndex nv iptr)
@@ -209,17 +209,20 @@ pokeRoundedCurve xdata col ptr tc bc = go True
go False (x : xs) n = pokeJustV xdata bc col ptr n x >>= go True xs
go _ [] n = return n
pokeCylinderCaps :: Float -> Point4 -> Ptr Float -> Point3 -> Point3 -> [Point3] -> Int -> IO Int
-- I am not completely sure the normals are correct here
-- they assume that we do actually have a cylinder, with normals for the caps
-- that can be determined by the first two vertices
pokeCylinderCaps :: Float -> Point4 -> Ptr Float -> [Point3] -> Int
-> IO Int
{-# INLINE pokeCylinderCaps #-}
pokeCylinderCaps xdata col ptr tc bc (a:b:as) = go True (a:b:as)
pokeCylinderCaps xdata col ptr (a:b:as) = go True (a:b:as)
where
n1 = a - b
n2 = b - a
--go True (x : xs) n = pokeJustVInvNormal xdata tc col ptr n x >>= go False xs
--go False (x : xs) n = pokeJustVInvNormal xdata bc col ptr n x >>= go True xs
go True (x : xs) n = pokeFlatV xdata n1 col ptr n x >>= go False xs
go False (x : xs) n = pokeFlatV xdata n2 col ptr n x >>= go True xs
go _ [] n = return n
pokeCylinderCaps _ _ _ _ = const $ return 0
pokeBox ::
Bool ->
@@ -449,24 +452,6 @@ pokeJustV xdata cp col ptr nv sh = do
V3 x y z = sh
V3 nx ny nz = cp
pokeJustVInvNormal ::
Float ->
Point3 ->
Point4 ->
Ptr Float ->
Int ->
Point3 ->
IO Int
{-# INLINE pokeJustVInvNormal #-}
pokeJustVInvNormal xdata cp col ptr nv sh = do
pokeByteOff ptr (nv * shapeVerxSize) (V4 x y z xdata)
pokeByteOff ptr (nv *shapeVerxSize + 4 * floatSize) (toColor8 col)
pokeByteOff ptr (nv *shapeVerxSize + 4 * (floatSize + ubyteSize)) (V4 nx ny nz 1)
return (nv + 1)
where
V3 x y z = sh
V3 nx ny nz = (2 * sh) - cp
pokeFlatV ::
Float ->
Point3 ->