Fix issues found by `cargo clippy`, including bugs

This commit is contained in:
Matthew Gordon 2024-11-22 20:32:15 -04:00
parent a4503c3dbf
commit e7180e57bf
3 changed files with 12 additions and 17 deletions

View File

@ -37,7 +37,7 @@ struct Camera {
}
impl Camera {
fn new(device: &wgpu::Device, viewport_aspect_ratio: f32) -> Self {
fn new(viewport_aspect_ratio: f32) -> Self {
let projection_matrix = glam::Mat4::perspective_rh(
std::f32::consts::FRAC_PI_4,
viewport_aspect_ratio,
@ -182,10 +182,7 @@ impl DemRenderer {
)
};
let camera = Camera::new(
device,
surface_config.width as f32 / surface_config.height as f32,
);
let camera = Camera::new(surface_config.width as f32 / surface_config.height as f32);
let mut uniforms = UniformBufferManager::new(device);
uniforms.set_dem_texture_size(dem_texture_size);
@ -329,7 +326,7 @@ impl DemRenderer {
fn get_max_dem_dimension(&self) -> f32 {
let dem = &self.source;
(dem.x_max - dem.x_min)
.max(dem.y_max - dem.y_max)
.max(dem.y_max - dem.y_min)
.max(dem.z_max - dem.x_min)
}

View File

@ -200,5 +200,5 @@ impl MvuApp<Model> for App {
fn open_test_file(file_path: PathBuf, model: Rc<Model>) -> Rc<Model> {
let dem = Some(Rc::new(raster::Dem::load_from_image(&file_path)));
Rc::new(Model { dem })
Rc::new(Model { dem, ..*model })
}

View File

@ -1,7 +1,4 @@
use {
std::{fs::File, path::PathBuf},
tiff,
};
use std::{fs::File, path::PathBuf};
#[derive(Clone)]
pub struct Dem {
@ -63,9 +60,9 @@ fn round_bound(v: u32) -> u32 {
impl DemBvh {
fn new(dem: &Dem) -> DemBvh {
let mut layers = vec![create_first_dembvh_layer(&dem)];
let mut layers = vec![create_first_dembvh_layer(dem)];
while layers.last().unwrap().size > 1 {
layers.push(create_next_dembvh_layer(&layers.last().unwrap()));
layers.push(create_next_dembvh_layer(layers.last().unwrap()));
}
DemBvh { layers }
}
@ -181,10 +178,11 @@ impl Dem {
let x_max = 500.0;
let y_min = -500.0;
let y_max = 500.0;
let (z_min, z_max) = f32_values[1..].iter().fold(
(f32_values[0], f32_values[0]),
|(min, max), elem| (min.min(*elem), max.max(*elem)),
);
let (z_min, z_max) = f32_values[1..]
.iter()
.fold((f32_values[0], f32_values[0]), |(min, max), elem| {
(min.min(*elem), max.max(*elem))
});
let grid = f32_values
.iter()
.map(|v| normalized_f32_to_u16(normalize_f32(*v, z_min, z_max)))