aboutsummaryrefslogtreecommitdiff
path: root/src/hittable/xz_rect.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/xz_rect.rs
parent89a5c9a8a0cdf627cda0e31da454f83ca21315ce (diff)
fmt and tidy
Diffstat (limited to 'src/hittable/xz_rect.rs')
-rw-r--r--src/hittable/xz_rect.rs31
1 files changed, 27 insertions, 4 deletions
diff --git a/src/hittable/xz_rect.rs b/src/hittable/xz_rect.rs
index 4761f36..c990de5 100644
--- a/src/hittable/xz_rect.rs
+++ b/src/hittable/xz_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 XZRect {
pub material: Arc<dyn Material>,
@@ -13,7 +18,10 @@ pub struct XZRect {
impl XZRect {
fn has_infinite_bounds(&self) -> bool {
- self.x0.is_infinite() || self.x1.is_infinite() || self.z0.is_infinite() || self.z1.is_infinite()
+ self.x0.is_infinite()
+ || self.x1.is_infinite()
+ || self.z0.is_infinite()
+ || self.z1.is_infinite()
}
}
@@ -32,7 +40,11 @@ impl Hittable for XZRect {
hit_record.u = (x - self.x0) / (self.x1 - self.x0);
hit_record.v = (z - self.z0) / (self.z1 - self.z0);
hit_record.t = t;
- let outward_normal = Vec3 { x: 0.0, y: 1.0, z: 0.0 };
+ let outward_normal = Vec3 {
+ x: 0.0,
+ y: 1.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 XZRect {
fn bounding_box(&self, _: f64, _: f64) -> Option<AABB> {
match self.has_infinite_bounds() {
true => None,
- false => Some(AABB { minimum: Point3 { x: self.x0, y: self.k - 0.0001, z: self.z0 }, maximum: Point3 { x: self.x1, y: self.k + 0.0001, z: self.z1 } }),
+ false => Some(AABB {
+ minimum: Point3 {
+ x: self.x0,
+ y: self.k - 0.0001,
+ z: self.z0,
+ },
+ maximum: Point3 {
+ x: self.x1,
+ y: self.k + 0.0001,
+ z: self.z1,
+ },
+ }),
}
}
}