From 38b8ab1f15b800094db77c3ff04a49caaf9eb844 Mon Sep 17 00:00:00 2001 From: cignoni Date: Fri, 6 Jul 2012 06:58:17 +0000 Subject: [PATCH] Corrected a bug in GridStaticPointer: The hint about the number of cell to be used was ignored and used only to compute the expansion offset. --- vcg/space/index/grid_static_ptr.h | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/vcg/space/index/grid_static_ptr.h b/vcg/space/index/grid_static_ptr.h index dd56102d..e9e10140 100644 --- a/vcg/space/index/grid_static_ptr.h +++ b/vcg/space/index/grid_static_ptr.h @@ -260,7 +260,7 @@ namespace vcg { _bbox.min-=vcg::Point3(infl,infl,infl); _bbox.max+=vcg::Point3(infl,infl,infl); - Set(_oBegin,_oEnd,_bbox); + Set(_oBegin,_oEnd,_bbox,_size); } @@ -301,16 +301,17 @@ namespace vcg { // Note that the bbox must be already 'inflated' so to be sure that no object will fall on the border of the grid. template - inline void Set(const OBJITER & _oBegin, const OBJITER & _oEnd, const Box3x &_bbox) - { - int _size=(int)std::distance(_oBegin,_oEnd); - Point3 _dim = _bbox.max - _bbox.min; - Point3i _siz; - BestDim( _size, _dim, _siz ); - - Set(_oBegin,_oEnd,_bbox,_siz); - } - + inline void Set(const OBJITER & _oBegin, const OBJITER & _oEnd, const Box3x &_bbox, int _size=0) + { + if(_size==0) + _size=(int)std::distance(_oBegin,_oEnd); + Point3 _dim = _bbox.max - _bbox.min; + Point3i _siz; + BestDim( _size, _dim, _siz ); + + Set(_oBegin,_oEnd,_bbox,_siz); + } + template inline void Set(const OBJITER & _oBegin, const OBJITER & _oEnd, const Box3x &_bbox, Point3i _siz)