From 727b1c2ee98d395429ec1e667279fc3f5fec3a5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Manuel=20Tom=C3=A1s?= Date: Sun, 17 Jan 2021 17:51:07 -0300 Subject: Fix fragment shader bug on empty curves --- src/lerp.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/lerp.rs') diff --git a/src/lerp.rs b/src/lerp.rs index 222671f..1501d0f 100644 --- a/src/lerp.rs +++ b/src/lerp.rs @@ -4,6 +4,7 @@ use crate::poly::Poly; pub enum Lerp { Node(Box, Box), Leaf(Number, Number), + Just(Number) } impl Lerp { @@ -13,8 +14,8 @@ impl Lerp { fn new_s(v: &[Number]) -> Box { match v.len() { - 0 => Box::new(Lerp::Leaf(0.0, 0.0)), - 1 => Box::new(Lerp::Leaf(v[0], v[0])), + 0 => Box::new(Lerp::Just(0.0)), + 1 => Box::new(Lerp::Just(v[0])), 2 => Box::new(Lerp::Leaf(v[0], v[1])), _ => Box::new(Lerp::Node( Lerp::new_s(&v[0..v.len() - 1]), @@ -26,6 +27,7 @@ impl Lerp { pub fn lp(l: Box) -> Poly { match *l { + Lerp::Just(a) => Poly::new(vec![a]), Lerp::Leaf(a, b) => Poly::new(vec![a, b - a]), Lerp::Node(a, b) => { let a = lp(a); -- cgit v1.2.3