X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;ds=sidebyside;f=source%2Fgeometry%2Fcompositeshape.h;h=00ae55d0ad7b83e8d67a3f15867d75c6419a6903;hb=a29d2c17ca70a3ed5df1e863c92ccd851d5dba6b;hp=e9aeadcfe73df68657fab07473d15a6fba2f25a6;hpb=7de28b9c89ca4554f5c12746f481f5b385529479;p=libs%2Fmath.git diff --git a/source/geometry/compositeshape.h b/source/geometry/compositeshape.h index e9aeadc..00ae55d 100644 --- a/source/geometry/compositeshape.h +++ b/source/geometry/compositeshape.h @@ -38,6 +38,7 @@ public: virtual bool contains(const LinAl::Vector &) const; virtual unsigned get_max_ray_intersections() const { return max_isect; } virtual unsigned get_intersections(const Ray &, SurfacePoint *, unsigned) const; + virtual Coverage get_coverage(const BoundingBox &) const; }; template @@ -190,6 +191,23 @@ inline unsigned CompositeShape::get_intersections(const Ray &ray, return n; } +template +inline Coverage CompositeShape::get_coverage(const BoundingBox &bbox) const +{ + Coverage coverage = NO_COVERAGE; + for(typename ShapeArray::const_iterator i=shapes.begin(); i!=shapes.end(); ++i) + { + Coverage c = (*i)->get_coverage(bbox); + if(i==shapes.begin() || Ops::shortcircuit(c>coverage)) + coverage = c; + + if(coverage!=PARTIAL_COVERAGE && Ops::shortcircuit(coverage==FULL_COVERAGE)) + break; + } + + return coverage; +} + } // namespace Geometry } // namespace Msp