Mercurial > touhou
diff interpreters/src/th06/anm0.rs @ 787:7f9b3f5001c2
interpreters: Make Interpolator generic over N
This was a workaround for Rust < 1.51 which didn’t support const generics yet,
but we’ve had tat for close to five years now!
| author | Link Mauve <linkmauve@linkmauve.fr> |
|---|---|
| date | Mon, 15 Dec 2025 11:34:58 +0100 |
| parents | 21b186be2590 |
| children |
line wrap: on
line diff
--- a/interpreters/src/th06/anm0.rs +++ b/interpreters/src/th06/anm0.rs @@ -6,7 +6,7 @@ Call, Instruction, }; -use crate::th06::interpolator::{Interpolator1, Interpolator2, Interpolator3, Formula}; +use crate::th06::interpolator::{Interpolator, Formula}; use touhou_utils::math::Mat4; use touhou_utils::prng::Prng; use std::cell::RefCell; @@ -45,11 +45,11 @@ mirrored: bool, corner_relative_placement: bool, - scale_interpolator: Option<Interpolator2<f32>>, - fade_interpolator: Option<Interpolator1<f32>>, // XXX: should be u8! - offset_interpolator: Option<Interpolator3<f32>>, - rotation_interpolator: Option<Interpolator3<f32>>, - color_interpolator: Option<Interpolator3<f32>>, // XXX: should be u8! + scale_interpolator: Option<Interpolator<f32, 2>>, + fade_interpolator: Option<Interpolator<f32, 1>>, // XXX: should be u8! + offset_interpolator: Option<Interpolator<f32, 3>>, + rotation_interpolator: Option<Interpolator<f32, 3>>, + color_interpolator: Option<Interpolator<f32, 3>>, // XXX: should be u8! anm: Option<Anm0>, @@ -409,7 +409,7 @@ sprite.scale_speed = [ssx, ssy]; } Instruction::Fade(new_alpha, duration) => { - sprite.fade_interpolator = Some(Interpolator1::new([sprite.color[3] as f32], sprite.frame, [new_alpha as f32], sprite.frame + duration, Formula::Linear)); + sprite.fade_interpolator = Some(Interpolator::new([sprite.color[3] as f32], sprite.frame, [new_alpha as f32], sprite.frame + duration, Formula::Linear)); } Instruction::SetBlendmodeAlphablend() => { sprite.blendfunc = 1; @@ -433,13 +433,13 @@ sprite.dest_offset = [x, y, z]; } Instruction::MoveToLinear(x, y, z, duration) => { - sprite.offset_interpolator = Some(Interpolator3::new(sprite.dest_offset, sprite.frame, [x, y, z], sprite.frame + duration, Formula::Linear)); + sprite.offset_interpolator = Some(Interpolator::new(sprite.dest_offset, sprite.frame, [x, y, z], sprite.frame + duration, Formula::Linear)); } Instruction::MoveToDecel(x, y, z, duration) => { - sprite.offset_interpolator = Some(Interpolator3::new(sprite.dest_offset, sprite.frame, [x, y, z], sprite.frame + duration, Formula::InvertPower2)); + sprite.offset_interpolator = Some(Interpolator::new(sprite.dest_offset, sprite.frame, [x, y, z], sprite.frame + duration, Formula::InvertPower2)); } Instruction::MoveToAccel(x, y, z, duration) => { - sprite.offset_interpolator = Some(Interpolator3::new(sprite.dest_offset, sprite.frame, [x, y, z], sprite.frame + duration, Formula::Power2)); + sprite.offset_interpolator = Some(Interpolator::new(sprite.dest_offset, sprite.frame, [x, y, z], sprite.frame + duration, Formula::Power2)); } Instruction::Wait() => { self.waiting = true; @@ -471,7 +471,7 @@ sprite.visible = (visible & 1) != 0; } Instruction::ScaleIn(sx, sy, duration) => { - sprite.scale_interpolator = Some(Interpolator2::new(sprite.rescale, sprite.frame, [sx, sy], sprite.frame + duration, Formula::Linear)); + sprite.scale_interpolator = Some(Interpolator::new(sprite.rescale, sprite.frame, [sx, sy], sprite.frame + duration, Formula::Linear)); } Instruction::Todo(_todo) => { // TODO.
