]> git.tdb.fi Git - libs/math.git/blobdiff - source/geometry/negation.h
Optimize bounding box bisection with more early culling
[libs/math.git] / source / geometry / negation.h
index 8e2b3f41a6d7c30681026176330d0ed1a04d965e..60b92e33d1d30def4d60f631c8311acbbcd0c115 100644 (file)
@@ -26,10 +26,11 @@ public:
 
        const Shape<T, D> &get_shape() const { return *shape; }
 
-       virtual BoundingBox<T, D> get_axis_aligned_bounding_box() const;
+       virtual BoundingBox<T, D> get_axis_aligned_bounding_box(unsigned = 0) const;
        virtual bool contains(const LinAl::Vector<T, D> &) const;
        virtual unsigned get_max_ray_intersections() const { return shape->get_max_ray_intersections(); }
        virtual unsigned get_intersections(const Ray<T, D> &, SurfacePoint<T, D> *, unsigned) const;
+       virtual Coverage get_coverage(const BoundingBox<T, D> &) const;
 };
 
 template<typename T, unsigned D>
@@ -63,9 +64,9 @@ inline Negation<T, D> *Negation<T, D>::clone() const
 }
 
 template<typename T, unsigned D>
-inline BoundingBox<T, D> Negation<T, D>::get_axis_aligned_bounding_box() const
+inline BoundingBox<T, D> Negation<T, D>::get_axis_aligned_bounding_box(unsigned detail) const
 {
-       return ~shape->get_axis_aligned_bounding_box();
+       return ~shape->get_axis_aligned_bounding_box(detail);
 }
 
 template<typename T, unsigned D>
@@ -86,6 +87,18 @@ inline unsigned Negation<T, D>::get_intersections(const Ray<T, D> &ray, SurfaceP
        return count;
 }
 
+template<typename T, unsigned D>
+inline Coverage Negation<T, D>::get_coverage(const BoundingBox<T, D> &bbox) const
+{
+       Coverage coverage = shape->get_coverage(bbox);
+       if(coverage==FULL_COVERAGE)
+               return NO_COVERAGE;
+       else if(coverage==NO_COVERAGE)
+               return FULL_COVERAGE;
+       else
+               return coverage;
+}
+
 } // namespace Geometry
 } // namespace Msp