EffectCraft: An open-source motion graphics and compositing tool written by scratch in pure Rust
Refactor effects for strict Clippy checks
Dylan M. Taylord01871516a41
diff --git a/crates/effects/src/generate2.rs b/crates/effects/src/generate2.rsindex 62bce1706..b4781b793 100644--- a/crates/effects/src/generate2.rs+++ b/crates/effects/src/generate2.rs@@ -692,18 +692,33 @@ impl BoltCfg<'_> {}}-/// Grow a bolt from `a` to `z` by midpoint displacement (`depth` levels), forking at random.-/// Segments go to `out` with their intensity; `mains` marks the main core's segments.-#[allow(clippy::too_many_arguments)]-fn bolt(cfg: &BoltCfg, a: (f64, f64), z: (f64, f64), depth: u32, inten: f32, main: bool, rng: &mut Rng, out: &mut Vec<Seg>, mains: &mut Vec<bool>) {- if out.len() > 20_000 {+/// One branch's geometry and recursive growth state.+struct BoltBranch {+ start: (f64, f64),+ end: (f64, f64),+ depth: u32,+ intensity: f32,+ main: bool,+}++/// Segments and their matching main-core flags, kept in the same traversal order.+#[derive(Default)]+struct BoltOutput {+ segments: Vec<Seg>,+ mains: Vec<bool>,+}++/// Grow a branch by midpoint displacement, recursively appending its segments and forks.+fn bolt(cfg: &BoltCfg, branch: BoltBranch, rng: &mut Rng, output: &mut BoltOutput) {+ let BoltBranch { start: a, end: z, depth, intensity: inten, main } = branch;+ if output.segments.len() > 20_000 {return;}let (dx, dy) = (z.0 - a.0, z.1 - a.1);let len = (dx * dx + dy * dy).sqrt();if depth == 0 || len < 1.0 {- out.push((a, z, inten));- mains.push(main);+ output.segments.push((a, z, inten));+ output.mains.push(main);return;}let (nx, ny) = (-dy / len.max(1e-9), dx / len.max(1e-9));@@ -725,8 +740,8 @@ fn bolt(cfg: &BoltCfg, a: (f64, f64), z: (f64, f64), depth: u32, inten: f32, maiif cfg.obstacle > 0.0 && !main && cfg.alpha_at(m) > 0.5 && rng.f() < cfg.obstacle / 10.0 {return;}- bolt(cfg, a, m, depth - 1, inten, main, rng, out, mains);- bolt(cfg, m, z, depth - 1, inten, main, rng, out, mains);+ bolt(cfg, BoltBranch { start: a, end: m, depth: depth - 1, intensity: inten, main }, rng, output);+ bolt(cfg, BoltBranch { start: m, end: z, depth: depth - 1, intensity: inten, main }, rng, output);if rng.f() < cfg.fork && inten > cfg.term && len >= cfg.min_fork {let ang = rng.s() * 0.7;let (s, c) = ang.sin_cos();@@ -734,7 +749,7 @@ fn bolt(cfg: &BoltCfg, a: (f64, f64), z: (f64, f64), depth: u32, inten: f32, mailet k = 1.2;// Fork Strength 50 % keeps the decayed intensity; Fork Variation randomises it.let fi = inten * (1.0 - cfg.decay) * cfg.fork_strength * 2.0 * if cfg.fork_var > 0.0 { 1.0 - cfg.fork_var * rng.f() as f32 } else { 1.0 };- bolt(cfg, m, (m.0 + fx * k, m.1 + fy * k), depth.saturating_sub(1), fi.min(1.0), false, rng, out, mains);+ bolt(cfg, BoltBranch { start: m, end: (m.0 + fx * k, m.1 + fy * k), depth: depth.saturating_sub(1), intensity: fi.min(1.0), main: false }, rng, output);}}@@ -772,10 +787,9 @@ pub fn lightning_segments(ctx: &EffectCtx, b: &Buf) -> Vec<Seg> {fork_strength: (g("expertSettings/forkStrength", 50.0) / 100.0).clamp(0.0, 1.0) as f32,fork_var: (g("expertSettings/forkVariation", 0.0) / 100.0).clamp(0.0, 1.0) as f32,};- let mut segs = Vec::new();- let mut mains = Vec::new();+ let mut output = BoltOutput::default();let (h, w) = (b.img.height as f64, b.img.width as f64);- let mut go = |a, z, depth, cfg: &BoltCfg, rng: &mut Rng| bolt(cfg, a, z, depth, 1.0, true, rng, &mut segs, &mut mains);+ let mut go = |a, z, depth, cfg: &BoltCfg, rng: &mut Rng| bolt(cfg, BoltBranch { start: a, end: z, depth, intensity: 1.0, main: true }, rng, &mut output);// LIGHTNING_TYPES order.match kind {// Direction: travels toward the Direction point and beyond.@@ -811,6 +825,7 @@ pub fn lightning_segments(ctx: &EffectCtx, b: &Buf) -> Vec<Seg> {// Strike._ => go(o, d, depth, &cfg, &mut rng),}+ let BoltOutput { segments: mut segs, mains } = output;let dist = |p: (f64, f64)| ((p.0 - o.0).powi(2) + (p.1 - o.1).powi(2)).sqrt();let far = segs.iter().map(|(_, z, _)| dist(*z)).fold(1e-9, f64::max);// Decay Main Core: the whole bolt fades with distance from the origin.diff --git a/crates/effects/src/generate3/audio.rs b/crates/effects/src/generate3/audio.rsindex f1ac54db8..6c8d66e4a 100644--- a/crates/effects/src/generate3/audio.rs+++ b/crates/effects/src/generate3/audio.rs@@ -1,5 +1,5 @@use super::raster::{Seg, mask_px, over, poly_segs, raster_segs};-use super::*;+use super::{Buf, EffectCtx, IndexedParallelIterator, IntoParallelRefMutIterator, PI, ParallelIterator, poly_length, premul};// ---------------------------------------------------------------- Audio Spectrum / Waveformdiff --git a/crates/effects/src/generate3/common.rs b/crates/effects/src/generate3/common.rsindex b996cdc99..7e341ad8d 100644--- a/crates/effects/src/generate3/common.rs+++ b/crates/effects/src/generate3/common.rs@@ -1,4 +1,4 @@-use super::*;+use super::{EffectSpec, ParamUi, Value, slider};pub(super) fn spec(id: &'static str, name: &'static str, params: Vec<crate::ParamSpec>, render: crate::RenderFn) -> EffectSpec {EffectSpec { id, name, category: "Generate", params, render, gpu: false, float: true }diff --git a/crates/effects/src/generate3/fill.rs b/crates/effects/src/generate3/fill.rsindex a86f123ee..5df782a89 100644--- a/crates/effects/src/generate3/fill.rs+++ b/crates/effects/src/generate3/fill.rs@@ -1,5 +1,8 @@use super::raster::over;-use super::*;+use super::{+ Buf, EffectCtx, IndexedParallelIterator, IntoParallelRefIterator, IntoParallelRefMutIterator, PI, ParallelIterator, Plane, Px, gauss_plane, hash1,+ hsl_to_rgb, morph_frac, premul, rgb_to_hsl, smoothstep, unpremul,+};pub(super) fn glue_gun(ctx: &EffectCtx, mut b: Buf) -> Buf {let pr = ctx.params;diff --git a/crates/effects/src/generate3/fractal.rs b/crates/effects/src/generate3/fractal.rsindex 519bec640..05a76d5f0 100644--- a/crates/effects/src/generate3/fractal.rs+++ b/crates/effects/src/generate3/fractal.rs@@ -1,5 +1,5 @@use super::raster::over;-use super::*;+use super::{Buf, EffectCtx, IndexedParallelIterator, ParallelIterator, ParallelSliceMut, Px, hsl_to_rgb};// ---------------------------------------------------------------- Fractaldiff --git a/crates/effects/src/generate3/paths.rs b/crates/effects/src/generate3/paths.rsindex 779892cc7..319368a82 100644--- a/crates/effects/src/generate3/paths.rs+++ b/crates/effects/src/generate3/paths.rs@@ -1,5 +1,8 @@use super::raster::{Seg, all_masks_px, chaikin, mask_px, over, poly_segs, raster_convex, raster_segs, scan_runs, stroke_outline, trim_poly};-use super::*;+use super::{+ Buf, EffectCtx, Image, IndexedParallelIterator, IntoParallelRefIterator, IntoParallelRefMutIterator, ParallelIterator, Params, Plane, gauss_plane, hash1,+ layer_or_self, luminance, poly_length, smoothstep, unpremul,+};/// How painted coverage meets the layer: 0 On Original Image, 1 On Transparent, 2 Reveal/// Original Image.diff --git a/crates/effects/src/generate3/raster.rs b/crates/effects/src/generate3/raster.rsindex f9acd88a3..1b85818d0 100644--- a/crates/effects/src/generate3/raster.rs+++ b/crates/effects/src/generate3/raster.rs@@ -1,4 +1,4 @@-use super::*;+use super::{Buf, EffectCtx, IndexedParallelIterator, ParallelIterator, ParallelSliceMut, Plane, Px, smoothstep};// ---------------------------------------------------------------- shared rasterisation@@ -147,7 +147,6 @@ pub(super) fn chaikin(pts: &[[f64; 2]], iters: usize) -> Vec<[f64; 2]> {// ---------------------------------------------------------------- Scribble/// Scan runs (start, end along direction `d`) of the fill region on the line `n·p = s`.-#[allow(clippy::too_many_arguments)]pub(super) fn scan_runs(polys: &[(Vec<[f64; 2]>, bool, bool)], fill: u32, ew: f64, d: [f64; 2], n: [f64; 2], s: f64, out: &mut Vec<(f64, f64)>) {out.clear();for (pts, _closed, inverted) in polys {diff --git a/crates/effects/src/generate3/registry.rs b/crates/effects/src/generate3/registry.rsindex f7f6b040f..06c2b35fb 100644--- a/crates/effects/src/generate3/registry.rs+++ b/crates/effects/src/generate3/registry.rs@@ -4,7 +4,7 @@ use super::fill::{eyedropper_fill, glue_gun, paint_bucket, threads};use super::fractal::{FRACTAL_OVERSAMPLE, FRACTAL_PALETTES, FRACTAL_SETS, fractal};use super::paths::{scribble, stroke, vegas, write_on};use super::raster::{END_CAPS, JOINS};-use super::*;+use super::{EffectSpec, ParamUi, Value, col, num, p, popup, slider};// ---------------------------------------------------------------- registrydiff --git a/crates/effects/src/object_matte.rs b/crates/effects/src/object_matte.rsindex d98ec73ad..e61357c9f 100644--- a/crates/effects/src/object_matte.rs+++ b/crates/effects/src/object_matte.rs@@ -358,20 +358,24 @@ pub enum FrameMatte {Outside,}-/// The matte of layer frame `f` on the layer grid of `img` (the effect's input on that frame at-/// `scale`), computing what is missing. `frame(g)`: the input on frame g on the same grid.-#[allow(clippy::too_many_arguments)]+/// The layer grid and timing used to compute one object matte.+pub struct MatteFrame<'a> {+ pub layer_size: [f64; 2],+ pub fps: f64,+ pub frame: i64,+ pub scale: f64,+ pub img: &'a Image,+}++/// Compute the object's alpha for one layer frame, loading other frames on the same grid as needed.pub fn frame_matte(params: &Params,- layer_size: [f64; 2],- fps: f64,- f: i64,- scale: f64,- img: &Image,+ input: &MatteFrame<'_>,model: Option<Arc<dyn MaskModel>>,frame: &mut dyn FnMut(i64) -> Option<Arc<Image>>,cancel: &dyn Fn() -> bool,) -> FrameMatte {+ let MatteFrame { layer_size, fps, frame: f, scale, img } = *input;let Some(chain) = chain(params, layer_size, fps, f, scale, model) else { return FrameMatte::NoPrompt };if !chain.data.in_span(f) {return FrameMatte::Outside;@@ -408,7 +412,7 @@ fn render(ctx: &EffectCtx, buf: Buf) -> Buf {if let Some(a) = frozen_alpha(ctx.params, layer_size, fps, f, w, h, model.as_deref()) {return compose(&buf, Some(&a), w, h, b(ctx.params, "invert"), param(ctx.params, "view").map(Value::as_enum).unwrap_or(0) == 1);}- let alpha = match frame_matte(ctx.params, layer_size, fps, f, sc, &img, model, &mut frame, &|| false) {+ let alpha = match frame_matte(ctx.params, &MatteFrame { layer_size, fps, frame: f, scale: sc, img: &img }, model, &mut frame, &|| false) {FrameMatte::Alpha(a) if a.len() == w * h => Some(a),FrameMatte::NoPrompt => return buf,_ => None,@@ -608,7 +612,11 @@ mod tests {assert_ne!(seed(&p, [100.0, 80.0], 25.0, Some(stub.as_ref())), seed(&p, [100.0, 80.0], 25.0, None));let img = frame_at(0);let mut frame = |g: i64| Some(Arc::new(frame_at(g)));- let FrameMatte::Alpha(a) = frame_matte(&p, [100.0, 80.0], 25.0, 0, 1.0, &img, Some(stub.clone()), &mut frame, &|| false) else { panic!("no matte") };+ let FrameMatte::Alpha(a) =+ frame_matte(&p, &MatteFrame { layer_size: [100.0, 80.0], fps: 25.0, frame: 0, scale: 1.0, img: &img }, Some(stub.clone()), &mut frame, &|| false)+ else {+ panic!("no matte")+ };assert!(a[40 * 100 + 40] > 0.5 && a[5 * 100 + 5] < 0.5);assert_eq!(stub.calls.load(std::sync::atomic::Ordering::Relaxed), 1);assert_eq!(*stub.bbox.lock().unwrap(), None);@@ -634,7 +642,11 @@ mod tests {let stub = Arc::new(Stub::default());let img = frame_at(0);let mut frame = |g: i64| Some(Arc::new(frame_at(g)));- let FrameMatte::Alpha(a) = frame_matte(&p, [100.0, 80.0], 25.0, 0, 1.0, &img, Some(stub.clone()), &mut frame, &|| false) else { panic!("no matte") };+ let FrameMatte::Alpha(a) =+ frame_matte(&p, &MatteFrame { layer_size: [100.0, 80.0], fps: 25.0, frame: 0, scale: 1.0, img: &img }, Some(stub.clone()), &mut frame, &|| false)+ else {+ panic!("no matte")+ };assert_eq!(*stub.bbox.lock().unwrap(), Some([74.0, 54.0, 100.0, 80.0]));assert!(a[70 * 100 + 90] > 0.5 && a[40 * 100 + 40] < 0.5);// At half resolution the box is scaled with the frame (another Input Key, so the@@ -643,7 +655,8 @@ mod tests {p.values.insert(INPUT_KEY.into(), Value::Str("half".into()));let half = effectcraft_raster::resample(&img, 50, 40);let mut frame = |g: i64| Some(Arc::new(effectcraft_raster::resample(&frame_at(g), 50, 40)));- let _ = frame_matte(&p, [100.0, 80.0], 25.0, 0, 0.5, &half, Some(stub.clone()), &mut frame, &|| false);+ let _ =+ frame_matte(&p, &MatteFrame { layer_size: [100.0, 80.0], fps: 25.0, frame: 0, scale: 0.5, img: &half }, Some(stub.clone()), &mut frame, &|| false);assert_eq!(*stub.bbox.lock().unwrap(), Some([37.0, 27.0, 50.0, 40.0]));}diff --git a/crates/effects/src/ocio/cdl.rs b/crates/effects/src/ocio/cdl.rsindex 1feab04a2..dba8c68fe 100644--- a/crates/effects/src/ocio/cdl.rs+++ b/crates/effects/src/ocio/cdl.rs@@ -1,4 +1,4 @@-use super::*;+use super::{ParamUi, slider};// ---------------------------------------------------------------- ASC CDLdiff --git a/crates/effects/src/ocio/effects.rs b/crates/effects/src/ocio/effects.rsindex 7d07011a4..5df24096d 100644--- a/crates/effects/src/ocio/effects.rs+++ b/crates/effects/src/ocio/effects.rs@@ -1,7 +1,7 @@use super::cdl::Cdl;use super::lut::load_file;use super::space::{ACES_CCT, ACES_CG, ACES2065_1, D65, IDENTITY, P3, REC709, REC2020, SPACES, Space, Tf, Xform, matrix, sp, space_names};-use super::*;+use super::{Buf, ColorSpace, EffectCtx, EffectSpec, IntoParallelRefMutIterator, ParallelIterator, Value, invert, mul, mul_vec, p, popup, unpremul};// ---------------------------------------------------------------- displays, views and looksdiff --git a/crates/effects/src/ocio/lut.rs b/crates/effects/src/ocio/lut.rsindex ff4cbd935..8a6481eb6 100644--- a/crates/effects/src/ocio/lut.rs+++ b/crates/effects/src/ocio/lut.rs@@ -1,5 +1,5 @@use super::cdl::{Cdl, parse_cdl_xml};-use super::*;+use super::{Arc, HashMap, Lut, Mutex, OnceLock, parse_cube};// ---------------------------------------------------------------- LUT filesdiff --git a/crates/effects/src/ocio/program.rs b/crates/effects/src/ocio/program.rsindex ab9c4ea78..a223dc7b4 100644--- a/crates/effects/src/ocio/program.rs+++ b/crates/effects/src/ocio/program.rs@@ -2,7 +2,7 @@ use super::cdl::Cdl;use super::effects::{DISPLAYS, cdl_from_params, custom_xf, looks, parse_looks, profile, space_at};use super::lut::{FileXform, load_file};use super::space::{ACES_CCT, D65, IDENTITY, Space, Tf, Xform, matrix};-use super::*;+use super::{Arc, EffectCtx, Lut, invert, mul};// ---- Colour programs (the GPU compositor's colour-management kernels)diff --git a/crates/effects/src/ocio/registry.rs b/crates/effects/src/ocio/registry.rsindex b020b053b..cd3bd02a7 100644--- a/crates/effects/src/ocio/registry.rs+++ b/crates/effects/src/ocio/registry.rs@@ -4,7 +4,7 @@ use super::effects::{space_param, spec,};use super::space::SPACES;-use super::*;+use super::{EffectSpec, ParamUi, Value, num, p, popup, slider};pub fn specs() -> Vec<EffectSpec> {let cc = "Color Correction";diff --git a/crates/effects/src/ocio/space.rs b/crates/effects/src/ocio/space.rsindex 44fcf84d0..1a1d8f69b 100644--- a/crates/effects/src/ocio/space.rs+++ b/crates/effects/src/ocio/space.rs@@ -1,4 +1,4 @@-use super::*;+use super::{invert, mul, mul_vec, rgb_to_xyz};pub(super) type M3 = [[f64; 3]; 3];diff --git a/crates/effects/src/roto.rs b/crates/effects/src/roto.rsindex 4917cc231..2467a719d 100644--- a/crates/effects/src/roto.rs+++ b/crates/effects/src/roto.rs@@ -634,7 +634,7 @@ fn render(ctx: &EffectCtx, buf: Buf) -> Buf {let (w, h) = (img.width as usize, img.height as usize);let mp = matte_params(ctx.params);let mut rgb = rb::rgb_of(&img);- let map = refine::decontaminate(&mut rgb, &alpha, &band, w, h, &mp, rr * sc, sc);+ let map = refine::decontaminate(&mut rgb, &alpha, &band, (w, h), &mp, rr * sc, sc);let view_map = b(ctx.params, "refineEdgeMatte/decontamination/viewDecontaminationMap");let (ox, oy) = (buf.offset[0].round() as i64, buf.offset[1].round() as i64);for y in 0..h {diff --git a/crates/effects/src/sim/common.rs b/crates/effects/src/sim/common.rsindex c11c3f886..294d787f1 100644--- a/crates/effects/src/sim/common.rs+++ b/crates/effects/src/sim/common.rs@@ -1,4 +1,4 @@-use super::*;+use super::{EffectSpec, ParamUi, Value, hash1, slider};pub(crate) fn spec(id: &'static str, name: &'static str, params: Vec<crate::ParamSpec>, render: crate::RenderFn) -> EffectSpec {EffectSpec { id, name, category: "Simulation", params, render, gpu: false, float: true }diff --git a/crates/effects/src/sim/engine.rs b/crates/effects/src/sim/engine.rsindex 973b7b5e8..b379636ce 100644--- a/crates/effects/src/sim/engine.rs+++ b/crates/effects/src/sim/engine.rs@@ -1,7 +1,7 @@use super::common::{h, hs};use super::particle_fx::{PS2_CACHE, PW_CACHE, ps2_phys, pw_phys};use super::sprites::{Shape, Sprite};-use super::*;+use super::{Buf, EffectCtx, Image, IntoParallelRefMutIterator, ParallelIterator, SimCache, params_key_except, value_noise};// ------------------------------------------------------------------ particle engine@@ -263,7 +263,8 @@ pub(super) fn particle_look(q: &Particle, birth: [f32; 4], death: [f32; 4], bsiz(c, size.max(0.0))}-pub(super) fn type_sprite(kind: u32, x: f32, y: f32, r: f32, c: [f32; 4], vx: f32, vy: f32, rot: f32) -> Sprite {+pub(super) fn type_sprite(kind: u32, x: f32, y: f32, r: f32, c: [f32; 4], velocity: [f32; 2], rot: f32) -> Sprite {+ let [vx, vy] = velocity;let vl = (vx * vx + vy * vy).sqrt().max(1e-6);let shape = match kind {0 => Shape::Line { dx: -vx / vl * r * 2.0, dy: -vy / vl * r * 2.0 },diff --git a/crates/effects/src/sim/particle_fx.rs b/crates/effects/src/sim/particle_fx.rsindex f8af6cba0..6b6c27b01 100644--- a/crates/effects/src/sim/particle_fx.rs+++ b/crates/effects/src/sim/particle_fx.rs@@ -1,6 +1,6 @@use super::engine::{PState, PW_EFFECT_CAMERA, Phys, accelerated, norm3, particle_look, sim_key, simulate, type_sprite};use super::sprites::{Acc, Post, Sprite, SpritePlan, raster, splat};-use super::*;+use super::{Buf, EffectCtx, Image, IntoParallelRefIterator, ParallelIterator, SimCache, Value, params_key, unpremul};// ------------------------------------------------------------------ CC Particle World@@ -169,7 +169,7 @@ pub(super) fn particle_world_plan(ctx: &EffectCtx, b: &Buf) -> Option<SpritePlanlet PwSeen { depth, x, y, k, v } = cam.see(q.p, q.v, lw, lh, b)?;let (c, size) = particle_look(q, birth, death, bs, ds, svar, max_op);let r = size * 0.5 * lw * k * s * 0.25;- let sp = type_sprite(kind, x, y, r, c, v[0] * lw * k * s, v[1] * lw * k * s, (q.id % 628) as f32 * 0.01 + q.age * 2.0);+ let sp = type_sprite(kind, x, y, r, c, [v[0] * lw * k * s, v[1] * lw * k * s], (q.id % 628) as f32 * 0.01 + q.age * 2.0);Some((depth, sp))}).collect();@@ -242,7 +242,7 @@ pub(super) fn particle_systems2_plan(ctx: &EffectCtx, b: &Buf) -> SpritePlan {let (bx, by) = b.to_px([(q.p[0] * unit) as f64, (q.p[1] * unit) as f64]);let (c, size) = particle_look(q, birth, death, bs, ds, svar, max_op);let r = size * unit * 0.02 * s;- type_sprite(kind, bx as f32, by as f32, r, c, q.v[0] * unit * s, q.v[1] * unit * s, (q.id % 628) as f32 * 0.01 + q.age * 2.0)+ type_sprite(kind, bx as f32, by as f32, r, c, [q.v[0] * unit * s, q.v[1] * unit * s], (q.id % 628) as f32 * 0.01 + q.age * 2.0)}).collect();particle_sprites(sprites, pr.e("particle/transferMode"))diff --git a/crates/effects/src/sim/registry.rs b/crates/effects/src/sim/registry.rsindex a688f1046..f29eb2653 100644--- a/crates/effects/src/sim/registry.rs+++ b/crates/effects/src/sim/registry.rs@@ -3,7 +3,7 @@ use super::engine::{PARTICLE_TYPES, PW_ANIMS};use super::particle_fx::{PW_FOV, mr_mercury, particle_systems2, particle_systems2_plan, particle_world, particle_world_plan};use super::sprites::SpritePlan;use super::weather::{bubbles, drizzle, rainfall, rainfall_plan, snowfall, snowfall_plan, star_burst, star_burst_plan};-use super::*;+use super::{Buf, EffectCtx, EffectSpec, ParamUi, Value, col, num, p, popup, slider};/// The sprite plan of a sprite-drawing simulation effect for buffer geometry `b` (its pixels/// are not read), `None` for other effects or settings drawn otherwise (the GPU compositor'sdiff --git a/crates/effects/src/sim/sprites.rs b/crates/effects/src/sim/sprites.rsindex 982579a5c..78c405abd 100644--- a/crates/effects/src/sim/sprites.rs+++ b/crates/effects/src/sim/sprites.rs@@ -1,4 +1,4 @@-use super::*;+use super::{Buf, Image, IndexedParallelIterator, IntoParallelRefIterator, IntoParallelRefMutIterator, ParallelIterator, ParallelSliceMut, Px, unpremul};// ------------------------------------------------------------------ band rasteriserdiff --git a/crates/effects/src/sim/weather.rs b/crates/effects/src/sim/weather.rsindex cac0b023c..b93c0e48b 100644--- a/crates/effects/src/sim/weather.rs+++ b/crates/effects/src/sim/weather.rs@@ -1,6 +1,6 @@use super::common::{h, hs};use super::sprites::{Acc, Post, Shape, Sprite, SpritePlan, Tint, aa, raster};-use super::*;+use super::{Buf, EffectCtx, Image, IntoParallelIterator, ParallelIterator, unpremul};// ------------------------------------------------------------------ CC Rainfall / CC Snowfalldiff --git a/crates/effects/src/sim2/foam.rs b/crates/effects/src/sim2/foam.rsindex cf9009492..fc187d191 100644--- a/crates/effects/src/sim2/foam.rs+++ b/crates/effects/src/sim2/foam.rs@@ -1,4 +1,7 @@-use super::*;+use super::{+ Acc, Buf, EffectCtx, Image, IndexedParallelIterator, IntoParallelRefIterator, IntoParallelRefMutIterator, ParallelIterator, Plane, Px, Shape, SimCache,+ Sprite, Value, hs, params_key, splat, unpremul, value_noise,+};// ------------------------------------------------------------------ Foamdiff --git a/crates/effects/src/sim2/pieces.rs b/crates/effects/src/sim2/pieces.rsindex 3aa3a68f6..bff5943c0 100644--- a/crates/effects/src/sim2/pieces.rs+++ b/crates/effects/src/sim2/pieces.rs@@ -1,5 +1,5 @@use super::shatter::{ShatterPlan, card_dance_plan, shatter_impl};-use super::*;+use super::{Acc, Buf, EffectCtx, Image, Lighting, Proj, raster, unpremul};// ------------------------------------------------------------------ 3D piecesdiff --git a/crates/effects/src/sim2/pixels.rs b/crates/effects/src/sim2/pixels.rsindex 2079f03c3..2cda428db 100644--- a/crates/effects/src/sim2/pixels.rs+++ b/crates/effects/src/sim2/pixels.rs@@ -1,6 +1,6 @@use super::pieces::{Cam, Piece, PiecePlan, PieceTex, rot_axis, sort_far_first};use super::shatter::{ShatterPlan, shatter_impl};-use super::*;+use super::{Acc, Buf, EffectCtx, IntoParallelIterator, ParallelIterator, Post, Shape, Sprite, SpritePlan, h, hs, unpremul};// ------------------------------------------------------------------ CC Ball Actiondiff --git a/crates/effects/src/sim2/registry.rs b/crates/effects/src/sim2/registry.rsindex 93508e7b5..333916a16 100644--- a/crates/effects/src/sim2/registry.rs+++ b/crates/effects/src/sim2/registry.rs@@ -2,7 +2,7 @@ use super::foam::{FOAM_TEXTURES, foam};use super::pixels::{ball_action, pixel_polly, scatterize};use super::shatter::{CD_PROPS, CD_SOURCES, SHATTER_PATTERNS, SHATTER_TEXTURE_MODES, card_dance, shatter};use super::surfaces::{caustics, wave_world};-use super::*;+use super::{EffectSpec, ParamUi, Value, col, num, p, pct, popup, pt, slider, spec};// ------------------------------------------------------------------ specsdiff --git a/crates/effects/src/sim2/shatter.rs b/crates/effects/src/sim2/shatter.rsindex 90b5163f1..844fbb4b3 100644--- a/crates/effects/src/sim2/shatter.rs+++ b/crates/effects/src/sim2/shatter.rs@@ -1,5 +1,8 @@use super::pieces::{M3, Piece, PiecePlan, PieceTex, inv3, rot_axis, rot_xyz, sort_far_first};-use super::*;+use super::{+ Acc, Buf, EffectCtx, Image, IndexedParallelIterator, IntoParallelIterator, IntoParallelRefIterator, Lighting, ParallelIterator, Post, Shape, Sprite,+ SpritePlan, Value, h, hs, layer_or_self, unpremul,+};// ------------------------------------------------------------------ Card Dancediff --git a/crates/effects/src/sim2/surfaces.rs b/crates/effects/src/sim2/surfaces.rsindex 0bcc639c4..7c3c032f0 100644--- a/crates/effects/src/sim2/surfaces.rs+++ b/crates/effects/src/sim2/surfaces.rs@@ -1,4 +1,4 @@-use super::*;+use super::{Acc, Buf, EffectCtx, Image, IntoParallelIterator, ParallelIterator, Plane, Px, Shape, SimCache, Sprite, Value, gauss_plane, params_key, unpremul};// ------------------------------------------------------------------ Causticsdiff --git a/crates/effects/src/sim3.rs b/crates/effects/src/sim3.rsindex 688b45950..88a16d981 100644--- a/crates/effects/src/sim3.rs+++ b/crates/effects/src/sim3.rs@@ -575,7 +575,8 @@ fn mapper_from(ctx: &EffectCtx, group: &str, ephemeral: bool) -> Option<Mapper>/// Draw a map layer frame as a particle: centred on (x, y) buffer px, rotated `angle` degrees/// and scaled, over `out`.-fn blit_layer(out: &mut Image, lp: &crate::LayerPixels, x: f64, y: f64, angle: f64, scale: [f64; 2], buf_scale: f64, alpha: f32) {+fn blit_layer(out: &mut Image, lp: &crate::LayerPixels, position: [f64; 2], angle: f64, scale: [f64; 2], buf_scale: f64, alpha: f32) {+ let [x, y] = position;let (w, h) = (lp.size[0] * scale[0].abs() * buf_scale, lp.size[1] * scale[1].abs() * buf_scale);let r = (w * w + h * h).sqrt() * 0.5 + 1.0;let (x0, x1) = ((x - r).floor().max(0.0) as i64, (x + r).ceil().min(out.width as f64) as i64);@@ -925,7 +926,7 @@ impl PgPlan {pub fn finish(&self, mut b: Buf) -> Buf {let mut fx = splat(b.img.width, b.img.height, &self.sprites.sprites, self.sprites.acc);for q in &self.blits {- blit_layer(&mut fx, &self.frames[q.frame], q.x, q.y, q.angle, q.scale, b.scale, q.alpha);+ blit_layer(&mut fx, &self.frames[q.frame], [q.x, q.y], q.angle, q.scale, b.scale, q.alpha);}// Particles replace the layer's own pixels.b.img = combine(&b.img, &fx, 5);diff --git a/crates/effects/src/warp_stab.rs b/crates/effects/src/warp_stab.rsindex f850bdcf3..226654a04 100644--- a/crates/effects/src/warp_stab.rs+++ b/crates/effects/src/warp_stab.rs@@ -453,7 +453,7 @@ fn render(ctx: &EffectCtx, buf: Buf) -> Buf {});let need = need_m.into_inner().unwrap_or_else(std::sync::PoisonError::into_inner);if synth && need.iter().any(|w| *w > 0.0) {- synthesize(ctx, &a, k, &src_of, &crop, sc, &mut out, &need);+ synthesize(ctx, &a, k, &SynthesisGrid { src_of: &src_of, crop: &crop, scale: sc }, &mut out, &need);}if b(ctx.params, "advanced/showTrackPoints") {let r = (2.5 * f(ctx.params, "advanced/trackPointSize") / 100.0 * sc).max(0.5);@@ -465,19 +465,16 @@ fn render(ctx: &EffectCtx, buf: Buf) -> Buf {Buf { img: out, offset: [0.0; 2], scale: sc }}-/// Fill the pixels flagged in `need` (weight = how much synthesized content they take) from-/// neighbouring frames, nearest first.-#[allow(clippy::too_many_arguments)]-fn synthesize(- ctx: &EffectCtx,- a: &WarpAnalysis,- k: usize,- src_of: &(dyn Fn([f64; 2]) -> [f64; 2] + Sync),- crop: &[f64; 4],- sc: f64,- out: &mut Image,- need: &[f32],-) {+/// Maps an output sample into the uncropped source grid shared by neighbouring frames.+struct SynthesisGrid<'a> {+ src_of: &'a (dyn Fn([f64; 2]) -> [f64; 2] + Sync),+ crop: &'a [f64; 4],+ scale: f64,+}++/// Fill the pixels flagged in `need` from neighbouring frames, nearest first.+fn synthesize(ctx: &EffectCtx, a: &WarpAnalysis, k: usize, grid: &SynthesisGrid<'_>, out: &mut Image, need: &[f32]) {+ let SynthesisGrid { src_of, crop, scale: sc } = *grid;let Some(host) = ctx.env.host else { return };let n = a.frames.len();let range = ((f(ctx.params, "advanced/synthesizeInputRange").max(0.0) / a.frame_duration.max(1e-6)).round() as usize).min(60);