Remove redundant code
This commit is contained in:
parent
c49a3ea241
commit
0cf6b5b1fb
|
|
@ -67,8 +67,8 @@ impl Space {
|
||||||
let inner = Rect { size: vec2(self.tube.inner_radius, self.tube.internal_halflength) };
|
let inner = Rect { size: vec2(self.tube.inner_radius, self.tube.internal_halflength) };
|
||||||
let ray = self.tube.global_to_inner(ray);
|
let ray = self.tube.global_to_inner(ray);
|
||||||
assert!(inner.is_inside(ray.pos));
|
assert!(inner.is_inside(ray.pos));
|
||||||
let objs = self.list_objects_inner();
|
|
||||||
let dist = inner.trace_out_of(ray).expect("Can't get outta here!");
|
let dist = inner.trace_out_of(ray).expect("Can't get outta here!");
|
||||||
|
let objs = self.list_objects(|loc| self.tube.global_to_inner(loc));
|
||||||
FlatTraceResult {
|
FlatTraceResult {
|
||||||
end: Some(self.tube.inner_to_global(ray.forward(dist))),
|
end: Some(self.tube.inner_to_global(ray.forward(dist))),
|
||||||
objects: Self::hit_objects(objs.as_slice(), ray, Some(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)),
|
||||||
|
|
@ -77,12 +77,12 @@ impl Space {
|
||||||
|
|
||||||
pub fn trace_outer(&self, ray: Ray) -> FlatTraceResult {
|
pub fn trace_outer(&self, ray: Ray) -> FlatTraceResult {
|
||||||
assert_eq!(self.which_subspace(ray.pos), Outer);
|
assert_eq!(self.which_subspace(ray.pos), Outer);
|
||||||
let cell = Rect { size: vec2(self.tube.outer_radius, self.tube.external_halflength) };
|
let outer = Rect { size: vec2(self.tube.outer_radius, self.tube.external_halflength) };
|
||||||
let objs = self.list_objects_outer();
|
let dist = outer.trace_into(ray);
|
||||||
let lim = cell.trace_into(ray);
|
let objs = self.list_objects(|loc| self.tube.global_to_outer(loc));
|
||||||
FlatTraceResult {
|
FlatTraceResult {
|
||||||
end: lim.map(|dist| ray.forward(dist)),
|
end: dist.map(|dist| ray.forward(dist)),
|
||||||
objects: Self::hit_objects(objs.as_slice(), ray, lim, |pos| pos),
|
objects: Self::hit_objects(objs.as_slice(), ray, dist, |pos| pos),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -97,22 +97,6 @@ impl Space {
|
||||||
self.objs.iter().map(|&Object { id, loc, r }| Object { id, loc: tfm(loc), r }).collect()
|
self.objs.iter().map(|&Object { id, loc, r }| Object { id, loc: tfm(loc), r }).collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn list_objects_outer(&self) -> Vec<Object> {
|
|
||||||
self.list_objects(|loc|
|
|
||||||
match self.which_subspace(loc.pos) {
|
|
||||||
Inner | Outer => self.tube.global_to_outer(loc),
|
|
||||||
Boundary => panic!("Object at {} was destroyed by the space curvature", loc.pos),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
fn list_objects_inner(&self) -> Vec<Object> {
|
|
||||||
self.list_objects(|loc|
|
|
||||||
match self.which_subspace(loc.pos) {
|
|
||||||
Inner | Outer => self.tube.global_to_inner(loc),
|
|
||||||
Boundary => panic!("Object at {} was destroyed by the space curvature", loc.pos),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
fn hit_objects(objs: &[Object], ray: Ray, limit: Option<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);
|
let limit = limit.unwrap_or(f32::INFINITY);
|
||||||
objs.iter()
|
objs.iter()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user