diff options
author | Tavian Barnes <tavianator@gmail.com> | 2009-10-13 03:39:04 +0000 |
---|---|---|
committer | Tavian Barnes <tavianator@gmail.com> | 2009-10-13 03:39:04 +0000 |
commit | 8646f32b25d5ae22b5483854059ee584dfc4a2c7 (patch) | |
tree | fabbdb3a37451d913c95825908a272e1b651bd8d /libdimension | |
parent | bc2395e659081356079688ba74e8db266d8a802e (diff) | |
download | dimension-8646f32b25d5ae22b5483854059ee584dfc4a2c7.tar.xz |
Fix ray-box intersection test.
Diffstat (limited to 'libdimension')
-rw-r--r-- | libdimension/kD_splay_tree.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/libdimension/kD_splay_tree.c b/libdimension/kD_splay_tree.c index 758e68c..de70edf 100644 --- a/libdimension/kD_splay_tree.c +++ b/libdimension/kD_splay_tree.c @@ -388,14 +388,14 @@ dmnsn_ray_box_intersection(dmnsn_line line, dmnsn_vector min, dmnsn_vector max, if (line.n.y != 0.0) { /* y == -1.0 */ - t_temp = (-1.0 - line.x0.y)/line.n.y; + t_temp = (min.y - line.x0.y)/line.n.y; p = dmnsn_line_point(line, t_temp); if (p.x >= min.x && p.x <= max.x && p.z >= min.z && p.z <= max.z && t_temp >= 0.0 && (t < 0.0 || t_temp < t)) return 1; /* y == 1.0 */ - t_temp = (1.0 - line.x0.y)/line.n.y; + t_temp = (max.y - line.x0.y)/line.n.y; p = dmnsn_line_point(line, t_temp); if (p.x >= min.x && p.x <= max.x && p.z >= min.z && p.z <= max.z && t_temp >= 0.0 && (t < 0.0 || t_temp < t)) @@ -404,14 +404,14 @@ dmnsn_ray_box_intersection(dmnsn_line line, dmnsn_vector min, dmnsn_vector max, if (line.n.z != 0.0) { /* z == -1.0 */ - t_temp = (-1.0 - line.x0.z)/line.n.z; + t_temp = (min.z - line.x0.z)/line.n.z; p = dmnsn_line_point(line, t_temp); if (p.x >= min.x && p.x <= max.x && p.y >= min.y && p.y <= max.y && t_temp >= 0.0 && (t < 0.0 || t_temp < t)) return 1; /* z == 1.0 */ - t_temp = (1.0 - line.x0.z)/line.n.z; + t_temp = (max.z - line.x0.z)/line.n.z; p = dmnsn_line_point(line, t_temp); if (p.x >= min.x && p.x <= max.x && p.y >= min.y && p.y <= max.y && t_temp >= 0.0 && (t < 0.0 || t_temp < t)) |