diff options
author | lamp | 2024-01-21 17:03:07 +0000 |
---|---|---|
committer | lamp | 2024-01-21 17:03:07 +0000 |
commit | 45fafbcd4b41a5388ece377c4e051b5846407288 (patch) | |
tree | 2192c471ca3b47671f0906e27f6f6088f40b3d8a /src/material/metal.rs | |
parent | 89a5c9a8a0cdf627cda0e31da454f83ca21315ce (diff) |
fmt and tidy
Diffstat (limited to 'src/material/metal.rs')
-rw-r--r-- | src/material/metal.rs | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/material/metal.rs b/src/material/metal.rs index 2865a2f..638e5e4 100644 --- a/src/material/metal.rs +++ b/src/material/metal.rs @@ -1,7 +1,7 @@ use super::Material; -use crate::{hittable::HitRecord, vec3::Vec3}; -use crate::vec3::Color; use crate::ray::Ray; +use crate::vec3::Color; +use crate::{hittable::HitRecord, vec3::Vec3}; pub struct Metal { pub albedo: Color, @@ -9,9 +9,19 @@ pub struct Metal { } impl Material for Metal { - fn scatter(&self, ray_in: &Ray, hit_record: &HitRecord, attenuation: &mut Color, scattered: &mut Ray) -> bool { + fn scatter( + &self, + ray_in: &Ray, + hit_record: &HitRecord, + attenuation: &mut Color, + scattered: &mut Ray, + ) -> bool { let reflected = ray_in.direction.unit_vector().reflect(&hit_record.normal); - *scattered = Ray { origin: hit_record.p.clone(), direction: reflected + self.fuzz * Vec3::random_in_unit_sphere(), time: ray_in.time }; + *scattered = Ray { + origin: hit_record.p.clone(), + direction: reflected + self.fuzz * Vec3::random_in_unit_sphere(), + time: ray_in.time, + }; *attenuation = self.albedo.clone(); scattered.direction.dot(&hit_record.normal) > 0.0 } |