comparison interpreters/src/th06/std.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
comparison
equal deleted inserted replaced
786:7e940ebeb5fd 787:7f9b3f5001c2
1 //! Interpreter of STD files. 1 //! Interpreter of STD files.
2 2
3 use touhou_formats::th06::std::{Stage, Call, Instruction}; 3 use touhou_formats::th06::std::{Stage, Call, Instruction};
4 use crate::th06::interpolator::{Interpolator3, Formula}; 4 use crate::th06::interpolator::{Interpolator, Formula};
5 use touhou_utils::math::{Mat4, setup_camera}; 5 use touhou_utils::math::{Mat4, setup_camera};
6 use std::cell::RefCell; 6 use std::cell::RefCell;
7 use std::rc::Rc; 7 use std::rc::Rc;
8 8
9 /// Interpreter for Stage. 9 /// Interpreter for Stage.
10 pub struct StageRunner { 10 pub struct StageRunner {
11 /// XXX: no pub. 11 /// XXX: no pub.
12 pub stage: Rc<RefCell<Stage>>, 12 pub stage: Rc<RefCell<Stage>>,
13 frame: u32, 13 frame: u32,
14 14
15 position: Interpolator3<f32>, 15 position: Interpolator<f32, 3>,
16 direction: Interpolator3<f32>, 16 direction: Interpolator<f32, 3>,
17 17
18 /// XXX: no pub. 18 /// XXX: no pub.
19 pub fog_color: [f32; 4], 19 pub fog_color: [f32; 4],
20 /// XXX: no pub. 20 /// XXX: no pub.
21 pub fog_near: f32, 21 pub fog_near: f32,
27 /// Create a new StageRunner attached to a Stage. 27 /// Create a new StageRunner attached to a Stage.
28 pub fn new(stage: Rc<RefCell<Stage>>) -> StageRunner { 28 pub fn new(stage: Rc<RefCell<Stage>>) -> StageRunner {
29 StageRunner { 29 StageRunner {
30 stage, 30 stage,
31 frame: 0, 31 frame: 0,
32 position: Interpolator3::new([0., 0., 0.], 0, [0., 0., 0.], 0, Formula::Linear), 32 position: Interpolator::new([0., 0., 0.], 0, [0., 0., 0.], 0, Formula::Linear),
33 direction: Interpolator3::new([0., 0., 0.], 0, [0., 0., 0.], 0, Formula::Linear), 33 direction: Interpolator::new([0., 0., 0.], 0, [0., 0., 0.], 0, Formula::Linear),
34 fog_color: [1.; 4], 34 fog_color: [1.; 4],
35 fog_near: 0., 35 fog_near: 0.,
36 fog_far: 1000., 36 fog_far: 1000.,
37 } 37 }
38 } 38 }