final Iterator<ReadonlyVector3> it = getPoints().iterator();
if (renderCap == 0 || !it.hasNext()) {
return;
}
final ReadonlyColor fromColor;
final ReadonlyColor toColor;
final float fromWidth;
final float toWidth;
// we've already checked for all null cases earlier
if (isSecondary) {
fromColor = fromStyle.getSecondaryReadonlyColor();
toColor = toStyle.getSecondaryReadonlyColor();
fromWidth = fromStyle.getSecondaryWidth();
toWidth = toStyle.getSecondaryWidth();
} else {
fromColor = fromStyle.getMainReadonlyColor();
toColor = toStyle.getMainReadonlyColor();
fromWidth = fromStyle.getMainWidth();
toWidth = toStyle.getMainWidth();
}
final float blendEndpoint = getBlendEndpoint();
// We can't use GL_LINE_STRIP in a single drawing session because each
// line segment has its own style.
ReadonlyVector3 pointA = it.next();
ReadonlyVector3 pointB;
int lineNum = 0;
while (it.hasNext() && (renderCap < 0 || lineNum < renderCap)) {
pointB = it.next();
float percent = lineNum / blendEndpoint;
mc.startDrawing(GL11.GL_LINES);
GL11.glLineWidth(blend(fromWidth, toWidth, percent));
// fromColor.copy().blend(toColor, percent) would work, but this is
// a rendering method. Creating thousands of temporary objects that
// will just get GC'd should be avoided, so we operate on the
// individual RGBA components.
GL11.glColor4d(
blend(fromColor.getRed(), toColor.getRed(), percent),
blend(fromColor.getGreen(), toColor.getGreen(), percent),
blend(fromColor.getBlue(), toColor.getBlue(), percent),
blend(fromColor.getAlpha(), toColor.getAlpha(), percent));
mc.addVertex(pointA);
mc.addVertex(pointB);
mc.finishDrawing();
pointA = pointB;