From 4fd276890eb041c5c98c5fe8fb03e22b89245f9d Mon Sep 17 00:00:00 2001
From: jshipsey <jshipsey18@gmail.com>
Date: Tue, 19 Oct 2021 22:27:22 -0400
Subject: [PATCH] switch to new matcell variant

---
 assets/common/entity/spot/pirate.ron          | 12 +-----
 assets/common/entity/spot/witch_dark.ron      | 12 +-----
 .../loadout/spots/dwarf_graverobber.ron       |  1 +
 common/src/figure/cell.rs                     | 20 +++-------
 common/src/figure/mat_cell.rs                 |  1 +
 common/src/figure/mod.rs                      |  7 ++--
 frame-trace_1634705763589.json                | 38 +++++++++++++++++++
 voxygen/src/hud/item_imgs.rs                  |  1 +
 voxygen/src/scene/figure/load.rs              |  2 +-
 9 files changed, 53 insertions(+), 41 deletions(-)
 create mode 100644 frame-trace_1634705763589.json

diff --git a/assets/common/entity/spot/pirate.ron b/assets/common/entity/spot/pirate.ron
index 381f06c508..5af961727c 100644
--- a/assets/common/entity/spot/pirate.ron
+++ b/assets/common/entity/spot/pirate.ron
@@ -1,16 +1,6 @@
 EntityConfig (
     name: Name("Pirate"),
-    body: Exact(Humanoid(Body(
-        species: Human,
-        body_type: Female,
-        hair_style: 2,
-        beard: 0,
-        eyes: 0,
-        accessory: 0,
-        hair_color: 12,
-        skin: 8,
-        eye_color: 3,
-    ))),
+    body: RandomWith("humanoid"),
     alignment: Alignment(Enemy),
 
     loot: LootTable("common.loot_tables.creature.biped_large.saurok"),
diff --git a/assets/common/entity/spot/witch_dark.ron b/assets/common/entity/spot/witch_dark.ron
index 8b4d39a009..19d3992b32 100644
--- a/assets/common/entity/spot/witch_dark.ron
+++ b/assets/common/entity/spot/witch_dark.ron
@@ -1,16 +1,6 @@
 EntityConfig (
     name: Name("Witch"),
-    body: Exact(Humanoid(Body(
-        species: Human,
-        body_type: Female,
-        hair_style: 15,
-        beard: 0,
-        eyes: 0,
-        accessory: 0,
-        hair_color: 12,
-        skin: 0,
-        eye_color: 1,
-    ))),
+    body: RandomWith("humanoid"),
     alignment: Alignment(Enemy),
 
     loot: LootTable("common.loot_tables.spots.witch"),
diff --git a/assets/common/loadout/spots/dwarf_graverobber.ron b/assets/common/loadout/spots/dwarf_graverobber.ron
index 20fbc4d25d..cd39f533c5 100644
--- a/assets/common/loadout/spots/dwarf_graverobber.ron
+++ b/assets/common/loadout/spots/dwarf_graverobber.ron
@@ -5,6 +5,7 @@
     Armor(Hands): Item("common.items.armor.hide.rawhide.hand"),
     Armor(Legs): Item("common.items.armor.hide.rawhide.pants"),
     Armor(Feet): Item("common.items.armor.hide.rawhide.foot"),
+    Armor(Head): Item("common.items.armor.misc.head.bandana.thief"),
 
     Lantern: Choice([
         (1.0, Some(Item("common.items.lantern.black_0"))),
diff --git a/common/src/figure/cell.rs b/common/src/figure/cell.rs
index 63ddb3d81d..378aae4cb2 100644
--- a/common/src/figure/cell.rs
+++ b/common/src/figure/cell.rs
@@ -5,20 +5,19 @@ use vek::*;
 
 const GLOWY: u8 = 1 << 1;
 const SHINY: u8 = 1 << 2;
-const HOLLOW: u8 = 1 << 3;
 
 #[derive(Copy, Clone, Debug, PartialEq, Eq)]
 pub struct CellData {
     pub col: Rgb<u8>,
-    pub attr: NonZeroU8, // 1 = glowy, 2 = shiny, 3 = hollow
+    pub attr: NonZeroU8, // 1 = glowy, 2 = shiny
 }
 
 impl CellData {
-    pub(super) fn new(col: Rgb<u8>, glowy: bool, shiny: bool, hollow: bool) -> Self {
+    pub(super) fn new(col: Rgb<u8>, glowy: bool, shiny: bool) -> Self {
         CellData {
             col,
             attr: NonZeroU8::new(
-                1 + glowy as u8 * GLOWY + shiny as u8 * SHINY + hollow as u8 * HOLLOW,
+                1 + glowy as u8 * GLOWY + shiny as u8 * SHINY,
             )
             .unwrap(),
         }
@@ -26,7 +25,7 @@ impl CellData {
 }
 
 impl Default for CellData {
-    fn default() -> Self { Self::new(Rgb::broadcast(255), false, false, false) }
+    fn default() -> Self { Self::new(Rgb::broadcast(255), false, false) }
 }
 
 /// A type representing a single voxel in a figure.
@@ -37,8 +36,8 @@ pub enum Cell {
 }
 
 impl Cell {
-    pub fn new(col: Rgb<u8>, glowy: bool, shiny: bool, hollow: bool) -> Self {
-        Cell::Filled(CellData::new(col, glowy, shiny, hollow))
+    pub fn new(col: Rgb<u8>, glowy: bool, shiny: bool) -> Self {
+        Cell::Filled(CellData::new(col, glowy, shiny))
     }
 
     pub fn get_color(&self) -> Option<Rgb<u8>> {
@@ -61,13 +60,6 @@ impl Cell {
             Cell::Empty => false,
         }
     }
-
-    pub fn is_hollow(&self) -> bool {
-        match self {
-            Cell::Filled(data) => data.attr.get() & HOLLOW != 0,
-            Cell::Empty => false,
-        }
-    }
 }
 
 impl Vox for Cell {
diff --git a/common/src/figure/mat_cell.rs b/common/src/figure/mat_cell.rs
index 1b2c8de4ea..8e09bf1a41 100644
--- a/common/src/figure/mat_cell.rs
+++ b/common/src/figure/mat_cell.rs
@@ -20,6 +20,7 @@ pub enum MatCell {
     None,
     Mat(Material),
     Normal(CellData),
+    Hollow,
 }
 
 impl Vox for MatCell {
diff --git a/common/src/figure/mod.rs b/common/src/figure/mod.rs
index c9475b807c..508b842f51 100644
--- a/common/src/figure/mod.rs
+++ b/common/src/figure/mod.rs
@@ -67,7 +67,6 @@ impl Segment {
                                 color,
                                 (13..16).contains(&voxel.i), // Glowy
                                 (8..13).contains(&voxel.i),  // Shiny
-                                voxel.i == 16,               // Hollow
                             ),
                         )
                         .unwrap();
@@ -99,7 +98,6 @@ impl Segment {
                     transform(rgb),
                     cell.is_glowy(),
                     cell.is_shiny(),
-                    cell.is_hollow(),
                 )
             })
         })
@@ -166,8 +164,9 @@ impl MatSegment {
         for (pos, vox) in self.full_vol_iter() {
             let data = match vox {
                 MatCell::None => continue,
-                MatCell::Mat(mat) => CellData::new(map(*mat), false, false, false),
+                MatCell::Mat(mat) => CellData::new(map(*mat), false, false),
                 MatCell::Normal(data) => *data,
+                MatCell::Hollow => continue,
             };
             vol.set(pos, Cell::Filled(data)).unwrap();
         }
@@ -220,6 +219,7 @@ impl MatSegment {
                     4 => MatCell::Mat(Material::SkinDark),
                     5 => MatCell::Mat(Material::SkinLight),
                     7 => MatCell::Mat(Material::EyeWhite),
+                    16 => MatCell::Hollow,
                     //6 => MatCell::Mat(Material::Clothing),
                     index => {
                         let color = palette
@@ -230,7 +230,6 @@ impl MatSegment {
                             color,
                             (13..16).contains(&index),
                             (8..13).contains(&index),
-                            index == 16, // Hollow
                         ))
                     },
                 };
diff --git a/frame-trace_1634705763589.json b/frame-trace_1634705763589.json
new file mode 100644
index 0000000000..76bd2be55d
--- /dev/null
+++ b/frame-trace_1634705763589.json
@@ -0,0 +1,38 @@
+{
+"traceEvents": [
+{ "pid":1, "tid":1, "ts":1634705763488162, "dur":5681.276321411133, "ph":"X", "name":"frame" },
+{ "pid":1, "tid":1, "ts":1634705763488195, "dur":661.1347198486328, "ph":"X", "name":"shadow_pass" },
+{ "pid":1, "tid":1, "ts":1634705763488195.3, "dur":643.0149078369141, "ph":"X", "name":"direcred_terrain_shadows" },
+{ "pid":1, "tid":1, "ts":1634705763488839.3, "dur":15.497207641601563, "ph":"X", "name":"direcred_figure_shadows" },
+{ "pid":1, "tid":1, "ts":1634705763488858.8, "dur":690.460205078125, "ph":"X", "name":"point shadows" },
+{ "pid":1, "tid":1, "ts":1634705763488867, "dur":43.15376281738281, "ph":"X", "name":"point shadow face-0 pass" },
+{ "pid":1, "tid":1, "ts":1634705763488917.5, "dur":45.7763671875, "ph":"X", "name":"point shadow face-1 pass" },
+{ "pid":1, "tid":1, "ts":1634705763488970.8, "dur":51.25999450683594, "ph":"X", "name":"point shadow face-2 pass" },
+{ "pid":1, "tid":1, "ts":1634705763489028.8, "dur":51.25999450683594, "ph":"X", "name":"point shadow face-3 pass" },
+{ "pid":1, "tid":1, "ts":1634705763489088.5, "dur":42.438507080078125, "ph":"X", "name":"point shadow face-4 pass" },
+{ "pid":1, "tid":1, "ts":1634705763489501.8, "dur":45.06111145019531, "ph":"X", "name":"point shadow face-5 pass" },
+{ "pid":1, "tid":1, "ts":1634705763489573, "dur":3035.5453491210938, "ph":"X", "name":"first_pass" },
+{ "pid":1, "tid":1, "ts":1634705763489573.8, "dur":20.503997802734375, "ph":"X", "name":"figures" },
+{ "pid":1, "tid":1, "ts":1634705763489594.3, "dur":1816.2727355957031, "ph":"X", "name":"terrain" },
+{ "pid":1, "tid":1, "ts":1634705763491410.8, "dur":41.00799560546875, "ph":"X", "name":"figures" },
+{ "pid":1, "tid":1, "ts":1634705763491451.8, "dur":1039.9818420410156, "ph":"X", "name":"lod_terrain" },
+{ "pid":1, "tid":1, "ts":1634705763492492, "dur":3.337860107421875, "ph":"X", "name":"skybox" },
+{ "pid":1, "tid":1, "ts":1634705763492495.8, "dur":96.08268737792969, "ph":"X", "name":"sprites" },
+{ "pid":1, "tid":1, "ts":1634705763492592.3, "dur":0, "ph":"X", "name":"fluid" },
+{ "pid":1, "tid":1, "ts":1634705763492593.5, "dur":13.113021850585938, "ph":"X", "name":"particles" },
+{ "pid":1, "tid":1, "ts":1634705763492606.8, "dur":1.430511474609375, "ph":"X", "name":"debug" },
+{ "pid":1, "tid":1, "ts":1634705763492621, "dur":546.4553833007813, "ph":"X", "name":"second_pass" },
+{ "pid":1, "tid":1, "ts":1634705763493169.8, "dur":466.1083221435547, "ph":"X", "name":"bloom" },
+{ "pid":1, "tid":1, "ts":1634705763493174, "dur":41.00799560546875, "ph":"X", "name":"downsample filtered 1" },
+{ "pid":1, "tid":1, "ts":1634705763493220.5, "dur":12.874603271484375, "ph":"X", "name":"downsample 2" },
+{ "pid":1, "tid":1, "ts":1634705763493237.5, "dur":4.0531158447265625, "ph":"X", "name":"downsample 3" },
+{ "pid":1, "tid":1, "ts":1634705763493247.3, "dur":2.6226043701171875, "ph":"X", "name":"downsample 4" },
+{ "pid":1, "tid":1, "ts":1634705763493255.3, "dur":5.0067901611328125, "ph":"X", "name":"upsample 1" },
+{ "pid":1, "tid":1, "ts":1634705763493438.3, "dur":11.205673217773438, "ph":"X", "name":"upsample 2" },
+{ "pid":1, "tid":1, "ts":1634705763493456.3, "dur":31.948089599609375, "ph":"X", "name":"upsample 3" },
+{ "pid":1, "tid":1, "ts":1634705763493501.8, "dur":131.13021850585938, "ph":"X", "name":"upsample 4" },
+{ "pid":1, "tid":1, "ts":1634705763493646.8, "dur":193.11904907226563, "ph":"X", "name":"third_pass" },
+{ "pid":1, "tid":1, "ts":1634705763493647.3, "dur":181.1981201171875, "ph":"X", "name":"postprocess" },
+{ "pid":1, "tid":1, "ts":1634705763493829.5, "dur":9.5367431640625, "ph":"X", "name":"ui" }
+]
+}
diff --git a/voxygen/src/hud/item_imgs.rs b/voxygen/src/hud/item_imgs.rs
index 443cee23c8..67ff971203 100644
--- a/voxygen/src/hud/item_imgs.rs
+++ b/voxygen/src/hud/item_imgs.rs
@@ -211,6 +211,7 @@ fn graceful_load_segment_no_skin(specifier: &str) -> Arc<Segment> {
     let seg = mat_seg
         .map(|mat_cell| match mat_cell {
             MatCell::None => None,
+            MatCell::Hollow => None,
             MatCell::Mat(_) => Some(MatCell::None),
             MatCell::Normal(_) => None,
         })
diff --git a/voxygen/src/scene/figure/load.rs b/voxygen/src/scene/figure/load.rs
index a249148052..4e03d59bc9 100644
--- a/voxygen/src/scene/figure/load.rs
+++ b/voxygen/src/scene/figure/load.rs
@@ -318,7 +318,7 @@ impl HumHeadSpec {
             .maybe_add(beard)
             .maybe_add(accessory)
             .maybe_add(helmet)
-            .unify_with(|v| if v.is_hollow() { Cell::empty() } else { v });
+            .unify();
         (
             head,
             Vec3::from(spec.offset) + origin_offset.map(|e| e as f32 * -1.0),