Improve level generation speed
This commit is contained in:
@@ -48,14 +48,29 @@ faceEdges xs = zipWith addNormal xs (tail xs ++ [head xs])
|
||||
n = crossProd (b -.-.- a) (c -.-.- a)
|
||||
|
||||
rhombus :: Point3 -> Point3 -> [Point3]
|
||||
{-# INLINE rhombus #-}
|
||||
rhombus a b =
|
||||
[V3 0 0 0
|
||||
,a
|
||||
,a +.+.+ b
|
||||
,b
|
||||
]
|
||||
boxXYZnobase :: Float -> Float -> Float -> [[Point3]]
|
||||
{-# INLINE boxXYZnobase #-}
|
||||
boxXYZnobase x y z =
|
||||
[ map (+.+.+ V3 0 0 z) $ reverse bottomFace
|
||||
, frontFace
|
||||
, map (+.+.+ V3 0 y 0) $ reverse frontFace
|
||||
, sideFace
|
||||
, map (+.+.+ V3 x 0 0) $ reverse sideFace
|
||||
]
|
||||
where
|
||||
bottomFace = rhombus (V3 0 y 0) (V3 x 0 0)
|
||||
frontFace = rhombus (V3 x 0 0) (V3 0 0 z)
|
||||
sideFace = rhombus (V3 0 0 z) (V3 0 y 0)
|
||||
|
||||
boxXYZ :: Float -> Float -> Float -> [[Point3]]
|
||||
{-# INLINE boxXYZ #-}
|
||||
boxXYZ x y z =
|
||||
[ bottomFace
|
||||
, map (+.+.+ V3 0 0 z) $ reverse bottomFace
|
||||
@@ -86,6 +101,7 @@ polyToPics :: Polyhedra -> [Picture]
|
||||
polyToPics = map helpPoly3D . _pyFaces
|
||||
|
||||
helpPoly3D :: [(Point3, Point4)] -> [Verx]
|
||||
--{-# INLINE helpPoly3D #-}
|
||||
helpPoly3D vs = map f $ polyToTris vs
|
||||
where
|
||||
f (pos,col) = Verx pos col [] 0 polyNum
|
||||
|
||||
Reference in New Issue
Block a user