void OctreeNode::set_neibors() { OctreeNode* n; BBOX test_box = BBOX(min()-0.5*dim(), max()+0.5*dim()); if ((!_leaf || _display) && _height != 1) { for (int i = 0; i < 8; i++) { n = _parent->get_children()[i]; if (n != this && (!n->get_leaf() || n->get_disp())) { _neibors += n; } } _parent->neibors().num(); for (int i = 0; i < _parent->neibors().num(); i++) { n = _parent->neibors()[i]; if (!n->get_leaf()) { for (int j = 0; j < 8; j++) { if (n->get_children()[j]->overlaps(test_box) && (!n->get_children()[j]->get_leaf() || n->get_children()[j]->get_disp())) { //XXX - crashing here... _neibors += n->get_children()[j]; } } } } } if (!_leaf) { for (int i = 0; i < 8; i++) { _children[i]->set_neibors(); } } }