changeset 744:3687205fe620

anm0_vm: Use the unused u16 to store the anm layer to use.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Sat, 18 Jan 2020 16:25:45 +0100
parents 0fed350d1778
children 90e907859bae
files src/th06/anm0_vm.rs
diffstat 1 files changed, 11 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/th06/anm0_vm.rs	Tue Jan 07 12:34:11 2020 +0100
+++ b/src/th06/anm0_vm.rs	Sat Jan 18 16:25:45 2020 +0100
@@ -19,6 +19,8 @@
     /// XXX
     pub pos: [i16; 3],
     /// XXX
+    pub layer: u16,
+    /// XXX
     pub uv: [f32; 2],
     /// XXX
     pub color: [u8; 4],
@@ -59,6 +61,7 @@
     rotations_3d: [f32; 3],
     rotations_speed_3d: [f32; 3],
     color: [u8; 4],
+    layer: u16,
 }
 
 impl Sprite {
@@ -164,6 +167,11 @@
         vertices[1].color = self.color;
         vertices[2].color = self.color;
         vertices[3].color = self.color;
+
+        vertices[0].layer = self.layer;
+        vertices[1].layer = self.layer;
+        vertices[2].layer = self.layer;
+        vertices[3].layer = self.layer;
     }
 
     /// Update sprite values from the interpolators.
@@ -229,6 +237,7 @@
         let anms = self.inner.borrow();
         let mut anm = None;
         let mut texcoords = None;
+        let mut layer = 0;
         'anm: for anm0 in anms.iter() {
             for sp in anm0.sprites.iter() {
                 if sp.index == id as u32 {
@@ -237,8 +246,10 @@
                     break 'anm;
                 }
             }
+            layer += 1;
         }
         sprite.anm = anm;
+        sprite.layer = layer;
         if let Some(texcoords) = texcoords {
             sprite.texcoords = [texcoords.x, texcoords.y, texcoords.width, texcoords.height];
         }