Fix 2D broadphase remove-while-iterating logic

This commit is contained in:
Pedro J. Estébanez 2017-07-25 04:10:29 +02:00
parent fa1049b46b
commit 507b48179f

View file

@ -203,9 +203,11 @@ void BroadPhase2DHashGrid::_exit_grid(Element *p_elem, const Rect2 &p_rect, bool
if (sz.width * sz.height > large_object_min_surface) {
//unpair all elements, instead of checking all, just check what is already paired, so we at least save from checking static vs static
for (Map<Element *, PairData *>::Element *E = p_elem->paired.front(); E; E = E->next()) {
Map<Element *, PairData *>::Element *E = p_elem->paired.front();
while (E) {
Map<Element *, PairData *>::Element *next = E->next();
_unpair_attempt(p_elem, E->key());
E = next;
}
if (large_elements[p_elem].dec() == 0) {