Get rid of commented out Box intersection code
This commit is contained in:
parent
556e13ae74
commit
92e67215b9
1 changed files with 0 additions and 96 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue