Fixed bug in ray intersection code.
The max_t was getting overwritten during transforms.
This commit is contained in:
parent
a467a2a959
commit
c3d3145817
10
src/ray.rs
10
src/ray.rs
|
@ -34,4 +34,14 @@ impl Ray {
|
||||||
self.dir = self.dir * *mat;
|
self.dir = self.dir * *mat;
|
||||||
self.dir_inv = Vector { co: Float4::new(1.0, 1.0, 1.0, 1.0) / self.dir.co };
|
self.dir_inv = Vector { co: Float4::new(1.0, 1.0, 1.0, 1.0) / self.dir.co };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn update_from_world_ray(&mut self, wr: &Ray) {
|
||||||
|
self.orig = wr.orig;
|
||||||
|
self.dir = wr.dir;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn update_from_xformed_world_ray(&mut self, wr: &Ray, mat: &Matrix4x4) {
|
||||||
|
self.update_from_world_ray(wr);
|
||||||
|
self.transform(mat);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,8 +68,7 @@ impl<'a> Tracer<'a> {
|
||||||
for ray in &mut rs[..] {
|
for ray in &mut rs[..] {
|
||||||
let id = ray.id;
|
let id = ray.id;
|
||||||
let t = ray.time;
|
let t = ray.time;
|
||||||
*ray = wrays[id as usize];
|
ray.update_from_xformed_world_ray(&wrays[id as usize], &lerp_slice(xforms, t));
|
||||||
ray.transform(&lerp_slice(xforms, t));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,14 +94,13 @@ impl<'a> Tracer<'a> {
|
||||||
for ray in &mut rs[..] {
|
for ray in &mut rs[..] {
|
||||||
let id = ray.id;
|
let id = ray.id;
|
||||||
let t = ray.time;
|
let t = ray.time;
|
||||||
*ray = wrays[id as usize];
|
ray.update_from_xformed_world_ray(&wrays[id as usize],
|
||||||
ray.transform(&lerp_slice(xforms, t));
|
&lerp_slice(xforms, t));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for ray in &mut rs[..] {
|
for ray in &mut rs[..] {
|
||||||
let id = ray.id;
|
let id = ray.id;
|
||||||
let t = ray.time;
|
ray.update_from_world_ray(&wrays[id as usize]);
|
||||||
*ray = wrays[id as usize];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user