Nicer
This commit is contained in:
parent
1cf2518568
commit
33c51e425b
|
|
@ -51,7 +51,7 @@ struct Space {
|
|||
rect: Rect,
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Eq)]
|
||||
#[derive(PartialEq, Eq, Debug)]
|
||||
enum Subspace {
|
||||
Outer,
|
||||
Boundary,
|
||||
|
|
@ -101,13 +101,10 @@ fn draw_ray_2(gc: &mut Vec<Draw>, space: &Space, base: Vec2, dir: Vec2) {
|
|||
let dir = space.rect.globalize(base, dir);
|
||||
gc.new_path();
|
||||
gc.move_to(base.x, base.y);
|
||||
let dt = DT;
|
||||
let mut p = base;
|
||||
let mut v = space.rect.normalize_vec_at(base, dir);
|
||||
for _ in 0..10000 {
|
||||
let a: Vec2 = -riemann::contract2(riemann::krist(&space.rect, p), v);
|
||||
v = v + a * dt;
|
||||
p = p + v * dt;
|
||||
Ray { pos: p, dir: v } = space.trace_step(Ray { pos: p, dir: v });
|
||||
gc.line_to(p.x, p.y);
|
||||
if p.abs().cmpgt(Vec2::splat(1000.0)).any() {
|
||||
break;
|
||||
|
|
@ -125,9 +122,7 @@ fn draw_ray_2(gc: &mut Vec<Draw>, space: &Space, base: Vec2, dir: Vec2) {
|
|||
Inner => {
|
||||
let cell = RectInside { rect: space.rect };
|
||||
let ray = cell.ray_to_local(Ray { pos: p, dir: v });
|
||||
let Some(ray) = cell.to_boundary(ray) else {
|
||||
panic!("Can't get outta here!");
|
||||
};
|
||||
let ray = cell.to_boundary(ray).expect("Can't get outta here!");
|
||||
Ray { pos: p, dir: v } = cell.ray_to_global(ray);
|
||||
}
|
||||
Outer => {
|
||||
|
|
@ -229,7 +224,7 @@ impl Renderable for Rect {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[derive(Copy, Clone, Debug, PartialEq)]
|
||||
struct Ray {
|
||||
pos: Vec2,
|
||||
dir: Vec2,
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user