rtiow: descend both children in BVHTriangles::hit.
This commit is contained in:
parent
d3dd002883
commit
95827a4a52
@ -194,13 +194,15 @@ where
|
||||
}
|
||||
}
|
||||
} else {
|
||||
let hr = self.intersect_bvh(r, node.left_child, t_min, t_max);
|
||||
if hr.is_some() {
|
||||
return hr;
|
||||
}
|
||||
let hr = self.intersect_bvh(r, node.left_child + 1, t_min, t_max);
|
||||
if hr.is_some() {
|
||||
return hr;
|
||||
let r1 = self.intersect_bvh(r, node.left_child, t_min, t_max);
|
||||
let r2 = self.intersect_bvh(r, node.left_child + 1, t_min, t_max);
|
||||
// Merge results, if both hit, take the one closest to the ray origin (smallest t
|
||||
// value).
|
||||
match (&r1, &r2) {
|
||||
(Some(_), None) => return r1,
|
||||
(None, Some(_)) => return r2,
|
||||
(None, None) => (),
|
||||
(Some(rp1), Some(rp2)) => return if rp1.t < rp2.t { r1 } else { r2 },
|
||||
}
|
||||
}
|
||||
None
|
||||
@ -282,7 +284,7 @@ fn ray_triangle_intersect_moller_trumbore(r: Ray, tri: &Triangle) -> Option<RayT
|
||||
if t > EPSILON {
|
||||
return Some(RayTriangleResult {
|
||||
t,
|
||||
p: r.origin + r.direction * t,
|
||||
p: r.point_at_parameter(t),
|
||||
});
|
||||
}
|
||||
None
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user