Keep limit as an Option one level deeper
This commit is contained in:
parent
b5c57babb4
commit
c2922d5fe1
|
|
@ -71,7 +71,7 @@ impl Space {
|
|||
let dist = inner.trace_out_of(ray).expect("Can't get outta here!");
|
||||
FlatTraceResult {
|
||||
end: Some(self.tube.inner_to_global(ray.forward(dist))),
|
||||
objects: Self::hit_objects(objs.as_slice(), ray, dist, |pos| self.tube.inner_to_global(pos)),
|
||||
objects: Self::hit_objects(objs.as_slice(), ray, Some(dist), |pos| self.tube.inner_to_global(pos)),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -80,10 +80,9 @@ impl Space {
|
|||
let cell = Rect { size: vec2(self.tube.outer_radius, self.tube.external_halflength) };
|
||||
let objs = self.list_objects_outer();
|
||||
let lim = cell.trace_into(ray);
|
||||
let dist = lim.unwrap_or(f32::INFINITY);
|
||||
FlatTraceResult {
|
||||
end: lim.map(|dist| ray.forward(dist)),
|
||||
objects: Self::hit_objects(objs.as_slice(), ray, dist, |pos| pos),
|
||||
objects: Self::hit_objects(objs.as_slice(), ray, lim, |pos| pos),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -114,7 +113,8 @@ impl Space {
|
|||
})
|
||||
}
|
||||
|
||||
fn hit_objects(objs: &[Object], ray: Ray, limit: f32, globalize: impl Fn(Vec2) -> Vec2) -> Vec<Hit> {
|
||||
fn hit_objects(objs: &[Object], ray: Ray, limit: Option<f32>, globalize: impl Fn(Vec2) -> Vec2) -> Vec<Hit> {
|
||||
let limit = limit.unwrap_or(f32::INFINITY);
|
||||
objs.iter()
|
||||
.filter_map(|obj| {
|
||||
let rel = ray.pos - obj.loc.pos;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user