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/hittable/hittable_box.rs | |
parent | 89a5c9a8a0cdf627cda0e31da454f83ca21315ce (diff) |
fmt and tidy
Diffstat (limited to 'src/hittable/hittable_box.rs')
-rw-r--r-- | src/hittable/hittable_box.rs | 75 |
1 files changed, 62 insertions, 13 deletions
diff --git a/src/hittable/hittable_box.rs b/src/hittable/hittable_box.rs index 7b95cc7..9631635 100644 --- a/src/hittable/hittable_box.rs +++ b/src/hittable/hittable_box.rs @@ -1,6 +1,14 @@ use std::sync::Arc; -use crate::{hittable::{HitRecord, Hittable, AABB, hittable_list::HittableList, xy_rect::XYRect, xz_rect::XZRect, yz_rect::YZRect}, material::Material, ray::Ray, vec3::Point3}; +use crate::{ + hittable::{ + hittable_list::HittableList, xy_rect::XYRect, xz_rect::XZRect, yz_rect::YZRect, HitRecord, + Hittable, AABB, + }, + material::Material, + ray::Ray, + vec3::Point3, +}; pub struct HittableBox { min: Point3, @@ -12,20 +20,58 @@ impl HittableBox { pub fn new(min: Point3, max: Point3, material: Arc<dyn Material>) -> Self { let mut sides = HittableList::new(); - sides.add(Arc::new(XYRect { material: material.clone(), x0: min.x, x1: max.x, y0: min.y, y1: max.y, k: max.z })); - sides.add(Arc::new(XYRect { material: material.clone(), x0: min.x, x1: max.x, y0: min.y, y1: max.y, k: min.z })); + sides.add(Arc::new(XYRect { + material: material.clone(), + x0: min.x, + x1: max.x, + y0: min.y, + y1: max.y, + k: max.z, + })); + sides.add(Arc::new(XYRect { + material: material.clone(), + x0: min.x, + x1: max.x, + y0: min.y, + y1: max.y, + k: min.z, + })); - sides.add(Arc::new(XZRect { material: material.clone(), x0: min.x, x1: max.x, z0: min.z, z1: max.z, k: max.y })); - sides.add(Arc::new(XZRect { material: material.clone(), x0: min.x, x1: max.x, z0: min.z, z1: max.z, k: min.y })); + sides.add(Arc::new(XZRect { + material: material.clone(), + x0: min.x, + x1: max.x, + z0: min.z, + z1: max.z, + k: max.y, + })); + sides.add(Arc::new(XZRect { + material: material.clone(), + x0: min.x, + x1: max.x, + z0: min.z, + z1: max.z, + k: min.y, + })); - sides.add(Arc::new(YZRect { material: material.clone(), y0: min.y, y1: max.y, z0: min.z, z1: max.z, k: max.x })); - sides.add(Arc::new(YZRect { material: material.clone(), y0: min.y, y1: max.y, z0: min.z, z1: max.z, k: min.x })); + sides.add(Arc::new(YZRect { + material: material.clone(), + y0: min.y, + y1: max.y, + z0: min.z, + z1: max.z, + k: max.x, + })); + sides.add(Arc::new(YZRect { + material: material.clone(), + y0: min.y, + y1: max.y, + z0: min.z, + z1: max.z, + k: min.x, + })); - Self { - min, - max, - sides, - } + Self { min, max, sides } } } @@ -35,6 +81,9 @@ impl Hittable for HittableBox { } fn bounding_box(&self, _: f64, _: f64) -> Option<AABB> { - Some(AABB { minimum: self.min.clone(), maximum: self.max.clone() }) + Some(AABB { + minimum: self.min.clone(), + maximum: self.max.clone(), + }) } } |