46 SHAPE_ENTRY( T aParent )
48 shape = ShapeFunctor( aParent );
49 bbox = shape->BBox( 0 );
62 typedef std::vector<SHAPE_ENTRY> SHAPE_VEC;
63 typedef typename std::vector<SHAPE_ENTRY>::iterator SHAPE_VEC_ITER;
73 iterator( SHAPE_VEC_ITER aCurrent ) :
78 m_current( aB.m_current )
83 return (*m_current).parent;
97 bool operator==(
const iterator& aRhs )
const
99 return m_current == aRhs.m_current;
102 bool operator!=(
const iterator& aRhs )
const
104 return m_current != aRhs.m_current;
109 m_current = aRhs.m_current;
114 SHAPE_VEC_ITER m_current;
126 int aMinDistance,
bool aExact ) :
128 m_current( aCurrent ),
130 m_minDistance( aMinDistance ),
135 m_refBBox = aShape->
BBox();
142 m_current( aB.m_current ),
143 m_shape( aB.m_shape ),
144 m_minDistance( aB.m_minDistance ),
145 m_exact( aB.m_exact ),
146 m_refBBox( aB.m_refBBox )
152 return (*m_current).parent;
171 return m_current == aRhs.m_current;
176 return m_current != aRhs.m_current;
182 m_current = aRhs.m_current;
183 m_shape = aRhs.m_shape;
184 m_minDistance = aRhs.m_minDistance;
185 m_exact = aRhs.m_exact;
186 m_refBBox = aRhs.m_refBBox;
193 while( m_current != m_end )
195 if( m_refBBox.Distance( m_current->bbox ) <= m_minDistance )
197 if( !m_exact || m_current->shape->Collide( m_shape, m_minDistance ) )
205 SHAPE_VEC_ITER m_end;
206 SHAPE_VEC_ITER m_current;
215 SHAPE_ENTRY s( aItem );
217 m_shapes.push_back( s );
220 void Remove(
const T aItem )
224 for( i = m_shapes.begin(); i != m_shapes.end(); ++i )
226 if( i->parent == aItem )
230 if( i == m_shapes.end() )
238 return m_shapes.size();
241 template <
class Visitor>
242 int Query(
const SHAPE* aShape,
int aMinDistance, Visitor& aV,
bool aExact =
true )
246 VECTOR2I::extended_type minDistSq = (VECTOR2I::extended_type) aMinDistance * aMinDistance;
250 for( i = m_shapes.begin(); i != m_shapes.end(); ++i )
252 if( refBBox.SquaredDistance( i->bbox ) <= minDistSq )
254 if( !aExact || i->shape->Collide( aShape, aMinDistance ) )
258 if( !aV( i->parent ) )
272 query_iterator qbegin(
SHAPE* aShape,
int aMinDistance,
bool aExact )
274 return query_iterator( m_shapes.begin(), m_shapes.end(), aShape, aMinDistance, aExact );
277 const query_iterator qend()
279 return query_iterator( m_shapes.end(), m_shapes.end(),
nullptr, 0,
false );
284 return iterator( m_shapes.begin() );
289 return iterator( m_shapes.end() );
virtual const BOX2I BBox(int aClearance=0) const =0
Compute a bounding box of the shape, with a margin of aClearance a collision.