summaryrefslogtreecommitdiff
path: root/world/src/mesh.rs
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2025-01-27 15:26:00 +0100
committermetamuffin <metamuffin@disroot.org>2025-01-27 15:26:00 +0100
commitc121d94f0b27bc04ffbdca55cd0939c1401d5a2e (patch)
tree67ac9da1f994c24b9a3e8e8d2adc2e334d2e34a5 /world/src/mesh.rs
parent6b5c44d58e6c6d3df360396a0897290fc603699b (diff)
downloadweareserver-c121d94f0b27bc04ffbdca55cd0939c1401d5a2e.tar
weareserver-c121d94f0b27bc04ffbdca55cd0939c1401d5a2e.tar.bz2
weareserver-c121d94f0b27bc04ffbdca55cd0939c1401d5a2e.tar.zst
clippy: fixes and ignores
Diffstat (limited to 'world/src/mesh.rs')
-rw-r--r--world/src/mesh.rs59
1 files changed, 28 insertions, 31 deletions
diff --git a/world/src/mesh.rs b/world/src/mesh.rs
index b8dc0c3..4e6317d 100644
--- a/world/src/mesh.rs
+++ b/world/src/mesh.rs
@@ -38,7 +38,7 @@ pub fn import_mesh(
texture_cache: &TextureCache,
armatures: &[Option<Armature>],
) -> Result<()> {
- Ok(for p in mesh.primitives() {
+ 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:?}");
@@ -52,7 +52,7 @@ pub fn import_mesh(
.map(|iter| {
let a = iter.map(|[x, y, z]| vec3a(x, y, z)).collect::<Vec<_>>();
debug!("{} vertex positions", a.len());
- Ok::<_, anyhow::Error>(store.set(&a)?)
+ store.set(&a)
})
.transpose()?;
@@ -61,7 +61,7 @@ pub fn import_mesh(
.map(|iter| {
let a = iter.map(|[x, y, z]| vec3a(x, y, z)).collect::<Vec<_>>();
debug!("{} vertex normals", a.len());
- Ok::<_, anyhow::Error>(store.set(&a)?)
+ store.set(&a)
})
.transpose()?;
@@ -71,7 +71,7 @@ pub fn import_mesh(
// TODO dont ignore handedness
let a = iter.map(|[x, y, z, _h]| vec3a(x, y, z)).collect::<Vec<_>>();
debug!("{} vertex tangents", a.len());
- Ok::<_, anyhow::Error>(store.set(&a)?)
+ store.set(&a)
})
.transpose()?;
@@ -80,7 +80,7 @@ pub fn import_mesh(
.map(|iter| {
let a = iter.into_u16().collect::<Vec<_>>();
debug!("{} vertex joint indecies", a.len());
- Ok::<_, anyhow::Error>(store.set(&a)?)
+ store.set(&a)
})
.transpose()?;
@@ -89,7 +89,7 @@ pub fn import_mesh(
.map(|iter| {
let a = iter.into_f32().collect::<Vec<_>>();
debug!("{} vertex joint weights", a.len());
- Ok::<_, anyhow::Error>(store.set(&a)?)
+ store.set(&a)
})
.transpose()?;
@@ -98,7 +98,7 @@ pub fn import_mesh(
.map(|iter| {
let a = iter.into_f32().map(|[x, y]| vec2(x, y)).collect::<Vec<_>>();
debug!("{} vertex texture coordinates", a.len());
- Ok::<_, anyhow::Error>(store.set(&a)?)
+ store.set(&a)
})
.transpose()?;
@@ -110,7 +110,7 @@ pub fn import_mesh(
.map(|[x, y, z]| vec3a(x, y, z))
.collect::<Vec<_>>();
debug!("{} vertex colors", a.len());
- Ok::<_, anyhow::Error>(store.set(&a)?)
+ store.set(&a)
})
.transpose()?;
@@ -147,9 +147,9 @@ pub fn import_mesh(
if let Some(tex) = p.material().pbr_metallic_roughness().base_color_texture() {
let r = load_texture(
"albedo",
- &store,
+ store,
path_base,
- &buffers,
+ buffers,
&tex.texture().source().source(),
args.webp,
texture_cache,
@@ -161,9 +161,9 @@ pub fn import_mesh(
if let Some(tex) = p.material().normal_texture() {
tex_normal = Some(load_texture(
"normal",
- &store,
+ store,
path_base,
- &buffers,
+ buffers,
&tex.texture().source().source(),
args.webp,
texture_cache,
@@ -173,9 +173,9 @@ pub fn import_mesh(
if let Some(tex) = p.material().emissive_texture() {
tex_emission = Some(load_texture(
"emission",
- &store,
+ store,
path_base,
- &buffers,
+ buffers,
&tex.texture().source().source(),
args.webp,
texture_cache,
@@ -185,14 +185,13 @@ pub fn import_mesh(
if let Some(tex) = p
.material()
.transmission()
- .map(|t| t.transmission_texture())
- .flatten()
+ .and_then(|t| t.transmission_texture())
{
tex_transmission = Some(load_texture(
"transmission",
- &store,
+ store,
path_base,
- &buffers,
+ buffers,
&tex.texture().source().source(),
args.webp,
texture_cache,
@@ -202,14 +201,13 @@ pub fn import_mesh(
if let Some(tex) = p
.material()
.volume()
- .map(|t| t.thickness_texture())
- .flatten()
+ .and_then(|t| t.thickness_texture())
{
tex_thickness = Some(load_texture(
"thickness",
- &store,
+ store,
path_base,
- &buffers,
+ buffers,
&tex.texture().source().source(),
args.webp,
texture_cache,
@@ -219,9 +217,9 @@ pub fn import_mesh(
if let Some(tex) = p.material().occlusion_texture() {
tex_occlusion = Some(load_texture(
"occlusion",
- &store,
+ store,
path_base,
- &buffers,
+ buffers,
&tex.texture().source().source(),
args.webp,
texture_cache,
@@ -236,9 +234,9 @@ pub fn import_mesh(
{
let r = load_texture(
"metallic+roughness",
- &store,
+ store,
path_base,
- &buffers,
+ buffers,
&tex.texture().source().source(),
args.webp,
texture_cache,
@@ -299,10 +297,8 @@ pub fn import_mesh(
let g_dispersion = p
.material()
.extension_value("KHR_materials_dispersion")
- .map(|e| e.get("dispersion"))
- .flatten()
- .map(|e| e.as_f64())
- .flatten()
+ .and_then(|e| e.get("dispersion"))
+ .and_then(|e| e.as_f64())
.map(|e| e as f32);
if let Some(d) = g_dispersion {
debug!("dispersion is {d}");
@@ -391,5 +387,6 @@ pub fn import_mesh(
})?;
prefab.mesh.push((trans, mesh))
- })
+ };
+ Ok(())
}