public Result < List < Long > > queryPolygons ( float [ ] center , float [ ] halfExtents , QueryFilter filter ) { if ( Objects . isNull ( center ) || ! vIsFinite ( center ) || Objects . isNull ( halfExtents ) || ! vIsFinite ( halfExtents ) || Objects . isNull ( filter ) ) { // return DT_FAILURE | DT_INVALID_PARAM; } float [ ] bmin = vSub ( center , halfExtents ) ; float [ ] bmax = vAdd ( center , halfExtents ) ; // Find tiles the query touches. int [ ] minxy = m_nav . calcTileLoc ( bmin ) ; int minx = minxy [ 0 ] ; int miny = minxy [ 1 ] ; int [ ] maxxy = m_nav . calcTileLoc ( bmax ) ; int maxx = maxxy [ 0 ] ; int maxy = maxxy [ 1 ] ; List < Long > polys = new ArrayList <> ( ) ; for ( int y = miny ; y <= maxy ; ++ y ) { for ( int x = minx ; x <= maxx ; ++ x ) { List < MeshTile > neis = m_nav . getTilesAt ( x , y ) ; for ( int j = 0 ; j < neis . size ( ) ; ++ j ) { List < Long > polysInTile = queryPolygonsInTile ( neis . get ( j ) , bmin , bmax , filter ) ; polys . addAll ( polysInTile ) ; } } } return Result . success ( polys ) ; }
Finds polygons that overlap the search box .