rtiow: AABB more compact Debug representation. Loosen assertions.
This commit is contained in:
parent
6ab3021403
commit
f7c5f29e67
@ -2,7 +2,7 @@ use std::fmt;
|
|||||||
|
|
||||||
use crate::{ray::Ray, vec3::Vec3};
|
use crate::{ray::Ray, vec3::Vec3};
|
||||||
|
|
||||||
#[derive(Default, Debug, Copy, Clone, PartialEq)]
|
#[derive(Default, Copy, Clone, PartialEq)]
|
||||||
pub struct AABB {
|
pub struct AABB {
|
||||||
bounds: [Vec3; 2],
|
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 {
|
impl AABB {
|
||||||
pub fn new<V: Into<Vec3>>(min: V, max: V) -> AABB {
|
pub fn new<V: Into<Vec3>>(min: V, max: V) -> AABB {
|
||||||
let min: Vec3 = min.into();
|
let min: Vec3 = min.into();
|
||||||
let max: Vec3 = max.into();
|
let max: Vec3 = max.into();
|
||||||
assert!(min.x < max.x);
|
assert!(min.x <= max.x);
|
||||||
assert!(min.y < max.y);
|
assert!(min.y <= max.y);
|
||||||
assert!(min.z < max.z);
|
assert!(min.z <= max.z);
|
||||||
AABB { bounds: [min, max] }
|
AABB { bounds: [min, max] }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user