X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fgeometry%2Fcompositeshape.h;h=c472b437e3052f4948cde3a68ac40a9f1107b35a;hb=2826730b5d68d1ad74dc6363af43ca796f96caa2;hp=00ae55d0ad7b83e8d67a3f15867d75c6419a6903;hpb=a29d2c17ca70a3ed5df1e863c92ccd851d5dba6b;p=libs%2Fmath.git diff --git a/source/geometry/compositeshape.h b/source/geometry/compositeshape.h index 00ae55d..c472b43 100644 --- a/source/geometry/compositeshape.h +++ b/source/geometry/compositeshape.h @@ -34,7 +34,7 @@ protected: public: virtual ~CompositeShape(); - virtual BoundingBox get_axis_aligned_bounding_box() const; + virtual BoundingBox get_axis_aligned_bounding_box(unsigned = 0) const; 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; @@ -100,8 +100,11 @@ inline CompositeShape::~CompositeShape() } template -inline BoundingBox CompositeShape::get_axis_aligned_bounding_box() const +inline BoundingBox CompositeShape::get_axis_aligned_bounding_box(unsigned detail) const { + if(detail) + return this->bisect_axis_aligned_bounding_box(detail); + BoundingBox aabb; for(typename ShapeArray::const_iterator i=shapes.begin(); i!=shapes.end(); ++i) { @@ -198,10 +201,12 @@ inline Coverage CompositeShape::get_coverage(const BoundingBox &b 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)) + if(i==shapes.begin()) coverage = c; + else + coverage = Ops::combine_coverage(coverage, c); - if(coverage!=PARTIAL_COVERAGE && Ops::shortcircuit(coverage==FULL_COVERAGE)) + if((coverage==NO_COVERAGE && Ops::shortcircuit(false)) || (coverage==FULL_COVERAGE && Ops::shortcircuit(true))) break; }