public static int findEdge ( Poly node , MeshData tile , float value , int comp ) { float error = Float . MAX_VALUE ; int edge = 0 ; for ( int i = 0 ; i < node . vertCount ; i ++ ) { int j = ( i + 1 ) % node . vertCount ; float v1 = tile . verts [ 3 * node . verts [ i ] + comp ] - value ; float v2 = tile . verts [ 3 * node . verts [ j ] + comp ] - value ; float d = v1 * v1 + v2 * v2 ; if ( d < error ) { error = d ; edge = i ; } } return edge ; }
Find edge closest to the given coordinate