diff --git a/3party/kdtree++/kdtree.hpp b/3party/kdtree++/kdtree.hpp index 08ce1a902c..3b2d8badeb 100644 --- a/3party/kdtree++/kdtree.hpp +++ b/3party/kdtree++/kdtree.hpp @@ -402,9 +402,11 @@ namespace KDTree template bool for_any(ToDo toDo) const { + bool wasСalled = false; if (_M_get_root()) - return _M_for_any(_M_get_root(), 0, toDo); - return false; + _M_for_any(_M_get_root(), 0, toDo, wasСalled); + + return wasСalled; } // compares via equality @@ -666,21 +668,24 @@ namespace KDTree } template - bool _M_for_any(_Link_const_type N, size_type const L, ToDo toDo) const + void _M_for_any(_Link_const_type N, size_type const L, ToDo toDo, bool & wasСalled) const { + if (wasСalled) + return; + if (toDo.DoIfIntersects(_S_value(N))) - return true; + { + wasСalled = true; + return; + } if (_S_left(N) && toDo.ScanLeft(L, _S_value(N))) - return _M_for_any(_S_left(N), L+1, toDo); + _M_for_any(_S_left(N), L+1, toDo, wasСalled); if (_S_right(N) && toDo.ScanRight(L, _S_value(N))) - return _M_for_any(_S_right(N), L+1, toDo); - - return false; + _M_for_any(_S_right(N), L+1, toDo, wasСalled); } - _Link_type _M_get_erase_replacement(_Link_type node, size_type const level) {