Add object crossings

This commit is contained in:
numzero 2024-11-17 01:02:51 +03:00
parent 6da6944fa3
commit 8e7a57761e

View File

@ -58,6 +58,18 @@ fn draw_ellipse(center: Vec3, u: Vec3, v: Vec3) -> Line {
)
}
fn draw_mark(pos: Vec3) -> Vec<Line> {
[
vec3(1., 1., 1.),
vec3(1., 1., -1.),
vec3(1., -1., 1.),
vec3(1., -1., -1.),
]
.into_iter()
.map(|off| draw_line(pos - off, pos + off))
.collect()
}
pub fn build() -> Vec<FancyLine> {
let tube = Tube {
inner_radius: 30.0,
@ -104,11 +116,17 @@ pub fn build() -> Vec<FancyLine> {
fn draw_ray_2(gc: &mut Vec<Line>, space: &Space, camera: Location, dir: Vec3) {
let pos = vec3(0., 0., 0.);
let (hits, path) = space.trace_dbg(camera, Ray { pos, dir });
let hits2 = space.trace(camera, Ray { pos, dir });
for (a, b) in hits.into_iter().zip(hits2.into_iter()) {
assert_eq!(a.id, b.id);
assert_eq!(a.pos, b.pos);
assert_eq!(a.rel, b.rel);
if true {
let hits2 = space.trace(camera, Ray { pos, dir });
for (a, b) in hits.iter().zip(hits2.into_iter()) {
assert_eq!(a.id, b.id);
assert_eq!(a.pos, b.pos);
assert_eq!(a.rel, b.rel);
}
}
for hit in hits {
gc.extend(draw_mark(hit.pos));
}
let mut pts = path.points;