X-Git-Url: http://git.tdb.fi/?p=libs%2Fmath.git;a=blobdiff_plain;f=source%2Fgeometry%2Fcompositeshape.h;h=50b04e80c506e93f7dc995187140e871dec66e27;hp=fd55c8e6e090875cd147f57697a35190fa26206e;hb=827b227ae53884109b6885ccd1424dda8c0b3725;hpb=68389c29cf88d6522dcfa00b5e2a5166e3947210 diff --git a/source/geometry/compositeshape.h b/source/geometry/compositeshape.h index fd55c8e..50b04e8 100644 --- a/source/geometry/compositeshape.h +++ b/source/geometry/compositeshape.h @@ -105,14 +105,13 @@ template inline unsigned CompositeShape::get_intersections(const Ray &ray, SurfacePoint *points, unsigned size) const { unsigned n = 0; - for(typename ShapeArray::const_iterator i=shapes.begin(); i!=shapes.end(); ++i) + for(typename ShapeArray::const_iterator i=shapes.begin(); (nget_intersections(ray, points+base, size-base); - for(unsigned j=0; j pt = points[base+j]; + SurfacePoint &pt = points[base+j]; bool surface = Ops::init_surface(); for(typename ShapeArray::const_iterator k=shapes.begin(); k!=shapes.end(); ++k) @@ -121,22 +120,16 @@ inline unsigned CompositeShape::get_intersections(const Ray &ray, if(surface) { - if(points) - { - unsigned k; - for(k=n; (k>0 && points[k-1].distance>pt.distance); --k) - points[k] = points[k-1]; - if(base+j!=k) - points[k] = pt; - } + if(points && base+j!=n) + points[n] = pt; ++n; - if(n==size) - return n; } } } + sort_points(points, n); + return n; }