diff options
author | Tavian Barnes <tavianator@gmail.com> | 2010-07-03 00:59:28 -0600 |
---|---|---|
committer | Tavian Barnes <tavianator@gmail.com> | 2010-07-03 00:59:28 -0600 |
commit | 66c4b24d561b643e8ccba74bf78223fdefe524fe (patch) | |
tree | 4357847de8002267103823b486b82baddf110293 | |
parent | 440b2c1949e5d9135505871ad3da032cf93add43 (diff) | |
download | dimension-66c4b24d561b643e8ccba74bf78223fdefe524fe.tar.xz |
Make dmnsn_ray_box_intersection() return false for zero boxes.
-rw-r--r-- | libdimension/prtree.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/libdimension/prtree.c b/libdimension/prtree.c index 15bc997..04e7de9 100644 --- a/libdimension/prtree.c +++ b/libdimension/prtree.c @@ -529,7 +529,7 @@ dmnsn_ray_box_intersection(dmnsn_line line, dmnsn_bounding_box box, double t) { double tmin = -INFINITY, tmax = INFINITY; - if (line.n.x != 0.0) { + if (line.n.x != 0.0 && box.min.x < box.max.x) { double tx1 = (box.min.x - line.x0.x)/line.n.x; double tx2 = (box.max.x - line.x0.x)/line.n.x; @@ -543,7 +543,7 @@ dmnsn_ray_box_intersection(dmnsn_line line, dmnsn_bounding_box box, double t) return false; } - if (line.n.y != 0.0) { + if (line.n.y != 0.0 && box.min.y < box.max.y) { double ty1 = (box.min.y - line.x0.y)/line.n.y; double ty2 = (box.max.y - line.x0.y)/line.n.y; @@ -557,7 +557,7 @@ dmnsn_ray_box_intersection(dmnsn_line line, dmnsn_bounding_box box, double t) return false; } - if (line.n.z != 0.0) { + if (line.n.z != 0.0 && box.min.z < box.max.z) { double tz1 = (box.min.z - line.x0.z)/line.n.z; double tz2 = (box.max.z - line.x0.z)/line.n.z; |