From 649a6a0869a159f112630f14fa1d8a33a3952f11 Mon Sep 17 00:00:00 2001 From: Nathan Vegdahl Date: Thu, 6 Jul 2017 22:10:37 -0700 Subject: [PATCH] Rearrnging the operations in ray/bbox test for slight perf improvement. The difference is extremely small, but consistent. I'm guessing due to better pipelining of instructions. --- src/bbox.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/bbox.rs b/src/bbox.rs index 11995ca..6c3824a 100644 --- a/src/bbox.rs +++ b/src/bbox.rs @@ -44,15 +44,15 @@ impl BBox { let t2 = (self.max.co - ray.orig.co) * ray.dir_inv.co; // 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(0.0); + let mut near_t = t1.v_min(t2); far_t.set_3(std::f32::INFINITY); - let hitt0 = near_t.h_max(); - let hitt1 = far_t.h_min() * BBOX_MAXT_ADJUST; + near_t.set_3(0.0); + let far_hit_t = fast_minf32(far_t.h_min() * BBOX_MAXT_ADJUST, ray.max_t); + let near_hit_t = near_t.h_max(); // Did we hit? - return hitt0 <= fast_minf32(hitt1, ray.max_t); + return near_hit_t <= far_hit_t; } // Creates a new BBox transformed into a different space.