Skip to content

Commit 4cc4a3f

Browse files
committed
[*] Fix clippy warnings.
1 parent ab31f46 commit 4cc4a3f

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/structs/material.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ impl Material {
2626

2727
pub fn scatter<R: Rng>(&self, r: &Ray, hit_record: &HitRecord, rng: &mut R) -> Option<Ray> {
2828
match self {
29-
Material::Lambertian(lamb) => lamb.scatter(r, hit_record, rng),
29+
Material::Lambertian(lamb) => Some(lamb.scatter(r, hit_record, rng)),
3030
Material::Metal(met) => met.scatter(r, hit_record, rng),
31-
Material::Dielectric(diel) => diel.scatter(r, hit_record, rng),
31+
Material::Dielectric(diel) => Some(diel.scatter(r, hit_record, rng)),
3232
}
3333
}
3434

@@ -47,11 +47,11 @@ pub struct Lambertian {
4747
}
4848

4949
impl Lambertian {
50-
fn scatter<R: Rng>(&self, _r: &Ray, hit_record: &HitRecord, rng: &mut R) -> Option<Ray> {
50+
fn scatter<R: Rng>(&self, _r: &Ray, hit_record: &HitRecord, rng: &mut R) -> Ray {
5151
let scatter_dir =
5252
hit_record.out_normal + Vec3::random_in_hemisphere(&hit_record.out_normal, rng);
5353

54-
Some(Ray::new(hit_record.hit_point, scatter_dir))
54+
Ray::new(hit_record.hit_point, scatter_dir)
5555
}
5656

5757
fn attenuation(&self) -> Vec3 {
@@ -93,7 +93,7 @@ pub struct Dielectric {
9393
}
9494

9595
impl Dielectric {
96-
fn scatter<R: Rng>(&self, r: &Ray, hit_record: &HitRecord, rng: &mut R) -> Option<Ray> {
96+
fn scatter<R: Rng>(&self, r: &Ray, hit_record: &HitRecord, rng: &mut R) -> Ray {
9797
let reflect = |v: &Vec3, norm: &Vec3| -> Vec3 { v - 2. * Vec3::dot(v, norm) * norm };
9898
let refraction_ratio = if hit_record.front_face {
9999
1. / self.refraction
@@ -114,7 +114,7 @@ impl Dielectric {
114114
self.refract(&unit_dir, &hit_record.out_normal, refraction_ratio)
115115
};
116116

117-
Some(Ray::new(hit_record.hit_point, direction))
117+
Ray::new(hit_record.hit_point, direction)
118118
}
119119

120120
fn refract(&self, uv: &Vec3, n: &Vec3, eta: f64) -> Vec3 {

src/structs/sphere.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ impl Hitable for Sphere {
2525
let a = Vec3::dot(&r.direction(), &r.direction());
2626
let b = Vec3::dot(&oc, &r.direction());
2727
let c = Vec3::dot(&oc, &oc) - self.radius * self.radius;
28-
let discr = b * b - a * c;
28+
let discr = b.powf(2f64) - a * c;
2929
if discr > 0. {
3030
let root = (-b - discr.sqrt()) / a;
3131
if root > t_min && root < t_max {

0 commit comments

Comments
 (0)