Pull the distance a level out
This commit is contained in:
parent
2c47c66b60
commit
978138c780
|
|
@ -158,7 +158,8 @@ impl Space {
|
||||||
assert_eq!(self.which_subspace(ray.pos), Inner);
|
assert_eq!(self.which_subspace(ray.pos), Inner);
|
||||||
let cell = RectInside { rect: self.rect };
|
let cell = RectInside { rect: self.rect };
|
||||||
let ray = cell.ray_to_local(ray);
|
let ray = cell.ray_to_local(ray);
|
||||||
let ray = cell.to_boundary(ray).expect("Can't get outta here!");
|
let dist = cell.to_boundary(ray).expect("Can't get outta here!");
|
||||||
|
let ray = Ray { pos: ray.pos + ray.dir * dist, dir: ray.dir };
|
||||||
cell.ray_to_global(ray)
|
cell.ray_to_global(ray)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -412,7 +413,7 @@ trait FlatCell: std::fmt::Debug {
|
||||||
}
|
}
|
||||||
fn local_bounds(&self) -> (Vec2, Vec2);
|
fn local_bounds(&self) -> (Vec2, Vec2);
|
||||||
|
|
||||||
fn to_boundary(&self, ray: Ray) -> Option<Ray> {
|
fn to_boundary(&self, ray: Ray) -> Option<f32> {
|
||||||
assert!(self.is_inside(ray.pos));
|
assert!(self.is_inside(ray.pos));
|
||||||
let sgn = ray.dir.signum();
|
let sgn = ray.dir.signum();
|
||||||
let p = ray.pos * sgn;
|
let p = ray.pos * sgn;
|
||||||
|
|
@ -430,7 +431,7 @@ trait FlatCell: std::fmt::Debug {
|
||||||
(bnd.1.y - p.y) / v.y
|
(bnd.1.y - p.y) / v.y
|
||||||
};
|
};
|
||||||
if t <= 100000.0 {
|
if t <= 100000.0 {
|
||||||
Some(Ray { pos: sgn * (p + v * t), dir: sgn * v })
|
Some(t)
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user