]> git.tdb.fi Git - libs/math.git/commitdiff
Add an entry flag to SharedPoint
authorMikko Rasa <tdb@tdb.fi>
Sat, 2 Jul 2016 15:06:27 +0000 (18:06 +0300)
committerMikko Rasa <tdb@tdb.fi>
Sat, 2 Jul 2016 15:32:57 +0000 (18:32 +0300)
source/geometry/extrudedshape.h
source/geometry/halfspace.h
source/geometry/hyperbox.h
source/geometry/hypersphere.h
source/geometry/negation.h
source/geometry/surfacepoint.h

index 84addc46e7dde3fee65dea0283f56f2c0b29fc91..a62aa9a311e88bf09dd9fa5d480b425baaf38758 100644 (file)
@@ -147,6 +147,7 @@ inline unsigned ExtrudedShape<T, D>::get_intersections(const Ray<T, D> &ray, Sur
                                        points[n].position = ray_start+ray_direction*x;
                                        points[n].normal = compose(base_points[i].normal, T(0));
                                        points[n].distance = x;
+                                       points[n].entry = base_points[i].entry;
                                }
 
                                ++n;
@@ -173,6 +174,7 @@ inline unsigned ExtrudedShape<T, D>::get_intersections(const Ray<T, D> &ray, Sur
                                        points[n].normal = LinAl::Vector<T, D>();
                                        points[n].normal[D-1] = i;
                                        points[n].distance = x;
+                                       points[n].entry = (T(i)*ray_direction[D-1]<T(0));
                                }
 
                                ++n;
index 518f91ab7ad46979766f25d2ea96deb984cde345..b439851bd5adaf3a7067c7f91f5bf8308bb01166 100644 (file)
@@ -76,6 +76,7 @@ inline unsigned HalfSpace<T, D>::get_intersections(const Ray<T, D> &ray, Surface
                        points[0].position = ray.get_start()+ray.get_direction()*x;
                        points[0].normal = normal;
                        points[0].distance = x;
+                       points[0].entry = (c<T(0));
                }
 
                return 1;
index e45fadc12ae92d4752b523302328adeaa8df650d..546ad0ec3984c5b338978c23b37f0c8ea5f97533 100644 (file)
@@ -116,6 +116,7 @@ inline unsigned HyperBox<T, D>::get_intersections(const Ray<T, D> &ray, SurfaceP
                                        points[n].normal = LinAl::Vector<T, D>();
                                        points[n].normal[i] = j;
                                        points[n].distance = x;
+                                       points[n].entry = (T(j)*ray.get_direction()[i]<T(0));
 
                                        if(n==1 && x<points[0].distance)
                                                std::swap(points[0], points[1]);
index 4df03fed0eb433abb38d6df8e9375fc42f78befe..6bb4352f4016840ca331ebfd2034f35a7090e7d2 100644 (file)
@@ -85,6 +85,7 @@ inline unsigned HyperSphere<T, D>::get_intersections(const Ray<T, D> &ray, Surfa
                                points[n].position = ray.get_start()+ray.get_direction()*x;
                                points[n].normal = normalize(points[n].position);
                                points[n].distance = x;
+                               points[n].entry = (i<0);
                        }
 
                        ++n;
index ce2f7873d6aed3eeff7304e67abe7598b5c274c7..8e2b3f41a6d7c30681026176330d0ed1a04d965e 100644 (file)
@@ -79,7 +79,10 @@ inline unsigned Negation<T, D>::get_intersections(const Ray<T, D> &ray, SurfaceP
 {
        unsigned count = shape->get_intersections(ray, points, size);
        for(unsigned i=0; i<count; ++i)
+       {
                points[i].normal = -points[i].normal;
+               points[i].entry = !points[i].entry;
+       }
        return count;
 }
 
index 57a66d1e95f3898bf1f050ed65afa77bf8d89cae..3b38e1d2d03f6fdf5e2ee5c99ff6fbfaca633813 100644 (file)
@@ -16,6 +16,7 @@ struct SurfacePoint
        LinAl::Vector<T, N> position;
        LinAl::Vector<T, N> normal;
        T distance;
+       bool entry;
 };
 
 template<typename T, unsigned N>