perf(formats): index high-poly base colors by material name

This commit is contained in:
Dylan M. Taylor committed 2026-11-20 14:30:57 -05:00
1 parent 13ec99ac65
commit 5aaaf487e1
1 file changed
+5 -1
+5 -1
View File
@@ -335,11 +335,15 @@ pub fn import_high_poly_bytes(file_name: &str, bytes: &[u8]) -> Result<HighPolyM
mesh.tangents = vec![Vec4::new(1.0, 0.0, 0.0, 1.0); n];
mesh.validate()?;
let mut budget = BASE_COLOR_TEXELS;
let mut color_by_material: HashMap<&str, &RawBaseColor> = HashMap::with_capacity(colors.len());
for color in &colors {
color_by_material.entry(color.material.as_str()).or_insert(color);
}
let base_color = mesh
.materials
.iter()
.map(|m| {
let c = colors.iter().find(|c| c.material == *m)?;
let c = color_by_material.get(m.as_str()).copied()?;
let (width, height, texels) = match c.image.as_deref().map(|b| decode_base_color(b, &mut budget)) {
Some(Ok(t)) => t,
Some(Err(e)) => {