mirror of
https://github.com/storytold/texturecraft.git
synced 2026-11-21 15:00:42 +01:00
perf(formats): index high-poly base colors by material name
This commit is contained in:
1 file changed
+5
-1
@@ -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)) => {
|
||||
|
||||
Reference in new issue
Block a user