From 45fafbcd4b41a5388ece377c4e051b5846407288 Mon Sep 17 00:00:00 2001 From: lamp Date: Sun, 21 Jan 2024 17:03:07 +0000 Subject: fmt and tidy --- src/hittable/yz_rect.rs | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) (limited to 'src/hittable/yz_rect.rs') diff --git a/src/hittable/yz_rect.rs b/src/hittable/yz_rect.rs index dd90bdb..db068dd 100644 --- a/src/hittable/yz_rect.rs +++ b/src/hittable/yz_rect.rs @@ -1,6 +1,11 @@ use std::sync::Arc; -use crate::{hittable::{HitRecord, Hittable, AABB}, material::Material, ray::Ray, vec3::{Point3, Vec3}}; +use crate::{ + hittable::{HitRecord, Hittable, AABB}, + material::Material, + ray::Ray, + vec3::{Point3, Vec3}, +}; pub struct YZRect { pub material: Arc, @@ -13,7 +18,10 @@ pub struct YZRect { impl YZRect { fn has_infinite_bounds(&self) -> bool { - self.y0.is_infinite() || self.y1.is_infinite() || self.z0.is_infinite() || self.z1.is_infinite() + self.y0.is_infinite() + || self.y1.is_infinite() + || self.z0.is_infinite() + || self.z1.is_infinite() } } @@ -32,7 +40,11 @@ impl Hittable for YZRect { hit_record.u = (y - self.y0) / (self.y1 - self.y0); hit_record.v = (z - self.z0) / (self.z1 - self.z0); hit_record.t = t; - let outward_normal = Vec3 { x: 1.0, y: 0.0, z: 0.0 }; + let outward_normal = Vec3 { + x: 1.0, + y: 0.0, + z: 0.0, + }; hit_record.set_face_normal(ray, &outward_normal); hit_record.material = Some(self.material.clone()); hit_record.p = ray.at(t); @@ -42,7 +54,18 @@ impl Hittable for YZRect { fn bounding_box(&self, _: f64, _: f64) -> Option { match self.has_infinite_bounds() { true => None, - false => Some(AABB { minimum: Point3 { x: self.k - 0.0001, y: self.y0, z: self.z0 }, maximum: Point3 { x: self.k + 0.0001, y: self.y1, z: self.z1 } }), + false => Some(AABB { + minimum: Point3 { + x: self.k - 0.0001, + y: self.y0, + z: self.z0, + }, + maximum: Point3 { + x: self.k + 0.0001, + y: self.y1, + z: self.z1, + }, + }), } } } -- cgit v1.2.3