rtiow: add more rays in bvh_triangles test and better failure logging.
This commit is contained in:
parent
d213e04c11
commit
6ab3021403
@ -320,19 +320,31 @@ mod tests {
|
|||||||
//Metal::new(Vec3::new(0.8, 0.8, 0.8), 0.2),
|
//Metal::new(Vec3::new(0.8, 0.8, 0.8), 0.2),
|
||||||
//Lambertian::new(ConstantTexture::new(Vec3::new(1.0, 0.2, 0.2))),
|
//Lambertian::new(ConstantTexture::new(Vec3::new(1.0, 0.2, 0.2))),
|
||||||
);
|
);
|
||||||
let rays = [
|
let rays: Vec<_> = (1..20)
|
||||||
Ray::new([-1., 1., 1.], [1., 0., 0.], 0.),
|
.flat_map(|y| {
|
||||||
Ray::new([21., 1., 1.], [-1., 0., 0.], 0.),
|
(1..20).flat_map(move |x| {
|
||||||
Ray::new([1., -1., 1.], [0., 1., 0.], 0.),
|
let x = x as f32;
|
||||||
Ray::new([1., 21., 1.], [0., -1., 0.], 0.),
|
let y = y as f32;
|
||||||
Ray::new([1., 1., -1.], [0., 0., 1.], 0.),
|
vec![
|
||||||
Ray::new([1., 1., 21.], [0., 0., -1.], 0.),
|
Ray::new([-1., x, y], [1., 0., 0.], 0.),
|
||||||
// TODO more
|
Ray::new([21., x, y], [-1., 0., 0.], 0.),
|
||||||
];
|
Ray::new([x, -1., y], [0., 1., 0.], 0.),
|
||||||
|
Ray::new([x, 21., y], [0., -1., 0.], 0.),
|
||||||
|
Ray::new([x, y, -1.], [0., 0., 1.], 0.),
|
||||||
|
Ray::new([x, y, 21.], [0., 0., -1.], 0.),
|
||||||
|
]
|
||||||
|
.into_iter()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
.collect();
|
||||||
|
|
||||||
for (i, r) in rays.into_iter().enumerate() {
|
for (i, r) in rays.into_iter().enumerate() {
|
||||||
let c_hit = c.hit(r, 0., f32::MAX).expect("c_hit missed");
|
let c_hit = c
|
||||||
let s_hit = s.hit(r, 0., f32::MAX).expect("s_hit missed");
|
.hit(r, 0., f32::MAX)
|
||||||
|
.expect(&format!("c_hit missed {i}: {r:?}"));
|
||||||
|
let s_hit = s
|
||||||
|
.hit(r, 0., f32::MAX)
|
||||||
|
.expect(&format!("s_hit missed {i}: {r:?}"));
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
c_hit.t, s_hit.t,
|
c_hit.t, s_hit.t,
|
||||||
"{i}: [t] c_hit: {c_hit:?}, s_hit: {s_hit:?}"
|
"{i}: [t] c_hit: {c_hit:?}, s_hit: {s_hit:?}"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user