From 6d2d398c23586ca296353672611975cdcbc5c23a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=20Vald=C3=A9s?= Date: Wed, 26 Feb 2020 21:44:32 +0100 Subject: [PATCH] Fix cursor animation being stuck for 1 frame after animation reset --- src/renderer/cursor_renderer/cursor_vfx.rs | 2 +- src/renderer/cursor_renderer/mod.rs | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/renderer/cursor_renderer/cursor_vfx.rs b/src/renderer/cursor_renderer/cursor_vfx.rs index 1bd6752..32d72ab 100644 --- a/src/renderer/cursor_renderer/cursor_vfx.rs +++ b/src/renderer/cursor_renderer/cursor_vfx.rs @@ -225,7 +225,7 @@ impl CursorVfx for ParticleTrail { TrailMode::Torpedo => rng.rand_dir() * 10.0, TrailMode::PixieDust => { let base_dir = rng.rand_dir(); - let dir = Point::new(base_dir.x * 0.5, base_dir.y.abs()); + let dir = Point::new(base_dir.x * 0.5, 0.4 + base_dir.y.abs()); dir * 30.0 } }; diff --git a/src/renderer/cursor_renderer/mod.rs b/src/renderer/cursor_renderer/mod.rs index 4f25232..ac65b85 100644 --- a/src/renderer/cursor_renderer/mod.rs +++ b/src/renderer/cursor_renderer/mod.rs @@ -28,7 +28,7 @@ pub struct CursorSettings { pub fn initialize_settings() { SETTINGS.set(&CursorSettings { - animation_length: 0.1, + animation_length: 0.13, vfx_mode: cursor_vfx::VfxMode::Disabled, }); @@ -179,8 +179,6 @@ impl Corner { let direction_alignment = travel_direction.dot(corner_direction); - self.current_position = - ease_point(ease_out_expo, self.start_position, corner_destination, self.t); if self.t == 1.0 { // We are at destination, move t out of 0-1 range to stop the animation @@ -189,6 +187,9 @@ impl Corner { let corner_dt = dt * lerp(1.0, 1.0 - CURSOR_TRAIL_SIZE, -direction_alignment); self.t = (self.t + corner_dt / settings.animation_length).min(1.0) } + + self.current_position = + ease_point(ease_out_expo, self.start_position, corner_destination, self.t); true }