Move towards resolving picture rendering bug
The bug concerns a mutable vector storing the amount of data that has been poked.
This commit is contained in:
+12
-32
@@ -5,7 +5,6 @@ module Picture.Base (
|
||||
module Picture.Data,
|
||||
module Picture.Arc,
|
||||
module Color,
|
||||
blank,
|
||||
polygon,
|
||||
polygonWire,
|
||||
polygonCol,
|
||||
@@ -17,7 +16,6 @@ module Picture.Base (
|
||||
--thickArcFull,
|
||||
thickCircle,
|
||||
thickLine,
|
||||
lineThick,
|
||||
thickLineCol,
|
||||
circleSolid,
|
||||
circleSolidCol,
|
||||
@@ -49,7 +47,6 @@ module Picture.Base (
|
||||
mirroryz,
|
||||
mirrorxz,
|
||||
overPos,
|
||||
picMap,
|
||||
fold,
|
||||
) where
|
||||
|
||||
@@ -59,18 +56,10 @@ import Geometry
|
||||
import Picture.Arc
|
||||
import Picture.Data
|
||||
|
||||
blank :: Picture
|
||||
{-# INLINE blank #-}
|
||||
blank = mempty
|
||||
|
||||
polygonWire :: [Point2] -> Picture
|
||||
{-# INLINE polygonWire #-}
|
||||
polygonWire ps = line (ps <> [head ps])
|
||||
|
||||
picMap :: (Verx -> Verx) -> Picture -> Picture
|
||||
{-# INLINE picMap #-}
|
||||
picMap = map
|
||||
|
||||
-- | Expects clockwise input.
|
||||
polygon :: [Point2] -> Picture
|
||||
{-# INLINE polygon #-}
|
||||
@@ -110,7 +99,7 @@ poly3Col = map f . polyToTris
|
||||
|
||||
color :: RGBA -> Picture -> Picture
|
||||
{-# INLINE color #-}
|
||||
color = picMap . overCol . const
|
||||
color = fmap . overCol . const
|
||||
|
||||
translateH :: Float -> Float -> Point3 -> Point3
|
||||
{-# INLINE translateH #-}
|
||||
@@ -118,30 +107,30 @@ translateH !a !b (V3 x y z) = V3 (x + a) (y + b) z
|
||||
|
||||
translate :: Float -> Float -> Picture -> Picture
|
||||
{-# INLINE translate #-}
|
||||
translate x = picMap . overPos . translateH x
|
||||
translate x = fmap . overPos . translateH x
|
||||
|
||||
translate3 :: Point3 -> Picture -> Picture
|
||||
{-# INLINE translate3 #-}
|
||||
translate3 = picMap . overPos . (+.+.+)
|
||||
translate3 = fmap . overPos . (+.+.+)
|
||||
|
||||
tranRot :: V2 Float -> Float -> Picture -> Picture
|
||||
{-# INLINE tranRot #-}
|
||||
tranRot (V2 x y) r = picMap $ overPos (translateH x y . rotate3 r)
|
||||
tranRot (V2 x y) r = fmap $ overPos (translateH x y . rotate3 r)
|
||||
|
||||
setDepth :: Float -> Picture -> Picture
|
||||
{-# INLINE setDepth #-}
|
||||
--setDepth d = map $ second $ overPos (\(x,y,_) -> (x,y,d))
|
||||
setDepth d = picMap $ overPos (\(V3 x y _) -> V3 x y d)
|
||||
setDepth d = fmap $ overPos (\(V3 x y _) -> V3 x y d)
|
||||
|
||||
addDepth :: Float -> Picture -> Picture
|
||||
{-# INLINE addDepth #-}
|
||||
--addDepth d = map $ second $ overPos (\(x,y,z) -> (x,y,z+d))
|
||||
addDepth d = picMap $ overPos (\(V3 x y z) -> V3 x y (z + d))
|
||||
addDepth d = fmap $ overPos (\(V3 x y z) -> V3 x y (z + d))
|
||||
|
||||
-- TODO change the Int here to a dedicated type
|
||||
setLayer :: Layer -> Picture -> Picture
|
||||
{-# INLINE setLayer #-}
|
||||
setLayer i = picMap f
|
||||
setLayer i = fmap f
|
||||
where
|
||||
f v = v{_vxLayer = i}
|
||||
|
||||
@@ -151,11 +140,11 @@ scale3 a b (V3 x y z) = V3 (x * a) (y * b) z
|
||||
|
||||
scale :: Float -> Float -> Picture -> Picture
|
||||
{-# INLINE scale #-}
|
||||
scale x = picMap . overPos . scale3 x
|
||||
scale x = fmap . overPos . scale3 x
|
||||
|
||||
rotate :: Float -> Picture -> Picture
|
||||
{-# INLINE rotate #-}
|
||||
rotate = picMap . overPos . rotate3
|
||||
rotate = fmap . overPos . rotate3
|
||||
|
||||
makeArc :: Float -> Point2 -> [Point2]
|
||||
{-# INLINE makeArc #-}
|
||||
@@ -246,16 +235,6 @@ lineCol :: [(Point2, RGBA)] -> Picture
|
||||
{-# INLINE lineCol #-}
|
||||
lineCol = thickLineCol 1
|
||||
|
||||
lineThick :: Float -> [Point2] -> Picture
|
||||
{-# INLINE lineThick #-}
|
||||
lineThick t = fold . f
|
||||
where
|
||||
f (x : y : ys)
|
||||
| x == y = f (x : ys)
|
||||
| otherwise = polygon [x +.+ n x y, x -.- n x y, y -.- n x y, y +.+ n x y] : f (y : ys)
|
||||
f _ = []
|
||||
n a b = (t * 0.5) *.* errorNormalizeV 42 (vNormal (a -.- b))
|
||||
|
||||
thickLine :: Float -> [Point2] -> Picture
|
||||
{-# INLINE thickLine #-}
|
||||
thickLine t = fold . f
|
||||
@@ -266,6 +245,7 @@ thickLine t = fold . f
|
||||
where
|
||||
n = (t * 0.5) *.* errorNormalizeV 42 (vNormal (x -.- y))
|
||||
f _ = []
|
||||
--f _ = error "Tried to draw line without at least two points"
|
||||
|
||||
thickLineCol :: Float -> [(Point2, RGBA)] -> Picture
|
||||
{-# INLINE thickLineCol #-}
|
||||
@@ -348,11 +328,11 @@ charToTuple xoff c
|
||||
-- offset = fromIntegral (fromEnum c) - 32
|
||||
|
||||
mirrorxz :: Picture -> Picture
|
||||
mirrorxz = picMap (overPos flipy)
|
||||
mirrorxz = fmap (overPos flipy)
|
||||
where
|
||||
flipy (V3 x y z) = V3 x (negate y) z
|
||||
|
||||
mirroryz :: Picture -> Picture
|
||||
mirroryz = picMap (overPos flipx)
|
||||
mirroryz = fmap (overPos flipx)
|
||||
where
|
||||
flipx (V3 x y z) = V3 (negate x) y z
|
||||
|
||||
+1
-1
@@ -19,8 +19,8 @@ data Verx = Verx
|
||||
|
||||
data Layer
|
||||
= BloomLayer
|
||||
-- | BloomNoZWrite
|
||||
| DebugLayer
|
||||
| DebugLayer1
|
||||
| FixedCoordLayer
|
||||
deriving (Eq, Ord, Enum, Bounded, Show, Read) --Generic, Flat)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user