Creature shadow test

This commit is contained in:
2021-08-28 20:42:20 +01:00
parent f977742f06
commit 55f1d89a5e
6 changed files with 26 additions and 8 deletions
+18
View File
@@ -34,6 +34,16 @@ constructEdges (face:faces) = mapMaybe (findReverseEdge otherEdges) (faceEdges f
otherEdges = concatMap faceEdges faces
constructEdges _ = []
-- | a version of construct edges that directly returns the flattened list of
-- tuples
constructEdgesList :: [[Point3]] -> [Point3]
constructEdgesList (face:faces) = concatMap (findReverseEdgeList otherEdges) (faceEdges face)
++ constructEdgesList faces
where
otherEdges = concatMap faceEdges faces
constructEdgesList _ = []
findReverseEdge
:: [(Point3,Point3,Point3)]
-> (Point3,Point3,Point3)
@@ -41,6 +51,14 @@ findReverseEdge
findReverseEdge otherEdges (x,y,z) = (\(_,_,n) -> (x,y,z,n))
<$> find (\(a,b,_) -> (x,y) == (b,a)) otherEdges
findReverseEdgeList
:: [(Point3,Point3,Point3)]
-> (Point3,Point3,Point3)
-> [Point3]
findReverseEdgeList a b = case findReverseEdge a b of
Nothing -> []
Just (x,y,z,w) -> [x,y,z,w]
faceEdges :: [Point3] -> [(Point3,Point3,Point3)]
faceEdges xs = zipWith addNormal xs (tail xs ++ [head xs])
where