]> git.tdb.fi Git - libs/math.git/blobdiff - source/geometry/negation.h
Implement bounding boxes with a separate class
[libs/math.git] / source / geometry / negation.h
index 6746aed113f487618e0e7f254f088fd8bdc2289e..beb3e4e7b845d91edcaff45555add550a8165cd3 100644 (file)
@@ -1,6 +1,7 @@
 #ifndef MSP_GEOMETRY_NEGATION_H_
 #define MSP_GEOMETRY_NEGATION_H_
 
+#include "boundingbox.h"
 #include "shape.h"
 
 namespace Msp {
@@ -23,7 +24,7 @@ public:
 
        const Shape<T, D> &get_shape() const { return *shape; }
 
-       virtual HyperBox<T, D> get_axis_aligned_bounding_box() const;
+       virtual BoundingBox<T, D> get_axis_aligned_bounding_box() 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;
@@ -41,10 +42,9 @@ inline Negation<T, D> *Negation<T, D>::clone() const
 }
 
 template<typename T, unsigned D>
-inline HyperBox<T, D> Negation<T, D>::get_axis_aligned_bounding_box() const
+inline BoundingBox<T, D> Negation<T, D>::get_axis_aligned_bounding_box() const
 {
-       // XXX How do we handle this correctly?  In particular negation of a negation?
-       return HyperBox<T, D>();
+       return ~shape->get_axis_aligned_bounding_box();
 }
 
 template<typename T, unsigned D>