Finish up clippy lint.
This commit is contained in:
parent
e64e6af085
commit
0ec6f46be0
@ -42,7 +42,7 @@ impl fmt::Display for BVHNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Lint is wrong when dealing with Box<Trait>
|
// Lint is wrong when dealing with Box<Trait>
|
||||||
#[cfg_attr(feature = "cargo-clippy", allow(borrowed_box))]
|
#[allow(clippy::borrowed_box)]
|
||||||
fn box_x_compare(ah: &Box<Hit>, bh: &Box<Hit>) -> std::cmp::Ordering {
|
fn box_x_compare(ah: &Box<Hit>, bh: &Box<Hit>) -> std::cmp::Ordering {
|
||||||
match (ah.bounding_box(0., 0.), bh.bounding_box(0., 0.)) {
|
match (ah.bounding_box(0., 0.), bh.bounding_box(0., 0.)) {
|
||||||
(Some(box_left), Some(box_right)) => {
|
(Some(box_left), Some(box_right)) => {
|
||||||
@ -52,7 +52,7 @@ fn box_x_compare(ah: &Box<Hit>, bh: &Box<Hit>) -> std::cmp::Ordering {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(feature = "cargo-clippy", allow(borrowed_box))]
|
#[allow(clippy::borrowed_box)]
|
||||||
fn box_y_compare(ah: &Box<Hit>, bh: &Box<Hit>) -> std::cmp::Ordering {
|
fn box_y_compare(ah: &Box<Hit>, bh: &Box<Hit>) -> std::cmp::Ordering {
|
||||||
match (ah.bounding_box(0., 0.), bh.bounding_box(0., 0.)) {
|
match (ah.bounding_box(0., 0.), bh.bounding_box(0., 0.)) {
|
||||||
(Some(box_left), Some(box_right)) => {
|
(Some(box_left), Some(box_right)) => {
|
||||||
@ -62,7 +62,7 @@ fn box_y_compare(ah: &Box<Hit>, bh: &Box<Hit>) -> std::cmp::Ordering {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(feature = "cargo-clippy", allow(borrowed_box))]
|
#[allow(clippy::borrowed_box)]
|
||||||
fn box_z_compare(ah: &Box<Hit>, bh: &Box<Hit>) -> std::cmp::Ordering {
|
fn box_z_compare(ah: &Box<Hit>, bh: &Box<Hit>) -> std::cmp::Ordering {
|
||||||
match (ah.bounding_box(0., 0.), bh.bounding_box(0., 0.)) {
|
match (ah.bounding_box(0., 0.), bh.bounding_box(0., 0.)) {
|
||||||
(Some(box_left), Some(box_right)) => {
|
(Some(box_left), Some(box_right)) => {
|
||||||
@ -153,11 +153,13 @@ impl Hit for BVHNode {
|
|||||||
Some(ref bbox) => {
|
Some(ref bbox) => {
|
||||||
if bbox.hit(r, t_min, t_max) {
|
if bbox.hit(r, t_min, t_max) {
|
||||||
match (left.hit(r, t_min, t_max), right.hit(r, t_min, t_max)) {
|
match (left.hit(r, t_min, t_max), right.hit(r, t_min, t_max)) {
|
||||||
(Some(hit_left), Some(hit_right)) => if hit_left.t < hit_right.t {
|
(Some(hit_left), Some(hit_right)) => {
|
||||||
Some(hit_left)
|
if hit_left.t < hit_right.t {
|
||||||
} else {
|
Some(hit_left)
|
||||||
Some(hit_right)
|
} else {
|
||||||
},
|
Some(hit_right)
|
||||||
|
}
|
||||||
|
}
|
||||||
(Some(hit_left), None) => Some(hit_left),
|
(Some(hit_left), None) => Some(hit_left),
|
||||||
(None, Some(hit_right)) => Some(hit_right),
|
(None, Some(hit_right)) => Some(hit_right),
|
||||||
(None, None) => None,
|
(None, None) => None,
|
||||||
|
|||||||
@ -11,11 +11,12 @@ fn random_in_unit_disk() -> Vec3 {
|
|||||||
let mut rng = rand::thread_rng();
|
let mut rng = rand::thread_rng();
|
||||||
let v = Vec3::new(1., 1., 0.);
|
let v = Vec3::new(1., 1., 0.);
|
||||||
loop {
|
loop {
|
||||||
let p = 2. * Vec3::new(
|
let p =
|
||||||
rng.gen_range::<f32>(0., 1.),
|
2. * Vec3::new(
|
||||||
rng.gen_range::<f32>(0., 1.),
|
rng.gen_range::<f32>(0., 1.),
|
||||||
0.,
|
rng.gen_range::<f32>(0., 1.),
|
||||||
) - v;
|
0.,
|
||||||
|
) - v;
|
||||||
if p.squared_length() < 1. {
|
if p.squared_length() < 1. {
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
@ -36,7 +37,7 @@ pub struct Camera {
|
|||||||
|
|
||||||
impl Camera {
|
impl Camera {
|
||||||
// Parameters match the example C++ code.
|
// Parameters match the example C++ code.
|
||||||
#[cfg_attr(feature = "cargo-clippy", allow(too_many_arguments))]
|
#[allow(clippy::too_many_arguments)]
|
||||||
// vfov is top to bottom in degrees
|
// vfov is top to bottom in degrees
|
||||||
pub fn new(
|
pub fn new(
|
||||||
lookfrom: Vec3,
|
lookfrom: Vec3,
|
||||||
|
|||||||
@ -20,7 +20,7 @@ pub struct Cuboid {
|
|||||||
|
|
||||||
impl Cuboid {
|
impl Cuboid {
|
||||||
// This clippy doesn't work right with Arc.
|
// This clippy doesn't work right with Arc.
|
||||||
#[cfg_attr(feature = "cargo-clippy", allow(needless_pass_by_value))]
|
#[allow(clippy::needless_pass_by_value)]
|
||||||
pub fn new(p_min: Vec3, p_max: Vec3, material: Arc<Material>) -> Cuboid {
|
pub fn new(p_min: Vec3, p_max: Vec3, material: Arc<Material>) -> Cuboid {
|
||||||
Cuboid {
|
Cuboid {
|
||||||
p_min,
|
p_min,
|
||||||
|
|||||||
@ -17,7 +17,7 @@ impl Lode {
|
|||||||
{
|
{
|
||||||
let mut noise = vec![vec![vec![0.; NOISE_SIZE]; NOISE_SIZE]; NOISE_SIZE];
|
let mut noise = vec![vec![vec![0.; NOISE_SIZE]; NOISE_SIZE]; NOISE_SIZE];
|
||||||
// Squelch warning about only being used to index, as this way reads more consistently.
|
// Squelch warning about only being used to index, as this way reads more consistently.
|
||||||
#[cfg_attr(feature = "cargo-clippy", allow(needless_range_loop))]
|
#[allow(clippy::needless_range_loop)]
|
||||||
for x in 0..NOISE_SIZE {
|
for x in 0..NOISE_SIZE {
|
||||||
for y in 0..NOISE_SIZE {
|
for y in 0..NOISE_SIZE {
|
||||||
for z in 0..NOISE_SIZE {
|
for z in 0..NOISE_SIZE {
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
// There are many math functions in this file, so we allow single letter variable names.
|
// There are many math functions in this file, so we allow single letter variable names.
|
||||||
#![cfg_attr(feature = "cargo-clippy", allow(many_single_char_names))]
|
#![allow(clippy::many_single_char_names)]
|
||||||
use rand::Rng;
|
use rand::Rng;
|
||||||
|
|
||||||
use crate::noise::NoiseSource;
|
use crate::noise::NoiseSource;
|
||||||
@ -23,8 +23,10 @@ where
|
|||||||
rng.gen_range::<f32>(-1., 1.),
|
rng.gen_range::<f32>(-1., 1.),
|
||||||
rng.gen_range::<f32>(-1., 1.),
|
rng.gen_range::<f32>(-1., 1.),
|
||||||
rng.gen_range::<f32>(-1., 1.),
|
rng.gen_range::<f32>(-1., 1.),
|
||||||
).unit_vector()
|
)
|
||||||
}).collect()
|
.unit_vector()
|
||||||
|
})
|
||||||
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn perlin_generate_perm<R>(rng: &mut R) -> Vec<usize>
|
fn perlin_generate_perm<R>(rng: &mut R) -> Vec<usize>
|
||||||
@ -134,13 +136,13 @@ impl NoiseSource for Perlin {
|
|||||||
let mut c: [[[Vec3; 2]; 2]; 2] = Default::default();
|
let mut c: [[[Vec3; 2]; 2]; 2] = Default::default();
|
||||||
|
|
||||||
// Squelch warning about di only being used to index, as this way reads more consistently.
|
// Squelch warning about di only being used to index, as this way reads more consistently.
|
||||||
#[cfg_attr(feature = "cargo-clippy", allow(needless_range_loop))]
|
#[allow(clippy::needless_range_loop)]
|
||||||
for di in 0..2 {
|
for di in 0..2 {
|
||||||
for dj in 0..2 {
|
for dj in 0..2 {
|
||||||
for dk in 0..2 {
|
for dk in 0..2 {
|
||||||
c[di][dj][dk] = self.ran_vec[self.perm_x[(i + di) & 255]
|
c[di][dj][dk] = self.ran_vec[self.perm_x[(i + di) & 255]
|
||||||
^ self.perm_y[(j + dj) & 255]
|
^ self.perm_y[(j + dj) & 255]
|
||||||
^ self.perm_z[(k + dk) & 255]]
|
^ self.perm_z[(k + dk) & 255]]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
// There are many math functions in this file, so we allow single letter variable names.
|
// There are many math functions in this file, so we allow single letter variable names.
|
||||||
#![cfg_attr(feature = "cargo-clippy", allow(many_single_char_names))]
|
#![allow(clippy::many_single_char_names)]
|
||||||
use crate::aabb::AABB;
|
use crate::aabb::AABB;
|
||||||
use crate::hitable::Hit;
|
use crate::hitable::Hit;
|
||||||
use crate::hitable::HitRecord;
|
use crate::hitable::HitRecord;
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
#![allow(clippy::many_single_char_names)]
|
||||||
use rand;
|
use rand;
|
||||||
use rand::Rng;
|
use rand::Rng;
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user