From 81930f35ebeb2567218b429a58ce5b560a0a175b Mon Sep 17 00:00:00 2001 From: Andre Henriques Date: Wed, 15 Mar 2023 23:03:51 +0000 Subject: [PATCH] update lerp functionn --- src/render.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/render.rs b/src/render.rs index 5f049bd..83ddeee 100644 --- a/src/render.rs +++ b/src/render.rs @@ -332,10 +332,17 @@ pub trait Lerp { impl Lerp for f64 { fn lerp(self, other: &Self, diff: f64) -> Self { let delta = diff; - let lerped = self + ((*other - self) * 0.5 * delta); + + let change = (*other - self) * 0.1 * delta; + + if change < 0.0000001 { + return *other; + } + + let lerped = self + change; if *other != self { - println!("c: {} target:{} lerp: {} diff: {} move: {}", self, other, lerped, diff, (*other - self) * 0.5); + println!("c: {} target:{} lerp: {} diff: {} move: {}", self, other, lerped, diff, change); } lerped