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