Skip to content

Commit

Permalink
Avoid a bazillion verts all at once
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchej123 committed Mar 9, 2024
1 parent 8f57b9a commit 62473af
Showing 1 changed file with 16 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,8 @@ private void renderCable(double x, double y, double z) {
GL11.glDepthMask(true);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
// Draw the cable
tessellator.startDrawingQuads();
tessellator.setColorOpaque_F(1F, 1F, 1F);
renderFullHelix(tessellator, x, y, z);
tessellator.draw();
// Reset open GL
GL11.glDisable(GL11.GL_BLEND);
OpenGlHelper.glBlendFunc(770, 771, 1, 0);
Expand Down Expand Up @@ -318,7 +316,7 @@ private void clockwiseHelixPart(Tessellator tes, double x, double y, double z, i

double sectionHeight = 8 * side;
int sections = (int) Math.ceil(CABLE_HEIGHT / sectionHeight);

// spotless:off
for (int i = 0; i < 8 * sections; i++) {
int j = (i + offset) % 8;
int k = (i + 1 + offset) % 8;
Expand All @@ -331,33 +329,13 @@ private void clockwiseHelixPart(Tessellator tes, double x, double y, double z, i
double lightMinV = cableLight.getMinV();
double lightMaxV = cableLight.getMaxV();

tes.addVertexWithUV(
x + 0.5f + edgeX[k],
y + side * i + side,
z + 0.5f + edgeZ[k],
lightMinU,
lightMaxV);
tes.addVertexWithUV(
x + 0.5f + edgeX[k],
y + side * i + (side + width),
z + 0.5f + edgeZ[k],
lightMinU,
lightMinV);
tes.addVertexWithUV(
x + 0.5f + edgeX[j],
y + side * i + width,
z + 0.5f + edgeZ[j],
lightMaxU,
lightMinV);
tes.addVertexWithUV(x + 0.5f + edgeX[k], y + side * i + side, z + 0.5f + edgeZ[k], lightMinU, lightMaxV);
tes.addVertexWithUV(x + 0.5f + edgeX[k], y + side * i + (side + width), z + 0.5f + edgeZ[k], lightMinU, lightMinV);
tes.addVertexWithUV(x + 0.5f + edgeX[j], y + side * i + width, z + 0.5f + edgeZ[j], lightMaxU, lightMinV);
tes.addVertexWithUV(x + 0.5f + edgeX[j], y + side * i, z + 0.5f + edgeZ[j], lightMaxU, lightMaxV);
} else {
tes.addVertexWithUV(x + 0.5f + edgeX[k], y + side * i + side, z + 0.5f + edgeZ[k], minU, maxV);
tes.addVertexWithUV(
x + 0.5f + edgeX[k],
y + side * i + (side + width),
z + 0.5f + edgeZ[k],
minU,
minV);
tes.addVertexWithUV(x + 0.5f + edgeX[k], y + side * i + (side + width), z + 0.5f + edgeZ[k], minU, minV);
tes.addVertexWithUV(x + 0.5f + edgeX[j], y + side * i + width, z + 0.5f + edgeZ[j], maxU, minV);
tes.addVertexWithUV(x + 0.5f + edgeX[j], y + side * i, z + 0.5f + edgeZ[j], maxU, maxV);
}
Expand All @@ -368,6 +346,7 @@ private void clockwiseHelixPart(Tessellator tes, double x, double y, double z, i
tes.addVertexWithUV(x + 0.5f + edgeX[k], y + side * i + (side + width), z + 0.5f + edgeZ[k], minU, minV);
tes.addVertexWithUV(x + 0.5f + edgeX[k], y + side * i + side, z + 0.5f + edgeZ[k], minU, maxV);
}
// spotless:on
}

/**
Expand All @@ -392,12 +371,22 @@ private void renderFullHelix(Tessellator tes, double x, double y, double z) {
double motorGlowMinV = motorGlow.getMinV();
double motorGlowMaxV = motorGlow.getMaxV();

tes.startDrawingQuads();
clockwiseHelixPart(tes, x, y - 23.0, z, 0, 2.0 / 5.4, 0.75, minU, maxU, minV, maxV);
tes.draw();
tes.startDrawingQuads();
clockwiseHelixPart(tes, x, y - 23.0, z, 2, 2.0 / 5.4, 0.75, minU, maxU, minV, maxV);
tes.draw();
tes.startDrawingQuads();
clockwiseHelixPart(tes, x, y - 23.0, z, 4, 2.0 / 5.4, 0.75, minU, maxU, minV, maxV);
tes.draw();
tes.startDrawingQuads();
clockwiseHelixPart(tes, x, y - 23.0, z, 6, 2.0 / 5.4, 0.75, minU, maxU, minV, maxV);
tes.draw();

tes.startDrawingQuads();
motorGlow(tes, x, y, z, motorGlowMinU, motorGlowMaxU, motorGlowMinV, motorGlowMaxV);
tes.draw();
}

/**
Expand Down

0 comments on commit 62473af

Please sign in to comment.