From c286244e20a5c15a2e001b481016d1cb51c87d4a Mon Sep 17 00:00:00 2001 From: ghostly_zsh Date: Mon, 7 Jul 2025 11:59:22 -0500 Subject: [PATCH] more insanity --- crates/unified/src/particle_editor/mod.rs | 4 +++- crates/unified/src/particles.rs | 9 +++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/crates/unified/src/particle_editor/mod.rs b/crates/unified/src/particle_editor/mod.rs index 5f543081769296dba44242cccd6f529ed68a0a44..f1b75f75224725144316910d9b01584cdfa49dc4 100644 --- a/crates/unified/src/particle_editor/mod.rs +++ b/crates/unified/src/particle_editor/mod.rs @@ -34,7 +34,9 @@ pub fn particle_editor_plugin(app: &mut App) { }); } -fn setup_editor_effect(mut commands: Commands) { +fn setup_editor_effect( + mut commands: Commands, +) { commands.spawn(( ParticleEffect { lifetime_seconds: RandF32 { diff --git a/crates/unified/src/particles.rs b/crates/unified/src/particles.rs index 7353c9a9b223136e3b4454e8cd09832cc47d310e..cc461a19d810ee80aeaaa38f5661884cb24b5bd5 100644 --- a/crates/unified/src/particles.rs +++ b/crates/unified/src/particles.rs @@ -1,7 +1,6 @@ use std::collections::BTreeMap; use std::ops::Bound::{Included, Unbounded}; use bevy::color::{Color, LinearRgba}; -use bevy::math::cubic_splines::LinearSpline; use bevy::math::Vec2; use bevy::prelude::Component; use ordered_float::{FloatCore, OrderedFloat}; @@ -64,9 +63,11 @@ impl LifetimeCurve

{ Some(a_val.lerp(b_val, t)) } - pub fn clamp_time(&self, time: f32) -> Option { - let Some(first) = self.0.iter().nth(0) else { return None }; - let Some(last) = self.0.iter().last() else { return None }; + /// Given an input time value, use the ends of the spline's time to clamp + /// the input value. + pub fn clamp_time(&self, time: f32) -> Option { + let Some(first) = self.0.iter().nth(0) else { return None; }; + let Some(last) = self.0.iter().last() else { return None; }; Some(time.clamp(first.0.0, last.0.0)) }