From 3c0cc16c685e73d53d04b7d5bd66fae06ec9a69f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Tue, 12 Mar 2019 17:59:28 +0100 Subject: [PATCH] take the max coordinate instead of the non-zero one --- .../internal/AABB_tree/AABB_ray_intersection.h | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/AABB_tree/include/CGAL/internal/AABB_tree/AABB_ray_intersection.h b/AABB_tree/include/CGAL/internal/AABB_tree/AABB_ray_intersection.h index c5c388d4304..c05a0a34ef5 100644 --- a/AABB_tree/include/CGAL/internal/AABB_tree/AABB_ray_intersection.h +++ b/AABB_tree/include/CGAL/internal/AABB_tree/AABB_ray_intersection.h @@ -180,7 +180,14 @@ private: struct as_ray_param_visitor { typedef FT result_type; - as_ray_param_visitor(const Ray* ray) : ray(ray) {} + as_ray_param_visitor(const Ray* ray) + : ray(ray), max_i(0) + { + typename AABB_traits::Geom_traits::Vector_3 v = ray->to_vector(); + for (int i=1; i<3; ++i) + if( CGAL::abs(v[i]) > CGAL::abs(v[max_i]) ) + max_i = i; + } template FT operator()(const T& s) @@ -196,16 +203,11 @@ private: typename AABB_traits::Geom_traits::Vector_3 x(ray->source(), point); typename AABB_traits::Geom_traits::Vector_3 v = ray->to_vector(); - for(int i = 0; i < 3; ++i) { - if(v[i] != FT(0.)) { - return x[i] / v[i]; - } - } - CGAL_assertion(false); // should never end-up here - return FT(0.); + return x[max_i] / v[max_i]; } const Ray* ray; + int max_i; }; };