From 818f9df5f383adad815f6f3276bfc1fa30c25681 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Sat, 2 Jul 2016 20:00:50 +0300 Subject: [PATCH] Ensure that HyperBox does not produce duplicate intersections In certain corner cases (literally) two coincident intersections could be produced when the ray passed through the edge of the box, preventing intersctions on the opposite side from being produced. --- source/geometry/hyperbox.h | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/source/geometry/hyperbox.h b/source/geometry/hyperbox.h index 546ad0e..b9fad33 100644 --- a/source/geometry/hyperbox.h +++ b/source/geometry/hyperbox.h @@ -112,14 +112,23 @@ inline unsigned HyperBox::get_intersections(const Ray &ray, SurfaceP { if(points) { - points[n].position = p; - points[n].normal = LinAl::Vector(); - points[n].normal[i] = j; - points[n].distance = x; - points[n].entry = (T(j)*ray.get_direction()[i]0 && entry!=points[0].entry) + { + if(entry) + points[1] = points[0]; + else + ++k; + } + if(k(); + points[k].normal[i] = j; + points[k].distance = x; + points[k].entry = (T(j)*ray.get_direction()[i]