clippy fixes

This commit is contained in:
Robin Appelman 2024-12-14 15:03:59 +01:00
commit 3175e0840c
4 changed files with 16 additions and 18 deletions

View file

@ -83,7 +83,7 @@ pub fn load_material(
let bump_map = material.bump_map().and_then(|path| {
Some(TextureData {
image: load_texture(&path, loader).ok()?,
image: load_texture(path, loader).ok()?,
name: path.into(),
})
});
@ -107,10 +107,10 @@ fn load_texture(name: &str, loader: &Loader) -> Result<DynamicImage, Error> {
"materials/{}.vtf",
name.trim_end_matches(".vtf").trim_start_matches('/')
);
let mut raw = loader
let raw = loader
.load(&path)?
.ok_or(Error::Other(format!("Can't find file {}", path)))?;
let vtf = VTF::read(&mut raw)?;
let vtf = VTF::read(&raw)?;
let image = vtf.highres_image.decode(0)?;
Ok(image)
}

View file

@ -25,7 +25,7 @@ impl From<&vmdl::vvd::Vertex> for Vertex {
fn from(vertex: &vmdl::vvd::Vertex) -> Self {
Vertex {
position: vertex.position.into(),
uv: vertex.texture_coordinates.into(),
uv: vertex.texture_coordinates,
normal: vertex.normal.into(),
}
}

View file

@ -115,11 +115,9 @@ fn main() -> Result<(), Error> {
);
directional[0].intensity = directional_intensity;
directional[1].intensity = directional_intensity;
if ui.checkbox(&mut shadows_enabled, "Shadows").clicked() {
if !shadows_enabled {
directional[0].clear_shadow_map();
directional[1].clear_shadow_map();
}
if ui.checkbox(&mut shadows_enabled, "Shadows").clicked() && !shadows_enabled {
directional[0].clear_shadow_map();
directional[1].clear_shadow_map();
}
ui.label("Debug options");
@ -175,8 +173,10 @@ fn main() -> Result<(), Error> {
lights,
),
DebugType::DEPTH => {
let mut depth_material = DepthMaterial::default();
depth_material.max_distance = Some(depth_max);
let depth_material = DepthMaterial {
max_distance: Some(depth_max),
..DepthMaterial::default()
};
target.render_with_material(
&depth_material,
&camera,