Extract boundary tracing into a function
This commit is contained in:
parent
241f070769
commit
4b12fcf045
|
|
@ -9,6 +9,7 @@ use tube::metric::Tube;
|
||||||
use tube::Space;
|
use tube::Space;
|
||||||
use tube::Subspace::{Boundary, Inner, Outer};
|
use tube::Subspace::{Boundary, Inner, Outer};
|
||||||
use types::{Location, Object, Ray};
|
use types::{Location, Object, Ray};
|
||||||
|
use crate::types::FlatTraceResult;
|
||||||
|
|
||||||
mod riemann;
|
mod riemann;
|
||||||
mod fns;
|
mod fns;
|
||||||
|
|
@ -107,23 +108,26 @@ pub fn main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn draw_ray_2(gc: &mut Vec<Draw>, space: &Space, base: Vec2, dir: Vec2) {
|
fn draw_ray_2(gc: &mut Vec<Draw>, space: &Space, base: Vec2, dir: Vec2) {
|
||||||
|
fn trace_to_flat(gc: &mut Vec<Draw>, space: &Space, ray: Ray) -> (Ray, FlatTraceResult) {
|
||||||
|
for ray in space.trace_iter(ray).skip(1) {
|
||||||
|
gc.line_to(ray.pos.x, ray.pos.y);
|
||||||
|
match space.which_subspace(ray.pos) {
|
||||||
|
Inner => return (ray, space.trace_inner(ray)),
|
||||||
|
Outer => return (ray, space.trace_outer(ray)),
|
||||||
|
Boundary => continue,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
unreachable!("Space::trace_iter terminated!")
|
||||||
|
}
|
||||||
|
|
||||||
let mut hits = Vec::<Draw>::new();
|
let mut hits = Vec::<Draw>::new();
|
||||||
let dir = space.tube.globalize(base, dir);
|
let dir = space.tube.globalize(base, dir);
|
||||||
gc.new_path();
|
gc.new_path();
|
||||||
gc.move_to(base.x, base.y);
|
gc.move_to(base.x, base.y);
|
||||||
let mut ray = Ray { pos: base, dir: space.tube.normalize_vec_at(base, dir) * DT };
|
let mut ray = Ray { pos: base, dir: space.tube.normalize_vec_at(base, dir) * DT };
|
||||||
for _ in 0..10000 {
|
for _ in 0..100 {
|
||||||
ray = space.trace_step(ray);
|
let ret;
|
||||||
gc.line_to(ray.pos.x, ray.pos.y);
|
(ray, ret) = trace_to_flat(gc, space, ray);
|
||||||
if ray.pos.abs().cmpgt(Vec2::splat(1000.0)).any() {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
let sub = space.which_subspace(ray.pos);
|
|
||||||
let ret = match sub {
|
|
||||||
Inner => space.trace_inner(ray),
|
|
||||||
Outer => space.trace_outer(ray),
|
|
||||||
Boundary => continue,
|
|
||||||
};
|
|
||||||
gc.stroke();
|
gc.stroke();
|
||||||
gc.new_dash_pattern();
|
gc.new_dash_pattern();
|
||||||
// gc.dash_length(6.0);
|
// gc.dash_length(6.0);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user