private void addRoundedCorner(@NonNull GeometryArrays geoArrays,@NonNull float[] center,float[] radius,float rads0,float rads1,int triangles,@NonNull RectF viewPort,float z){
  final float[] vertices=geoArrays.triangleVertices;
  final short[] indices=geoArrays.triangleIndices;
  final int verticesOffset=geoArrays.verticesOffset;
  final int indicesOffset=geoArrays.indicesOffset;
  for (int i=0; i < triangles; i++) {
    final int currentOffset=verticesOffset + i * 5 + (i > 0 ? 2 * 5 : 0);
    final float rads=rads0 + (rads1 - rads0) * (i / (float)triangles);
    final float radsNext=rads0 + (rads1 - rads0) * ((i + 1) / (float)triangles);
    final int triangleEdge2Offset;
    if (i == 0) {
      vertices[currentOffset]=center[0];
      vertices[currentOffset + 1]=center[1];
      vertices[currentOffset + 2]=z;
      vertices[currentOffset + 3]=(vertices[currentOffset] - viewPort.left) / viewPort.width();
      vertices[currentOffset + 4]=(vertices[currentOffset + 1] - viewPort.bottom) / -viewPort.height();
      vertices[currentOffset + 5]=center[0] + radius[0] * (float)Math.cos(rads);
      vertices[currentOffset + 6]=center[1] + radius[1] * (float)Math.sin(rads);
      vertices[currentOffset + 7]=z;
      vertices[currentOffset + 8]=(vertices[currentOffset + 5] - viewPort.left) / viewPort.width();
      vertices[currentOffset + 9]=(vertices[currentOffset + 6] - viewPort.bottom) / -viewPort.height();
      triangleEdge2Offset=10;
    }
 else {
      triangleEdge2Offset=0;
    }
    final int edge2Offset=currentOffset + triangleEdge2Offset;
    vertices[edge2Offset]=center[0] + radius[0] * (float)Math.cos(radsNext);
    vertices[edge2Offset + 1]=center[1] + radius[1] * (float)Math.sin(radsNext);
    vertices[edge2Offset + 2]=z;
    vertices[edge2Offset + 3]=(vertices[edge2Offset] - viewPort.left) / viewPort.width();
    vertices[edge2Offset + 4]=(vertices[edge2Offset + 1] - viewPort.bottom) / -viewPort.height();
    final int initialIdx=verticesOffset / 5;
    indices[indicesOffset + i * 3]=(short)(initialIdx);
    indices[indicesOffset + i * 3 + 1]=(short)(initialIdx + i + 1);
    indices[indicesOffset + i * 3 + 2]=(short)(initialIdx + i + 2);
  }
}

private void addRoundedCorner ( @ NonNull GeometryArrays geoArrays , @ NonNull float [ ] center , float [ ] radius , float rads0 , float rads1 , int triangles , @ NonNull RectF viewPort , float z ) { final float [ ] vertices = geoArrays . triangleVertices ; final short [ ] indices = geoArrays . triangleIndices ; final int verticesOffset = geoArrays . verticesOffset ; final int indicesOffset = geoArrays . indicesOffset ; for ( int i = 0 ; i < triangles ; i ++ ) { final int currentOffset = verticesOffset + i * 5 + ( i > 0 ? 2 * 5 : 0 ) ; final float rads = rads0 + ( rads1 - rads0 ) * ( i / ( float ) triangles ) ; final float radsNext = rads0 + ( rads1 - rads0 ) * ( ( i + 1 ) / ( float ) triangles ) ; final int triangleEdge2Offset ; if ( i == 0 ) { vertices [ currentOffset ] = center [ 0 ] ; vertices [ currentOffset + 1 ] = center [ 1 ] ; vertices [ currentOffset + 2 ] = z ; vertices [ currentOffset + 3 ] = ( vertices [ currentOffset ] - viewPort . left ) / viewPort . width ( ) ; vertices [ currentOffset + 4 ] = ( vertices [ currentOffset + 1 ] - viewPort . bottom ) / - viewPort . height ( ) ; vertices [ currentOffset + 5 ] = center [ 0 ] + radius [ 0 ] * ( float ) Math . cos ( rads ) ; vertices [ currentOffset + 6 ] = center [ 1 ] + radius [ 1 ] * ( float ) Math . sin ( rads ) ; vertices [ currentOffset + 7 ] = z ; vertices [ currentOffset + 8 ] = ( vertices [ currentOffset + 5 ] - viewPort . left ) / viewPort . width ( ) ; vertices [ currentOffset + 9 ] = ( vertices [ currentOffset + 6 ] - viewPort . bottom ) / - viewPort . height ( ) ; triangleEdge2Offset = 10 ; } else { triangleEdge2Offset = 0 ; } final int edge2Offset = currentOffset + triangleEdge2Offset ; vertices [ edge2Offset ] = center [ 0 ] + radius [ 0 ] * ( float ) Math . cos ( radsNext ) ; vertices [ edge2Offset + 1 ] = center [ 1 ] + radius [ 1 ] * ( float ) Math . sin ( radsNext ) ; vertices [ edge2Offset + 2 ] = z ; vertices [ edge2Offset + 3 ] = ( vertices [ edge2Offset ] - viewPort . left ) / viewPort . width ( ) ; vertices [ edge2Offset + 4 ] = ( vertices [ edge2Offset + 1 ] - viewPort . bottom ) / - viewPort . height ( ) ; final int initialIdx = verticesOffset / 5 ; indices [ indicesOffset + i * 3 ] = ( short ) ( initialIdx ) ; indices [ indicesOffset + i * 3 + 1 ] = ( short ) ( initialIdx + i + 1 ) ; indices [ indicesOffset + i * 3 + 2 ] = ( short ) ( initialIdx + i + 2 ) ; } }
adds the vertices of a number of triangles to form a rounded corner . the triangles start at some center point and will sweep from a given initial angle up to a final one . the size of the triangles is defined by the radius . the array of vertices passed in must have the required length to add the geometry points ( 5 floats for each vertex ) . also the coordinates of the rect corners should already be in the view port space .
