mod common;
use embree3::{IntersectContext, Ray4, RayHit4, SoAHit as _, ValidMask, ValidMaskN};
fn four_hitting_rays() -> Ray4 { Ray4::new([[0.25, 0.25, -1.0]; 4], [[0.0, 0.0, 1.0]; 4]) }
#[test]
fn intersect4_skips_disabled_lane() {
let device = common::device();
let tri = common::unit_triangle(&device).commit();
let mut scene = device.create_scene().unwrap();
scene.attach_geometry(&tri);
scene.commit();
let mut rh = RayHit4::new(four_hitting_rays());
let mut valid = ValidMaskN::all_active();
valid.lanes_mut()[3] = ValidMask::Invalid;
let mut ctx = IntersectContext::coherent();
scene.intersect4(&mut ctx, &mut rh, &valid);
for i in 0..3 {
assert!(rh.hit.is_valid(i), "active lane {i} must hit the triangle");
assert_eq!(
rh.hit.geomID[i], 0,
"active lane {i} hit the attached geometry"
);
}
assert!(
!rh.hit.is_valid(3),
"disabled lane 3 must be left untouched (no hit written)"
);
}
#[test]
fn occluded4_skips_disabled_lane() {
let device = common::device();
let tri = common::unit_triangle(&device).commit();
let mut scene = device.create_scene().unwrap();
scene.attach_geometry(&tri);
scene.commit();
let mut ray4 = four_hitting_rays();
let mut valid = ValidMaskN::all_active();
valid.lanes_mut()[3] = ValidMask::Invalid;
let mut ctx = IntersectContext::coherent();
scene.occluded4(&mut ctx, &mut ray4, &valid);
for i in 0..3 {
assert_eq!(
ray4.tfar[i],
f32::NEG_INFINITY,
"active lane {i} must be reported occluded"
);
}
assert_ne!(
ray4.tfar[3],
f32::NEG_INFINITY,
"disabled lane 3 must be left untouched"
);
}