aboutsummaryrefslogtreecommitdiff
path: root/src/hittable/instance/translate.rs
diff options
context:
space:
mode:
authorlamp2024-01-21 17:03:07 +0000
committerlamp2024-01-21 17:03:07 +0000
commit45fafbcd4b41a5388ece377c4e051b5846407288 (patch)
tree2192c471ca3b47671f0906e27f6f6088f40b3d8a /src/hittable/instance/translate.rs
parent89a5c9a8a0cdf627cda0e31da454f83ca21315ce (diff)
fmt and tidy
Diffstat (limited to 'src/hittable/instance/translate.rs')
-rw-r--r--src/hittable/instance/translate.rs12
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();