diff --git a/src/bin/flat/tube/mod.rs b/src/bin/flat/tube/mod.rs index 3c36a87..7b5ae03 100644 --- a/src/bin/flat/tube/mod.rs +++ b/src/bin/flat/tube/mod.rs @@ -153,6 +153,14 @@ impl Space { Boundary => panic!("Can't draw a line here!"), } } + + fn camera_ray_to_abs(&self, camera: Location, ray: Ray) -> Ray { + let pos = camera.pos; + let dir = camera.rot * ray.dir; + // TODO account for ray.pos + let dir = DT * self.tube.normalize_vec_at(pos, dir); + Ray { pos, dir } + } } impl Traceable for Space { @@ -165,11 +173,7 @@ impl DebugTraceable for Space { fn trace_dbg(&self, camera: Location, ray: Ray) -> (Vec, RayPath) { let mut points = vec![]; let mut hits = vec![]; - let mut ray = Ray { - pos: camera.pos, - dir: camera.rot * ray.dir, - }; // TODO account for ray.pos - ray.dir = self.tube.normalize_vec_at(ray.pos, ray.dir) * DT; + let mut ray = self.camera_ray_to_abs(camera, ray); let trace_to_flat = |points: &mut Vec, ray| { for ray in self.trace_iter(ray).skip(1) {