Draw shape shadows using index buffer

This commit is contained in:
2021-09-21 00:43:45 +01:00
parent 5cbcbec101
commit 7f1a365cac
9 changed files with 167 additions and 41 deletions
+13 -5
View File
@@ -40,7 +40,7 @@ upperPrismPoly
-> Shape
{-# INLINE upperPrismPoly #-}
upperPrismPoly h ps =
( topFace <> sideFaces
( [ShapeObj ListV (topFace <> sideFaces)]
, topEdges <> bottomEdges <> sideEdges
)
where
@@ -64,7 +64,7 @@ prismPoly
-> Shape
{-# INLINE prismPoly #-}
prismPoly h ps =
( topFace <> bottomFace <> sideFaces
( [ShapeObj ListV (topFace <> bottomFace <> sideFaces)]
, topEdges <> bottomEdges <> sideEdges
)
where
@@ -86,7 +86,7 @@ prismPoly h ps =
flatPoly :: [Point2] -> Shape
flatPoly ps =
( shVfromList $ polyToTris $ map f ps
( [ShapeObj ListV $ shVfromList $ polyToTris $ map f ps]
, shEfromList $ concat $ zipWith g ps (tail ps ++ [head ps])
)
where
@@ -106,11 +106,11 @@ colorSH col = overCol $ const col
overCol :: (Point4 -> Point4) -> Shape -> Shape
{-# INLINE overCol #-}
overCol f = first (fmap $ overColVertex f)
overCol f = first (fmap $ overColObj f)
overPos :: (Point3 -> Point3) -> Shape -> Shape
{-# INLINE overPos #-}
overPos f = bimap (fmap $ overPosVertex f) (fmap f)
overPos f = bimap (fmap $ overPosObj f) (fmap f)
translateSH :: Point3 -> Shape -> Shape
{-# INLINE translateSH #-}
@@ -132,10 +132,18 @@ scaleSH :: Point3 -> Shape -> Shape
{-# INLINE scaleSH #-}
scaleSH !(V3 a b c) = overPos (\(V3 x y z) -> V3 (x*a) (y*b) (z*c))
overColObj :: (Point4 -> Point4) -> ShapeObj -> ShapeObj
{-# INLINE overColObj #-}
overColObj f (ShapeObj st vs) = ShapeObj st (map (overColVertex f) vs)
overColVertex :: (Point4 -> Point4) -> ShapeV -> ShapeV
{-# INLINE overColVertex #-}
overColVertex f (ShapeV a b) = ShapeV a (f b)
overPosObj :: (Point3 -> Point3) -> ShapeObj -> ShapeObj
{-# INLINE overPosObj #-}
overPosObj f (ShapeObj st vs) = ShapeObj st $ map (overPosVertex f) vs
overPosVertex :: (Point3 -> Point3) -> ShapeV -> ShapeV
{-# INLINE overPosVertex #-}
overPosVertex f (ShapeV a b) = ShapeV (f a) b