diff options
Diffstat (limited to 'world/src/mesh.rs')
-rw-r--r-- | world/src/mesh.rs | 41 |
1 files changed, 21 insertions, 20 deletions
diff --git a/world/src/mesh.rs b/world/src/mesh.rs index fd6b6ae..16c2ce7 100644 --- a/world/src/mesh.rs +++ b/world/src/mesh.rs @@ -36,13 +36,19 @@ pub fn import_mesh( args: &Args, ) -> Result<()> { Ok(for p in mesh.primitives() { + let name = mesh.name().or(node.name()).map(|e| e.to_owned()); + if let Some(name) = &name { + info!("adding mesh {name:?}"); + } else { + info!("adding mesh"); + } let reader = p.reader(|buf| Some(&buffers[buf.index()])); let va_position = reader .read_positions() .map(|iter| { let a = iter.map(|[x, y, z]| vec3a(x, y, z)).collect::<Vec<_>>(); - info!("{} vertex positions", a.len()); + debug!("{} vertex positions", a.len()); Ok::<_, anyhow::Error>(store.set(&a)?) }) .transpose()?; @@ -51,7 +57,7 @@ pub fn import_mesh( .read_normals() .map(|iter| { let a = iter.map(|[x, y, z]| vec3a(x, y, z)).collect::<Vec<_>>(); - info!("{} vertex normals", a.len()); + debug!("{} vertex normals", a.len()); Ok::<_, anyhow::Error>(store.set(&a)?) }) .transpose()?; @@ -60,7 +66,7 @@ pub fn import_mesh( .read_tex_coords(0) .map(|iter| { let a = iter.into_f32().map(|[x, y]| vec2(x, y)).collect::<Vec<_>>(); - info!("{} vertex texture coordinates", a.len()); + debug!("{} vertex texture coordinates", a.len()); Ok::<_, anyhow::Error>(store.set(&a)?) }) .transpose()?; @@ -72,7 +78,7 @@ pub fn import_mesh( .into_rgb_f32() .map(|[x, y, z]| vec3a(x, y, z)) .collect::<Vec<_>>(); - info!("{} vertex colors", a.len()); + debug!("{} vertex colors", a.len()); Ok::<_, anyhow::Error>(store.set(&a)?) }) .transpose()?; @@ -85,7 +91,7 @@ pub fn import_mesh( color_a.push(p[3]); } let o = if color_a.iter().any(|x| *x != 1.) { - info!("{} vertex transmissions", color_a.len()); + debug!("{} vertex transmissions", color_a.len()); Some(store.set(&color_a)?) } else { debug!("vertex transmission pruned"); @@ -102,7 +108,7 @@ pub fn import_mesh( .into_u32() .array_chunks::<3>() .collect::<Vec<_>>(); - info!("{} indecies", index.len() * 3); + debug!("{} indecies", index.len() * 3); let index = Some(store.set(&index)?); let mut tex_albedo = None; @@ -209,7 +215,7 @@ pub fn import_mesh( let base_color = p.material().pbr_metallic_roughness().base_color_factor(); let g_albedo = if base_color[0] != 1. || base_color[1] != 1. || base_color[2] != 1. { - info!( + debug!( "albedo is r={},g={},b={}", base_color[0], base_color[1], base_color[2] ); @@ -219,7 +225,7 @@ pub fn import_mesh( None }; let g_alpha = if base_color[3] != 1. { - info!("alpha is {}", base_color[3]); + debug!("alpha is {}", base_color[3]); Some(base_color[3]) } else { debug!("alpha pruned"); @@ -228,7 +234,7 @@ pub fn import_mesh( let emission = p.material().emissive_factor(); let g_emission = if emission[0] != 0. || emission[1] != 0. || emission[2] != 0. { - info!( + debug!( "emission is r={},g={},b={}", base_color[0], base_color[1], base_color[2] ); @@ -245,7 +251,7 @@ pub fn import_mesh( .unwrap_or(0.); let g_transmission = if transmission != 0. { - info!("transmission is {transmission}"); + debug!("transmission is {transmission}"); Some(transmission) } else { debug!("transmission pruned"); @@ -263,7 +269,7 @@ pub fn import_mesh( .flatten() .map(|e| e as f32); if let Some(d) = g_dispersion { - info!("dispersion is {d}"); + debug!("dispersion is {d}"); } let g_attenuation = p.material().volume().map(|v| { @@ -272,34 +278,29 @@ pub fn import_mesh( // manually derived from attenuation coefficient formula. i hope this is correct. |factor| -(factor.powf(1. / ref_dist)).ln(), )); - info!("attenuation is {att}"); + debug!("attenuation is {att}"); att }); let g_refractive_index = p.material().ior(); if let Some(i) = g_refractive_index { - info!("refractive index is {i}"); + debug!("refractive index is {i}"); } let g_thickness = p.material().volume().map(|v| v.thickness_factor()); - let name = mesh.name().map(|e| e.to_owned()); - if let Some(name) = &name { - info!("name is {name:?}"); - } - let g_unlit = if p .material() .extensions() .map(|e| e.contains_key("KHR_materials_unlit")) .unwrap_or(false) { - info!("unlit"); + debug!("unlit"); Some(()) } else { None }; let g_double_sided = if p.material().double_sided() { - info!("double sided"); + debug!("double sided"); Some(()) } else { None |