summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoe Crayne <joe@jerkface.net>2019-05-25 20:01:35 -0400
committerJoe Crayne <joe@jerkface.net>2019-05-25 20:01:35 -0400
commit27aa69522ca3da4fe04f996eb87a13e295db0f9f (patch)
tree12d08ea5b702b94753c1cfbd5fb18099a00368e5
parent786e58ccbb05ced78c5421b53fbc469971d7db82 (diff)
Attempt to detect sharp-turns.
-rw-r--r--MeshSketch.hs11
-rw-r--r--hello_obj2.lc9
2 files changed, 15 insertions, 5 deletions
diff --git a/MeshSketch.hs b/MeshSketch.hs
index ea8fbe6..7cda3fc 100644
--- a/MeshSketch.hs
+++ b/MeshSketch.hs
@@ -622,10 +622,15 @@ pushRing w st h k c = do
622 g <- pushFront (fromList [h,k]) <$> readIORef (stRecentPts st) 622 g <- pushFront (fromList [h,k]) <$> readIORef (stRecentPts st)
623 writeIORef (stRecentPts st) g 623 writeIORef (stRecentPts st) g
624 with3 g $ \a b c -> do 624 with3 g $ \a b c -> do
625 let d = det $ fromRows [(b-c),(a-b)] 625 let û = unit $ a-b
626 putStrLn $ "d = " ++ show d 626 v̂ = unit $ b-c
627 δ = norm_1 $ (a-b)^2
628 d = det $ fromRows [û,v̂]
629 x = dot û v̂
630 putStrLn $ "(d,x) = " ++ show (d,x)
627 updateBack (stRingBuffer st) $ \RingPoint{..} -> do 631 updateBack (stRingBuffer st) $ \RingPoint{..} -> do
628 rpColor @<- if d<0 then blue else red 632 rpColor @<- if x < 0.3 || δ<0.5 then yellow
633 else if d<0 then blue else red
629 pushBack (stRingBuffer st) $ \RingPoint{..} -> do 634 pushBack (stRingBuffer st) $ \RingPoint{..} -> do
630 rpPosition @<- d 635 rpPosition @<- d
631 rpColor @<- c 636 rpColor @<- c
diff --git a/hello_obj2.lc b/hello_obj2.lc
index 72a87ee..7b3d4a2 100644
--- a/hello_obj2.lc
+++ b/hello_obj2.lc
@@ -48,7 +48,12 @@ makeFrame (cubemap :: TextureCube)
48 `overlay` 48 `overlay`
49 points 49 points
50 & mapPrimitives (\(p,c) -> let p' = coordmap cam $ point p 50 & mapPrimitives (\(p,c) -> let p' = coordmap cam $ point p
51 in (p', point c)) 51 w = p'%w
52 yellowish = normalize c `dot` V3 1 1 0
53 p2 = if yellowish >= 0.9*sqrt 2
54 then V4 p'%x p'%y 0.1 w
55 else V4 p'%x p'%y 0.11 w
56 in (p2, point c))
52 57
53 & renderPoints cam 58 & renderPoints cam
54 59
@@ -61,7 +66,7 @@ renderPoints cam points =
61 points 66 points
62 & rasterizePrimitives (PointCtx (PointSize 5.0) 1.0 LowerLeft) ((Flat)) 67 & rasterizePrimitives (PointCtx (PointSize 5.0) 1.0 LowerLeft) ((Flat))
63 & mapFragments (\((c)) -> ((c))) 68 & mapFragments (\((c)) -> ((c)))
64 & accumulateWith (DepthOp Always False, ColorOp NoBlending (V4 True True True True)) 69 & accumulateWith (DepthOp Less True, ColorOp NoBlending (V4 True True True True))
65 70
66main :: Output 71main :: Output
67main = renderFrame $ 72main = renderFrame $