diff --git a/rtiow/renderer/src/aabb.rs b/rtiow/renderer/src/aabb.rs index e46c701..9936da3 100644 --- a/rtiow/renderer/src/aabb.rs +++ b/rtiow/renderer/src/aabb.rs @@ -2,7 +2,7 @@ use std::fmt; use crate::{ray::Ray, vec3::Vec3}; -#[derive(Default, Debug, Copy, Clone, PartialEq)] +#[derive(Default, Copy, Clone, PartialEq)] pub struct AABB { bounds: [Vec3; 2], } @@ -29,13 +29,25 @@ fn max(x: f32, y: f32) -> f32 { } } +impl fmt::Debug for AABB { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!( + f, + "AABB: <{} - {}> Vol: {}", + self.bounds[0], + self.bounds[1], + self.volume() + ) + } +} + impl AABB { pub fn new>(min: V, max: V) -> AABB { let min: Vec3 = min.into(); let max: Vec3 = max.into(); - assert!(min.x < max.x); - assert!(min.y < max.y); - assert!(min.z < max.z); + assert!(min.x <= max.x); + assert!(min.y <= max.y); + assert!(min.z <= max.z); AABB { bounds: [min, max] } }