intersections: implement a PartialEq that handles floats.
This commit is contained in:
parent
a553786807
commit
952ed8bf81
@ -7,11 +7,16 @@ use crate::{
|
|||||||
Float, EPSILON,
|
Float, EPSILON,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct Intersection<'i> {
|
pub struct Intersection<'i> {
|
||||||
pub t: Float,
|
pub t: Float,
|
||||||
pub object: &'i Shape,
|
pub object: &'i Shape,
|
||||||
}
|
}
|
||||||
|
impl<'i> PartialEq for Intersection<'i> {
|
||||||
|
fn eq(&self, rhs: &Intersection) -> bool {
|
||||||
|
((self.t - rhs.t).abs() < EPSILON) && (self.object == rhs.object)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<'i> Intersection<'i> {
|
impl<'i> Intersection<'i> {
|
||||||
/// Create new `Intersection` at the given `t` that hits the given `object`.
|
/// Create new `Intersection` at the given `t` that hits the given `object`.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user