Run fixes recommended by cargo-clippy

This commit is contained in:
2025-08-19 18:26:41 -05:00
parent fcb9ad2dd2
commit 46f6784256
3 changed files with 11 additions and 11 deletions

View File

@@ -176,7 +176,7 @@ impl Vec3 {
}
pub fn rand_unit_vector(srng: &mut SmallRng) -> Vec3 {
return Vec3::as_unit(Vec3::rand_in_unit_sphere(srng));
Vec3::as_unit(Vec3::rand_in_unit_sphere(srng))
}
pub fn length(&self) -> f32 {
@@ -204,11 +204,11 @@ impl Vec3 {
pub fn near_zero(&self) -> bool {
let epsilon: f32 = 1e-4;
return self.x.abs() < epsilon && self.y.abs() < epsilon && self.z.abs() < epsilon;
self.x.abs() < epsilon && self.y.abs() < epsilon && self.z.abs() < epsilon
}
pub fn reflect(v: Vec3, n: Vec3) -> Vec3 {
return v - n * Vec3::dot(v, n) * 2.0;
v - n * Vec3::dot(v, n) * 2.0
}
pub fn refract(uv: Vec3, n: Vec3, etai_over_etat: f32) -> Vec3 {

View File

@@ -50,7 +50,7 @@ fn ray_color(r: Ray, surface: &Hittable, depth: u32, rng: &mut SmallRng) -> Vec3
// when nothing is struck, return sky color
let unitdir = Vec3::as_unit(r.dir);
let t = 0.5 * (unitdir.y + 1.0);
return Vec3::ones() * (1.0 - t) + SKY_COLOR * t;
Vec3::ones() * (1.0 - t) + SKY_COLOR * t
}
}

View File

@@ -13,7 +13,7 @@ pub struct HitRecord {
}
impl HitRecord {
pub fn set_face_normal(&mut self, r: Ray, outward_normal: Vec3) -> () {
pub fn set_face_normal(&mut self, r: Ray, outward_normal: Vec3) {
self.front_face = Vec3::dot(r.dir, outward_normal) < 0.0;
self.normal = if self.front_face {
outward_normal
@@ -129,7 +129,7 @@ impl Material {
dir: scatter_dir,
};
*attenuation = *albedo; // deref on both sides? Wacky
return true;
true
}
Material::Metal { albedo, fuzz } => {
let reflected = Vec3::reflect(Vec3::as_unit(ray_in.dir), rec.normal);
@@ -138,7 +138,7 @@ impl Material {
dir: reflected + Vec3::rand_in_unit_sphere(srng) * *fuzz,
};
*attenuation = *albedo;
return Vec3::dot(scattered.dir, rec.normal) > 0.0;
Vec3::dot(scattered.dir, rec.normal) > 0.0
}
Material::Dielectric { index_refraction } => {
*attenuation = Vec3::ones();
@@ -166,7 +166,7 @@ impl Material {
orig: rec.p,
dir: direction,
};
return true;
true
}
}
}
@@ -175,7 +175,7 @@ impl Material {
// Schlick's approximation for reflectance.
let r0 = (1.0 - ref_idx) / (1.0 + ref_idx);
let r0 = r0 * r0;
return r0 + (1.0 - r0) * (1.0 - cosine).powf(5.0);
r0 + (1.0 - r0) * (1.0 - cosine).powf(5.0)
}
}
@@ -294,7 +294,7 @@ impl Scene {
world.push(Hittable::Sphere {
center,
radius: 0.2,
material: material,
material,
});
} else {
// glass
@@ -304,7 +304,7 @@ impl Scene {
world.push(Hittable::Sphere {
center,
radius: 0.2,
material: material,
material,
});
};
}