Skip to content

Commit

Permalink
fix for scarpet shapes
Browse files Browse the repository at this point in the history
  • Loading branch information
gnembon committed May 22, 2024
1 parent 36c3501 commit fed9502
Showing 1 changed file with 29 additions and 29 deletions.
58 changes: 29 additions & 29 deletions src/main/java/carpet/script/utils/ShapesRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,7 @@ public void renderFaces(Tesselator tesselator, double cx, double cy, double cz,
}
builder.addVertex((float) (vec.x() - cx), (float) (vec.y() - cy), (float) (vec.z() - cz)).setColor(shape.fr, shape.fg, shape.fb, shape.fa);
}
BufferUploader.draw(builder.buildOrThrow());
BufferUploader.drawWithShader(builder.buildOrThrow());

RenderSystem.disableCull();
RenderSystem.depthMask(false);
Expand Down Expand Up @@ -746,7 +746,7 @@ public void renderLines(PoseStack matrices, Tesselator tesselator, double cx, do
builder.addVertex((float) (vec.x() - cx), (float) (vec.y() - cy), (float) (vec.z() - cz)).setColor(shape.r, shape.g, shape.b, shape.a);
}
builder.addVertex((float) (vec0.x() - cx), (float) (vec0.y() - cy), (float) (vec0.z() - cz)).setColor(shape.r, shape.g, shape.b, shape.a);
BufferUploader.draw(builder.buildOrThrow());
BufferUploader.drawWithShader(builder.buildOrThrow());
if (shape.inneredges)
{
BufferBuilder builderr = tesselator.begin(VertexFormat.Mode.DEBUG_LINES, DefaultVertexFormat.POSITION_COLOR);
Expand All @@ -761,7 +761,7 @@ public void renderLines(PoseStack matrices, Tesselator tesselator, double cx, do
builderr.addVertex((float) (vec.x() - cx), (float) (vec.y() - cy), (float) (vec.z() - cz)).setColor(shape.r, shape.g, shape.b, shape.a);
builderr.addVertex((float) (vec0.x() - cx), (float) (vec0.y() - cy), (float) (vec0.z() - cz)).setColor(shape.r, shape.g, shape.b, shape.a);
}
BufferUploader.draw(builderr.buildOrThrow());
BufferUploader.drawWithShader(builderr.buildOrThrow());
}
return;
}
Expand Down Expand Up @@ -806,7 +806,7 @@ public void renderLines(PoseStack matrices, Tesselator tesselator, double cx, do
builder.addVertex((float) (vec.x() - cx), (float) (vec.y() - cy), (float) (vec.z() - cz)).setColor(shape.r, shape.g, shape.b, shape.a);
}
}
BufferUploader.draw(builder.buildOrThrow());
BufferUploader.drawWithShader(builder.buildOrThrow());
return;
}
if (shape.mode == 4)
Expand Down Expand Up @@ -840,7 +840,7 @@ public void renderLines(PoseStack matrices, Tesselator tesselator, double cx, do
builder.addVertex((float) (vecC.x() - cx), (float) (vecC.y() - cy), (float) (vecC.z() - cz)).setColor(shape.r, shape.g, shape.b, shape.a);
builder.addVertex((float) (vecA.x() - cx), (float) (vecA.y() - cy), (float) (vecA.z() - cz)).setColor(shape.r, shape.g, shape.b, shape.a);
}
BufferUploader.draw(builder.buildOrThrow());
BufferUploader.drawWithShader(builder.buildOrThrow());
}
}
}
Expand Down Expand Up @@ -929,7 +929,7 @@ public static void drawLine(Tesselator tesselator, float x1, float y1, float z1,
BufferBuilder builder = tesselator.begin(VertexFormat.Mode.DEBUG_LINES, DefaultVertexFormat.POSITION_COLOR);
builder.addVertex(x1, y1, z1).setColor(red1, grn1, blu1, alpha);
builder.addVertex(x2, y2, z2).setColor(red1, grn1, blu1, alpha);
BufferUploader.draw(builder.buildOrThrow());
BufferUploader.drawWithShader(builder.buildOrThrow());
}

public static void drawBoxWireGLLines(
Expand Down Expand Up @@ -982,7 +982,7 @@ public static void drawBoxWireGLLines(
builder.addVertex(x2, y2, z1).setColor(red1, grn1, blu1, alpha);
builder.addVertex(x2, y2, z2).setColor(red1, grn1, blu1, alpha);
}
BufferUploader.draw(builder.buildOrThrow());
BufferUploader.drawWithShader(builder.buildOrThrow());
}

public static void drawBoxFaces(
Expand Down Expand Up @@ -1043,7 +1043,7 @@ public static void drawBoxFaces(
builder.addVertex(x1, y2, z2).setColor(red1, grn1, blu1, alpha);
}
}
BufferUploader.draw(builder.buildOrThrow());
BufferUploader.drawWithShader(builder.buildOrThrow());
}

public static void drawCylinderWireframe(Tesselator tesselator,
Expand Down Expand Up @@ -1076,7 +1076,7 @@ public static void drawCylinderWireframe(Tesselator tesselator,
float z = r * Mth.sin(theta);
builder.addVertex(x + cx, y + cy, z + cz).setColor(red, grn, blu, alpha);
}
BufferUploader.draw(builder.buildOrThrow());
BufferUploader.drawWithShader(builder.buildOrThrow());
}

if (!isFlat)
Expand All @@ -1094,7 +1094,7 @@ public static void drawCylinderWireframe(Tesselator tesselator,
builder.addVertex(cx + x, cy + h, cz - z).setColor(red, grn, blu, alpha);
builder.addVertex(cx - x, cy + h, cz + z).setColor(red, grn, blu, alpha);
builder.addVertex(cx - x, cy + 0, cz + z).setColor(red, grn, blu, alpha);
BufferUploader.draw(builder.buildOrThrow());
BufferUploader.drawWithShader(builder.buildOrThrow());
}
}
else
Expand All @@ -1108,7 +1108,7 @@ public static void drawCylinderWireframe(Tesselator tesselator,
builder.addVertex(cx - x, cy, cz + z).setColor(red, grn, blu, alpha);
builder.addVertex(cx + x, cy, cz - z).setColor(red, grn, blu, alpha);
}
BufferUploader.draw(builder.buildOrThrow());
BufferUploader.drawWithShader(builder.buildOrThrow());
}

}
Expand All @@ -1126,7 +1126,7 @@ else if (axis == Direction.Axis.X)
float y = r * Mth.sin(theta);
builder.addVertex(x + cx, y + cy, z + cz).setColor(red, grn, blu, alpha);
}
BufferUploader.draw(builder.buildOrThrow());
BufferUploader.drawWithShader(builder.buildOrThrow());
}

if (!isFlat)
Expand All @@ -1143,7 +1143,7 @@ else if (axis == Direction.Axis.X)
builder.addVertex(cx + 0, cy + y, cz - z).setColor(red, grn, blu, alpha);
builder.addVertex(cx + h, cy + y, cz - z).setColor(red, grn, blu, alpha);
builder.addVertex(cx + h, cy - y, cz + z).setColor(red, grn, blu, alpha);
BufferUploader.draw(builder.buildOrThrow());
BufferUploader.drawWithShader(builder.buildOrThrow());
}
}
else
Expand All @@ -1157,7 +1157,7 @@ else if (axis == Direction.Axis.X)
builder.addVertex(cx, cy - y, cz + z).setColor(red, grn, blu, alpha);
builder.addVertex(cx, cy + y, cz - z).setColor(red, grn, blu, alpha);
}
BufferUploader.draw(builder.buildOrThrow());
BufferUploader.drawWithShader(builder.buildOrThrow());
}
}
else if (axis == Direction.Axis.Z)
Expand All @@ -1174,7 +1174,7 @@ else if (axis == Direction.Axis.Z)
float x = r * Mth.sin(theta);
builder.addVertex(x + cx, y + cy, z + cz).setColor(red, grn, blu, alpha);
}
BufferUploader.draw(builder.buildOrThrow());
BufferUploader.drawWithShader(builder.buildOrThrow());
}
if (!isFlat)
{
Expand All @@ -1190,7 +1190,7 @@ else if (axis == Direction.Axis.Z)
builder.addVertex(cx - x, cy + y, cz + 0).setColor(red, grn, blu, alpha);
builder.addVertex(cx - x, cy + y, cz + h).setColor(red, grn, blu, alpha);
builder.addVertex(cx + x, cy - y, cz + h).setColor(red, grn, blu, alpha);
BufferUploader.draw(builder.buildOrThrow());
BufferUploader.drawWithShader(builder.buildOrThrow());
}
}
else
Expand All @@ -1204,7 +1204,7 @@ else if (axis == Direction.Axis.Z)
builder.addVertex(cx + x, cy - y, cz).setColor(red, grn, blu, alpha);
builder.addVertex(cx - x, cy + y, cz).setColor(red, grn, blu, alpha);
}
BufferUploader.draw(builder.buildOrThrow());
BufferUploader.drawWithShader(builder.buildOrThrow());
}

}
Expand All @@ -1231,7 +1231,7 @@ public static void drawCylinderFaces(Tesselator tesselator,
float z = r * Mth.sin(theta);
builder.addVertex(x + cx, cy, z + cz).setColor(red, grn, blu, alpha);
}
BufferUploader.draw(builder.buildOrThrow());
BufferUploader.drawWithShader(builder.buildOrThrow());
if (!isFlat)
{
BufferBuilder builderr = tesselator.begin(VertexFormat.Mode.TRIANGLE_FAN, DefaultVertexFormat.POSITION_COLOR);
Expand All @@ -1243,7 +1243,7 @@ public static void drawCylinderFaces(Tesselator tesselator,
float z = r * Mth.sin(theta);
builderr.addVertex(x + cx, cy + h, z + cz).setColor(red, grn, blu, alpha);
}
BufferUploader.draw(builderr.buildOrThrow());
BufferUploader.drawWithShader(builderr.buildOrThrow());

BufferBuilder builderrr = tesselator.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR); // quad strip to quads
float xp = r * 1;
Expand All @@ -1260,7 +1260,7 @@ public static void drawCylinderFaces(Tesselator tesselator,
xp = x;
zp = z;
}
BufferUploader.draw(builderrr.buildOrThrow());
BufferUploader.drawWithShader(builderrr.buildOrThrow());
}

}
Expand All @@ -1275,7 +1275,7 @@ else if (axis == Direction.Axis.X)
float z = r * Mth.sin(theta);
builder.addVertex(cx, cy + y, z + cz).setColor(red, grn, blu, alpha);
}
BufferUploader.draw(builder.buildOrThrow());
BufferUploader.drawWithShader(builder.buildOrThrow());
if (!isFlat)
{
BufferBuilder builderr = tesselator.begin(VertexFormat.Mode.TRIANGLE_FAN, DefaultVertexFormat.POSITION_COLOR);
Expand All @@ -1287,7 +1287,7 @@ else if (axis == Direction.Axis.X)
float z = r * Mth.sin(theta);
builderr.addVertex(cx + h, cy + y, cz + z).setColor(red, grn, blu, alpha);
}
BufferUploader.draw(builderr.buildOrThrow());
BufferUploader.drawWithShader(builderr.buildOrThrow());

BufferBuilder builderrr = tesselator.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR); // quad strip to quads
float yp = r * 1;
Expand All @@ -1304,7 +1304,7 @@ else if (axis == Direction.Axis.X)
yp = y;
zp = z;
}
BufferUploader.draw(builderrr.buildOrThrow());
BufferUploader.drawWithShader(builderrr.buildOrThrow());
}
}
else if (axis == Direction.Axis.Z)
Expand All @@ -1318,7 +1318,7 @@ else if (axis == Direction.Axis.Z)
float y = r * Mth.sin(theta);
builder.addVertex(x + cx, cy + y, cz).setColor(red, grn, blu, alpha);
}
BufferUploader.draw(builder.buildOrThrow());
BufferUploader.drawWithShader(builder.buildOrThrow());
if (!isFlat)
{
BufferBuilder builderr = tesselator.begin(VertexFormat.Mode.TRIANGLE_FAN, DefaultVertexFormat.POSITION_COLOR);
Expand All @@ -1330,7 +1330,7 @@ else if (axis == Direction.Axis.Z)
float y = r * Mth.sin(theta);
builderr.addVertex(x + cx, cy + y, cz + h).setColor(red, grn, blu, alpha);
}
BufferUploader.draw(builderr.buildOrThrow());
BufferUploader.drawWithShader(builderr.buildOrThrow());

BufferBuilder builderrr = tesselator.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR); // quad strip to quads
float xp = r;
Expand All @@ -1347,7 +1347,7 @@ else if (axis == Direction.Axis.Z)
xp = x;
yp = y;
}
BufferUploader.draw(builderrr.buildOrThrow());
BufferUploader.drawWithShader(builderrr.buildOrThrow());
}
}
}
Expand All @@ -1372,7 +1372,7 @@ public static void drawSphereWireframe(Tesselator tesselator,
float y = r * Mth.cos(phi);
builder.addVertex(x + cx, y + cy, z + cz).setColor(red, grn, blu, alpha);
}
BufferUploader.draw(builder.buildOrThrow());
BufferUploader.drawWithShader(builder.buildOrThrow());
}
for (int j = 0; j <= num_steps180; j++)
{
Expand All @@ -1387,7 +1387,7 @@ public static void drawSphereWireframe(Tesselator tesselator,
float y = r * Mth.cos(phi);
builder.addVertex(x + cx, y + cy, z + cz).setColor(red, grn, blu, alpha);
}
BufferUploader.draw(builder.buildOrThrow());
BufferUploader.drawWithShader(builder.buildOrThrow());
}

}
Expand Down Expand Up @@ -1429,7 +1429,7 @@ public static void drawSphereFaces(Tesselator tesselator,
zbp = zp;
yp = y;
}
BufferUploader.draw(builder.buildOrThrow());
BufferUploader.drawWithShader(builder.buildOrThrow());
}
}
}

0 comments on commit fed9502

Please sign in to comment.