Playing with the implementation of slab intersection
This stuff is commented out anyway because it all moved to IntersectSlab...
This commit is contained in:
parent
3ce6987d78
commit
d79c95be71
1 changed files with 6 additions and 6 deletions
|
@ -88,16 +88,16 @@ Box::DoesIntersect(const Ray& ray,
|
||||||
* planes...
|
* planes...
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (ray.direction.x == 0.0) {
|
if (NearZero(ray.direction.x)) {
|
||||||
/* The ray is parallel to the X axis. */
|
/* The ray is parallel to the X axis. */
|
||||||
if (ray.origin.x < mNear.x || ray.origin.x > mFar.x) {
|
if (ray.origin.x < mNear.x || ray.origin.x > mFar.x) {
|
||||||
/* The ray's origin is not between the slabs, so no intersection. */
|
/* The ray's origin is not between the slabs, so no intersection. */
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Double invX = 1.0 / ray.direction.x;
|
//Double invX = 1.0 / ray.direction.x;
|
||||||
t0 = (mNear.x - ray.origin.x) * invX;
|
t0 = (mNear.x - ray.origin.x) / ray.direction.x;
|
||||||
t1 = (mFar.x - ray.origin.x) * invX;
|
t1 = (mFar.x - ray.origin.x) / ray.direction.x;
|
||||||
if (t0 > t1) {
|
if (t0 > t1) {
|
||||||
tNear = t1;
|
tNear = t1;
|
||||||
tFar = t0;
|
tFar = t0;
|
||||||
|
@ -118,7 +118,7 @@ Box::DoesIntersect(const Ray& ray,
|
||||||
|
|
||||||
/* Now the Y planes. */
|
/* Now the Y planes. */
|
||||||
|
|
||||||
if (ray.direction.y == 0.0) {
|
if (NearZero(ray.direction.y)) {
|
||||||
/* The ray is parallel to the Y axis. */
|
/* The ray is parallel to the Y axis. */
|
||||||
if (ray.origin.y < mNear.y || ray.origin.y > mFar.y) {
|
if (ray.origin.y < mNear.y || ray.origin.y > mFar.y) {
|
||||||
/* The ray's origin is not between the slabs, so no intersection. */
|
/* The ray's origin is not between the slabs, so no intersection. */
|
||||||
|
@ -149,7 +149,7 @@ Box::DoesIntersect(const Ray& ray,
|
||||||
|
|
||||||
/* Finally, the Z planes. */
|
/* Finally, the Z planes. */
|
||||||
|
|
||||||
if (ray.direction.z == 0.0) {
|
if (NearZero(ray.direction.z)) {
|
||||||
/* The ray is parallel to the Z axis. */
|
/* The ray is parallel to the Z axis. */
|
||||||
if (ray.origin.z < mNear.z || ray.origin.z > mFar.z) {
|
if (ray.origin.z < mNear.z || ray.origin.z > mFar.z) {
|
||||||
/* The ray's origin is not between the slabs, so no intersection. */
|
/* The ray's origin is not between the slabs, so no intersection. */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue