From b82db76553932911b5b37a9d3f4ab8a18e06fb38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=20Vald=C3=A9s?= Date: Sat, 29 Feb 2020 21:08:11 +0100 Subject: [PATCH] Expose speed and phase parameters for particles --- src/renderer/cursor_renderer/cursor_vfx.rs | 16 +++++++++------- src/renderer/cursor_renderer/mod.rs | 7 ++++++- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/renderer/cursor_renderer/cursor_vfx.rs b/src/renderer/cursor_renderer/cursor_vfx.rs index fc8f47a..747d70d 100644 --- a/src/renderer/cursor_renderer/cursor_vfx.rs +++ b/src/renderer/cursor_renderer/cursor_vfx.rs @@ -249,22 +249,24 @@ impl CursorVfx for ParticleTrail { let speed = match self.trail_mode { TrailMode::Railgun => { - let phase = t * 60.0; // TODO -- Hardcoded spiral curl - Point::new(phase.sin(), phase.cos()) * 20.0 // TODO -- Hardcoded spiral outward speed + let phase = t / 3.141592 * settings.vfx_particle_phase * (travel_distance / font_size.0); + Point::new(phase.sin(), phase.cos()) * 2.0 * settings.vfx_particle_speed } TrailMode::Torpedo => { - self.rng.rand_dir_normalized() * 10.0 // TODO -- Hardcoded particle speed + let mut travel_dir = travel; + travel_dir.normalize(); + let mut particle_dir = self.rng.rand_dir_normalized() - travel_dir * 1.5; + particle_dir.normalize(); + particle_dir * settings.vfx_particle_speed } TrailMode::PixieDust => { let base_dir = self.rng.rand_dir_normalized(); let dir = Point::new(base_dir.x * 0.5, 0.4 + base_dir.y.abs()); - dir * 30.0 // TODO -- hardcoded particle speed + dir * 3.0 * settings.vfx_particle_speed } }; - // Distribute particles along the travel distance, with a random offset to make it - // look random - + // Distribute particles along the travel distance let pos = match self.trail_mode { TrailMode::Railgun => prev_p + travel * t, TrailMode::PixieDust | TrailMode::Torpedo => { diff --git a/src/renderer/cursor_renderer/mod.rs b/src/renderer/cursor_renderer/mod.rs index 78b81e2..e39b3ff 100644 --- a/src/renderer/cursor_renderer/mod.rs +++ b/src/renderer/cursor_renderer/mod.rs @@ -27,7 +27,8 @@ pub struct CursorSettings { vfx_opacity: f32, vfx_particle_lifetime: f32, vfx_particle_density: f32, -} + vfx_particle_speed: f32, + vfx_particle_phase: f32, } pub fn initialize_settings() { @@ -38,6 +39,8 @@ pub fn initialize_settings() { vfx_opacity: 200.0, vfx_particle_lifetime: 1.2, vfx_particle_density: 7.0, + vfx_particle_speed: 10.0, + vfx_particle_phase: 1.5, }); register_nvim_setting!("cursor_animation_length", CursorSettings::animation_length); @@ -46,6 +49,8 @@ pub fn initialize_settings() { register_nvim_setting!("cursor_vfx_opacity", CursorSettings::vfx_opacity); register_nvim_setting!("cursor_vfx_particle_lifetime", CursorSettings::vfx_particle_lifetime); register_nvim_setting!("cursor_vfx_particle_density", CursorSettings::vfx_particle_density); + register_nvim_setting!("cursor_vfx_particle_speed", CursorSettings::vfx_particle_speed); + register_nvim_setting!("cursor_vfx_particle_phase", CursorSettings::vfx_particle_phase); } // ----------------------------------------------------------------------------