Functional tracer

This commit is contained in:
numzero 2024-05-27 19:16:59 +03:00
parent 716fe65841
commit a82441677d

View File

@ -116,13 +116,9 @@ impl Space {
fn trace_boundary(&self, ray: Ray) -> Ray { fn trace_boundary(&self, ray: Ray) -> Ray {
assert_eq!(self.which_subspace(ray.pos), Boundary); assert_eq!(self.which_subspace(ray.pos), Boundary);
let mut ray = ray; std::iter::successors(Some(ray), |&ray| Some(self.trace_step(ray)))
loop { .find(|&ray| self.which_subspace(ray.pos) != Boundary)
ray = self.trace_step(ray); .expect("Can't get outta the wall!")
if self.which_subspace(ray.pos) != Boundary {
break ray;
}
}
} }
} }