diff options
Diffstat (limited to 'src/hittable/instance/translate.rs')
-rw-r--r-- | src/hittable/instance/translate.rs | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/hittable/instance/translate.rs b/src/hittable/instance/translate.rs index a9c8162..8478bd4 100644 --- a/src/hittable/instance/translate.rs +++ b/src/hittable/instance/translate.rs @@ -1,6 +1,10 @@ use std::sync::Arc; -use crate::{hittable::{HitRecord, Hittable, AABB}, ray::Ray, vec3::Vec3}; +use crate::{ + hittable::{HitRecord, Hittable, AABB}, + ray::Ray, + vec3::Vec3, +}; pub struct Translate { pub hittable: Arc<dyn Hittable>, @@ -9,7 +13,11 @@ pub struct Translate { impl Hittable for Translate { fn hit(&self, ray: &Ray, t_min: f64, t_max: f64) -> Option<HitRecord> { - let moved_ray = Ray { origin: &ray.origin - &self.offset, direction: ray.direction.clone(), time: ray.time }; + let moved_ray = Ray { + origin: &ray.origin - &self.offset, + direction: ray.direction.clone(), + time: ray.time, + }; let mut hit_record = self.hittable.hit(&moved_ray, t_min, t_max)?; hit_record.p += self.offset.clone(); let normal = hit_record.normal.clone(); |