Changed BBox/Ray intersection code to use more simd ops.
This, of course, depends on the simd ops being there, which currently they are not. But in the future, hopefully this will make things speedy. Will need to test, of course.
This commit is contained in:
parent
890c04c44a
commit
61e3d47f56
12
src/bbox.rs
12
src/bbox.rs
|
@ -44,12 +44,12 @@ impl BBox {
|
||||||
let t2 = (self.max.co - ray.orig.co) * ray.dir_inv.co;
|
let t2 = (self.max.co - ray.orig.co) * ray.dir_inv.co;
|
||||||
|
|
||||||
// Find the far and near intersection
|
// Find the far and near intersection
|
||||||
let hitt0 = (t1[0].min(t2[0]))
|
let mut near_t = t1.v_min(t2);
|
||||||
.max(t1[1].min(t2[1]))
|
let mut far_t = t1.v_max(t2);
|
||||||
.max(t1[2].min(t2[2]));
|
near_t.set_3(std::f32::NEG_INFINITY);
|
||||||
let hitt1 = (t1[0].max(t2[0]))
|
far_t.set_3(std::f32::INFINITY);
|
||||||
.min(t1[1].max(t2[1]))
|
let hitt0 = near_t.h_max();
|
||||||
.min(t1[2].max(t2[2])) * BBOX_MAXT_ADJUST;
|
let hitt1 = far_t.h_min() * BBOX_MAXT_ADJUST;
|
||||||
|
|
||||||
// Did we hit?
|
// Did we hit?
|
||||||
return hitt0.max(0.0) <= hitt1.min(ray.max_t);
|
return hitt0.max(0.0) <= hitt1.min(ray.max_t);
|
||||||
|
|
|
@ -64,6 +64,30 @@ impl Float4 {
|
||||||
self.data.get_unchecked(3).max(*other.data.get_unchecked(3)))
|
self.data.get_unchecked(3).max(*other.data.get_unchecked(3)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn set_0(&mut self, n: f32) {
|
||||||
|
unsafe {
|
||||||
|
*self.data.get_unchecked_mut(0) = n;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn set_1(&mut self, n: f32) {
|
||||||
|
unsafe {
|
||||||
|
*self.data.get_unchecked_mut(1) = n;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn set_2(&mut self, n: f32) {
|
||||||
|
unsafe {
|
||||||
|
*self.data.get_unchecked_mut(2) = n;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn set_3(&mut self, n: f32) {
|
||||||
|
unsafe {
|
||||||
|
*self.data.get_unchecked_mut(3) = n;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user