Small optimization in BBox intersection and bugfix in BBox4 intersection.

This commit is contained in:
Nathan Vegdahl 2017-04-26 00:28:43 -07:00
parent c92a8c4da0
commit 8b0c422630
2 changed files with 4 additions and 3 deletions

View File

@ -47,13 +47,13 @@ impl BBox {
// Find the far and near intersection
let mut near_t = t1.v_min(t2);
let mut far_t = t1.v_max(t2);
near_t.set_3(std::f32::NEG_INFINITY);
near_t.set_3(0.0);
far_t.set_3(std::f32::INFINITY);
let hitt0 = near_t.h_max();
let hitt1 = far_t.h_min() * BBOX_MAXT_ADJUST;
// Did we hit?
return fast_maxf32(hitt0, 0.0) <= fast_minf32(hitt1, ray.max_t);
return hitt0 <= fast_minf32(hitt1, ray.max_t);
}
// Creates a new BBox transformed into a different space.

View File

@ -75,7 +75,8 @@ impl BBox4 {
// Get the minimum and maximum hits
let mins = v_max(v_max(xlos, ylos), v_max(zlos, Float4::splat(0.0)));
let maxs = v_max(v_min(v_min(xhis, yhis), zhis),
Float4::splat(std::f32::NEG_INFINITY) * Float4::splat(BBOX_MAXT_ADJUST));
Float4::splat(std::f32::NEG_INFINITY)) *
Float4::splat(BBOX_MAXT_ADJUST);
// Check for hits
let hits = mins.lt(Float4::splat(ray.max_t)) & mins.lte(maxs);