diff src/th06/interpolator.rs @ 709:6d4802abe134

Make interpolators use u32 instead of u16.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Sun, 08 Sep 2019 17:53:13 +0200
parents 6020e33d4fc4
children 5016c09e5d7c
line wrap: on
line diff
--- a/src/th06/interpolator.rs
+++ b/src/th06/interpolator.rs
@@ -23,8 +23,8 @@ macro_rules! generate_interpolator {
         pub(crate) struct $name<T> {
             start_values: [T; $n],
             end_values: [T; $n],
-            start_frame: u16,
-            end_frame: u16,
+            start_frame: u32,
+            end_frame: u32,
             formula: Formula,
         }
 
@@ -36,7 +36,7 @@ macro_rules! generate_interpolator {
               T: Copy,
               T: Default,
         {
-            pub fn new(start_values: [T; $n], start_frame: u16, end_values: [T; $n], end_frame: u16, formula: Formula) -> $name<T> {
+            pub fn new(start_values: [T; $n], start_frame: u32, end_values: [T; $n], end_frame: u32, formula: Formula) -> $name<T> {
                 $name {
                     start_values,
                     end_values,
@@ -46,8 +46,26 @@ macro_rules! generate_interpolator {
                 }
             }
 
+            pub fn set_start(&mut self, frame: u32, values: [T; $n]) {
+                self.start_values = values;
+                self.start_frame = frame;
+            }
+
+            pub fn set_end(&mut self, frame: u32, values: [T; $n]) {
+                self.end_values = values;
+                self.end_frame = frame;
+            }
+
+            pub fn set_end_values(&mut self, values: [T; $n]) {
+                self.end_values = values;
+            }
+
+            pub fn set_end_frame(&mut self, frame: u32) {
+                self.end_frame = frame;
+            }
+
             // XXX: Make it return [T; $n] instead, we don’t want to only do f32 here.
-            pub fn values(&self, frame: u16) -> [f32; $n] {
+            pub fn values(&self, frame: u32) -> [f32; $n] {
                 if frame + 1 >= self.end_frame {
                     // XXX: skip the last interpolation step.
                     // This bug is replicated from the original game.