Minor changes suggested by clippy
This commit is contained in:
parent
8c458d073e
commit
80b2d87d22
|
|
@ -82,6 +82,7 @@ impl Spectrum {
|
|||
Spectrum {
|
||||
shortest_wavelength: rgb_reference_spectrum::SHORTEST_WAVELENGTH,
|
||||
longest_wavelength: rgb_reference_spectrum::LONGEST_WAVELENGTH,
|
||||
#[allow(clippy::collapsible_else_if)]
|
||||
samples: if colour.red() <= colour.green() && colour.red() <= colour.blue() {
|
||||
if colour.green() <= colour.blue() {
|
||||
izip![
|
||||
|
|
@ -178,6 +179,7 @@ impl Spectrum {
|
|||
mod rgb_reference_spectrum {
|
||||
pub const SHORTEST_WAVELENGTH: f64 = 380.0;
|
||||
pub const LONGEST_WAVELENGTH: f64 = 720.0;
|
||||
#[allow(clippy::excessive_precision)]
|
||||
pub mod reflection {
|
||||
pub const WHITE: [f64; 32] = [
|
||||
1.0618958571272863e+00,
|
||||
|
|
|
|||
|
|
@ -109,21 +109,21 @@ pub trait NormalizedAsByte {
|
|||
|
||||
impl NormalizedAsByte for f32 {
|
||||
fn normalized_to_byte(self) -> u8 {
|
||||
(self * (std::u8::MAX as f32)) as u8
|
||||
(self * (u8::MAX as f32)) as u8
|
||||
}
|
||||
|
||||
fn byte_to_normalized(byte: u8) -> f32 {
|
||||
(byte as f32) / (std::u8::MAX as f32)
|
||||
(byte as f32) / (u8::MAX as f32)
|
||||
}
|
||||
}
|
||||
|
||||
impl NormalizedAsByte for f64 {
|
||||
fn normalized_to_byte(self) -> u8 {
|
||||
(self * (std::u8::MAX as f64)) as u8
|
||||
(self * (u8::MAX as f64)) as u8
|
||||
}
|
||||
|
||||
fn byte_to_normalized(byte: u8) -> f64 {
|
||||
(byte as f64) / (std::u8::MAX as f64)
|
||||
(byte as f64) / (u8::MAX as f64)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ fn update_texture(image: &ImageRgbU8, texture: &mut Texture) {
|
|||
.update(
|
||||
Rect::new(0, 0, image.get_width() as u32, image.get_height() as u32),
|
||||
image.get_pixel_data(),
|
||||
(image.get_width() * ImageRgbU8::num_channels()) as usize,
|
||||
image.get_width() * ImageRgbU8::num_channels(),
|
||||
)
|
||||
.expect("Couldn't update texture.");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ pub struct Mat4<T:Float> {
|
|||
}
|
||||
|
||||
impl<T:Float> Mat4<T> {
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn new(
|
||||
m00: T,
|
||||
m01: T,
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ mod wavefront_obj {
|
|||
) -> Vec<Triangle> {
|
||||
if let Some(v0_index) = polygon.iter().next() {
|
||||
let (v0_vertex, v0_normal) =
|
||||
get_vertex_and_normal(v0_index, &vertex_positions, normal_positions);
|
||||
get_vertex_and_normal(v0_index, vertex_positions, normal_positions);
|
||||
polygon
|
||||
.iter()
|
||||
.skip(1)
|
||||
|
|
|
|||
|
|
@ -82,17 +82,17 @@ impl HasBoundingBox for Plane {
|
|||
if v.x() == 0.0 {
|
||||
0.0
|
||||
} else {
|
||||
std::f64::INFINITY
|
||||
f64::INFINITY
|
||||
},
|
||||
if v.y() == 0.0 {
|
||||
0.0
|
||||
} else {
|
||||
std::f64::INFINITY
|
||||
f64::INFINITY
|
||||
},
|
||||
if v.z() == 0.0 {
|
||||
0.0
|
||||
} else {
|
||||
std::f64::INFINITY
|
||||
f64::INFINITY
|
||||
},
|
||||
)
|
||||
};
|
||||
|
|
|
|||
|
|
@ -106,6 +106,7 @@ impl HasBoundingBox for Triangle {
|
|||
impl Primitive for Triangle {}
|
||||
|
||||
fn indices_with_index_of_largest_element_last(v: &Vec3<f64>) -> [usize; 3] {
|
||||
#[allow(clippy::collapsible_else_if)]
|
||||
if v.x() > v.y() {
|
||||
if v.z() > v.x() {
|
||||
[0, 1, 2]
|
||||
|
|
|
|||
|
|
@ -15,15 +15,15 @@ impl Interval {
|
|||
|
||||
pub fn empty() -> Self {
|
||||
Interval {
|
||||
min: std::f64::INFINITY,
|
||||
max: std::f64::NEG_INFINITY,
|
||||
min: f64::INFINITY,
|
||||
max: f64::NEG_INFINITY,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn infinite() -> Self {
|
||||
Interval {
|
||||
min: std::f64::NEG_INFINITY,
|
||||
max: std::f64::INFINITY,
|
||||
min: f64::NEG_INFINITY,
|
||||
max: f64::INFINITY,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ pub struct TileIterator {
|
|||
impl TileIterator {
|
||||
pub fn new(total_width: usize, total_height: usize, tile_size: usize) -> TileIterator {
|
||||
// If tile_size*2 is greater than usize::max_value(), increment would overflow
|
||||
assert!(tile_size > 0 && tile_size * 2 < usize::max_value());
|
||||
assert!(tile_size > 0 && tile_size * 2 < usize::MAX);
|
||||
TileIterator {
|
||||
tile_size,
|
||||
total_width,
|
||||
|
|
|
|||
Loading…
Reference in New Issue