From c7da64cc641b67c84eee1a86effaaa2dd5774117 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Sun, 10 Sep 2023 14:03:29 -0700 Subject: [PATCH] i128 not necessary in this case and use glam --- src/body.rs | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/src/body.rs b/src/body.rs index c2a3b20..f80726e 100644 --- a/src/body.rs +++ b/src/body.rs @@ -58,18 +58,13 @@ impl MouseInterpolationState { match self.interpolation { MouseInterpolation::First => self.mouse0, MouseInterpolation::Lerp => { - //a 5 hour run uses 45 bits of TIME - //mouse positions may accumulate on a map where the player spins, especially for high dpi... - let x0=self.mouse0.x as i128; - let y0=self.mouse0.y as i128; - let x1=self.mouse1.x as i128; - let y1=self.mouse1.y as i128; - let t1t=(self.time1-time) as i128; - let tt0=(time-self.time0) as i128; - let dt=(self.time1-self.time0) as i128; - glam::ivec2( - ((x0*t1t+x1*tt0)/dt) as i32, - ((y0*t1t+y1*tt0)/dt) as i32) + let m0=self.mouse0.as_i64vec2(); + let m1=self.mouse1.as_i64vec2(); + //these are deltas + let t1t=(self.time1-time) as i64; + let tt0=(time-self.time0) as i64; + let dt=(self.time1-self.time0) as i64; + ((m0*t1t+m1*tt0)/dt).as_ivec2() } } }