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