]> git.tdb.fi Git - libs/math.git/blobdiff - source/geometry/hyperbox.h
Record distance in SurfacePoint
[libs/math.git] / source / geometry / hyperbox.h
index 7d363f246a8a48e25cbb07762e351f7f4dc58936..10c28d5d1f4c20a15937e7b0aa696f3074151aec 100644 (file)
@@ -83,7 +83,6 @@ inline unsigned HyperBox<T, D>::get_intersections(const Ray<T, D> &ray, SurfaceP
 
        LinAl::Vector<T, D> half_dim = dimensions/T(2);
        unsigned n = 0;
-       T first_depth = T();
        for(unsigned i=0; i<D; ++i)
        {
                if(!ray.get_direction()[i])
@@ -108,9 +107,9 @@ inline unsigned HyperBox<T, D>::get_intersections(const Ray<T, D> &ray, SurfaceP
                                        points[n].position = p;
                                        points[n].normal = LinAl::Vector<T, D>();
                                        points[n].normal[i] = j;
-                                       if(n==0)
-                                               first_depth = x;
-                                       else if(n==1 && x<first_depth)
+                                       points[n].distance = x;
+
+                                       if(n==1 && x<points[0].distance)
                                                std::swap(points[0], points[1]);
                                }