From 92e67215b98eee794501ba70f48ff83f3dd481a6 Mon Sep 17 00:00:00 2001 From: Eryn Wells Date: Sun, 3 Aug 2014 16:36:12 -0700 Subject: [PATCH] Get rid of commented out Box intersection code --- src/objectBox.cc | 96 ------------------------------------------------ 1 file changed, 96 deletions(-) diff --git a/src/objectBox.cc b/src/objectBox.cc index 70e880b..a759981 100644 --- a/src/objectBox.cc +++ b/src/objectBox.cc @@ -82,102 +82,6 @@ Box::DoesIntersect(const Ray& ray, * planes (X, Y, and Z planes). */ -#if 0 - /* - * Unrolling the loop means lots of duplicated code. So we start with the X - * planes... - */ - - if (NearZero(ray.direction.x)) { - /* The ray is parallel to the X axis. */ - if (ray.origin.x < mNear.x || ray.origin.x > mFar.x) { - /* The ray's origin is not between the slabs, so no intersection. */ - return false; - } - } else { - //Double invX = 1.0 / ray.direction.x; - t0 = (mNear.x - ray.origin.x) / ray.direction.x; - t1 = (mFar.x - ray.origin.x) / ray.direction.x; - if (t0 > t1) { - tNear = t1; - tFar = t0; - } else { - tNear = t0; - tFar = t1; - } - - if (tNear > tFar) { - /* Box is missed. */ - return false; - } - if (tFar < 0.0) { - /* Box is behind the ray. */ - return false; - } - } - - /* Now the Y planes. */ - - if (NearZero(ray.direction.y)) { - /* The ray is parallel to the Y axis. */ - if (ray.origin.y < mNear.y || ray.origin.y > mFar.y) { - /* The ray's origin is not between the slabs, so no intersection. */ - return false; - } - } else { - /* The ray isn't parallel, so calculate the intersection points. */ - Double invY = 1.0 / ray.direction.y; - t0 = (mNear.y - ray.origin.y) * invY; - t1 = (mFar.y - ray.origin.y) * invY; - if (t0 > t1) { - tNear = t1; - tFar = t0; - } else { - tNear = t0; - tFar = t1; - } - - if (tNear > tFar) { - /* Box is missed. */ - return false; - } - if (tFar < 0.0) { - /* Box is behind the ray. */ - return false; - } - } - - /* Finally, the Z planes. */ - - if (NearZero(ray.direction.z)) { - /* The ray is parallel to the Z axis. */ - if (ray.origin.z < mNear.z || ray.origin.z > mFar.z) { - /* The ray's origin is not between the slabs, so no intersection. */ - return false; - } - } else { - Double invZ = 1.0 / ray.direction.z; - t0 = (mNear.z - ray.origin.z) * invZ; - t1 = (mFar.z - ray.origin.z) * invZ; - if (t0 > t1) { - tNear = t1; - tFar = t0; - } else { - tNear = t0; - tFar = t1; - } - - if (tNear > tFar) { - /* Box is missed. */ - return false; - } - if (tFar < 0.0) { - /* Box is behind the ray. */ - return false; - } - } -#endif - if (!IntersectSlab(mNear.x, mFar.x, ray.origin.x, ray.direction.x, tNear, tFar)) { return false; }