lineBufferBuilder.begin(VertexFormat.DrawMode.DEBUG_LINES, VertexFormats.POSITION_COLOR);
}
- public static void drawSolidBox(MatrixStack.Entry matrixEntry, Box box, Color color, int alpha, boolean mask) {
+ public static void drawSolidBox(MatrixStack.Entry matrixEntry, Box box, Color color, int alpha, boolean mask, boolean sameX, boolean sameY, boolean sameZ) {
final float minX = (float) box.minX;
final float minY = (float) box.minY;
final float minZ = (float) box.minZ;
final BufferBuilder bufferBuilder = mask ? RenderBatch.quadBufferBuilderMasked : RenderBatch.quadBufferBuilderNonMasked;
- if (minX != maxX && minZ != maxZ) {
+ if (!sameX && !sameZ) {
if (mask) quadMaskedCount.getAndIncrement();
else quadNonMaskedCount.getAndIncrement();
- bufferBuilder.vertex(matrixEntry.getModel(), minX, minY, minZ).color(red, green, blue, alpha).next();
- bufferBuilder.vertex(matrixEntry.getModel(), maxX, minY, minZ).color(red, green, blue, alpha).next();
- bufferBuilder.vertex(matrixEntry.getModel(), maxX, minY, maxZ).color(red, green, blue, alpha).next();
- bufferBuilder.vertex(matrixEntry.getModel(), minX, minY, maxZ).color(red, green, blue, alpha).next();
+ bufferBuilder.vertex(matrixEntry.getPositionMatrix(), minX, minY, minZ).color(red, green, blue, alpha).next();
+ bufferBuilder.vertex(matrixEntry.getPositionMatrix(), maxX, minY, minZ).color(red, green, blue, alpha).next();
+ bufferBuilder.vertex(matrixEntry.getPositionMatrix(), maxX, minY, maxZ).color(red, green, blue, alpha).next();
+ bufferBuilder.vertex(matrixEntry.getPositionMatrix(), minX, minY, maxZ).color(red, green, blue, alpha).next();
+ if (!sameY) {
+ if (mask) quadMaskedCount.getAndIncrement();
+ else quadNonMaskedCount.getAndIncrement();
+ bufferBuilder.vertex(matrixEntry.getPositionMatrix(), minX, maxY, minZ).color(red, green, blue, alpha).next();
+ bufferBuilder.vertex(matrixEntry.getPositionMatrix(), minX, maxY, maxZ).color(red, green, blue, alpha).next();
+ bufferBuilder.vertex(matrixEntry.getPositionMatrix(), maxX, maxY, maxZ).color(red, green, blue, alpha).next();
+ bufferBuilder.vertex(matrixEntry.getPositionMatrix(), maxX, maxY, minZ).color(red, green, blue, alpha).next();
+ }
}
- if (minX != maxX && minZ != maxZ) {
+ if (!sameX && !sameY) {
if (mask) quadMaskedCount.getAndIncrement();
else quadNonMaskedCount.getAndIncrement();
- bufferBuilder.vertex(matrixEntry.getModel(), minX, maxY, minZ).color(red, green, blue, alpha).next();
- bufferBuilder.vertex(matrixEntry.getModel(), minX, maxY, maxZ).color(red, green, blue, alpha).next();
- bufferBuilder.vertex(matrixEntry.getModel(), maxX, maxY, maxZ).color(red, green, blue, alpha).next();
- bufferBuilder.vertex(matrixEntry.getModel(), maxX, maxY, minZ).color(red, green, blue, alpha).next();
+ bufferBuilder.vertex(matrixEntry.getPositionMatrix(), minX, minY, minZ).color(red, green, blue, alpha).next();
+ bufferBuilder.vertex(matrixEntry.getPositionMatrix(), minX, maxY, minZ).color(red, green, blue, alpha).next();
+ bufferBuilder.vertex(matrixEntry.getPositionMatrix(), maxX, maxY, minZ).color(red, green, blue, alpha).next();
+ bufferBuilder.vertex(matrixEntry.getPositionMatrix(), maxX, minY, minZ).color(red, green, blue, alpha).next();
+ if (!sameZ) {
+ if (mask) quadMaskedCount.getAndIncrement();
+ else quadNonMaskedCount.getAndIncrement();
+ bufferBuilder.vertex(matrixEntry.getPositionMatrix(), minX, minY, maxZ).color(red, green, blue, alpha).next();
+ bufferBuilder.vertex(matrixEntry.getPositionMatrix(), maxX, minY, maxZ).color(red, green, blue, alpha).next();
+ bufferBuilder.vertex(matrixEntry.getPositionMatrix(), maxX, maxY, maxZ).color(red, green, blue, alpha).next();
+ bufferBuilder.vertex(matrixEntry.getPositionMatrix(), minX, maxY, maxZ).color(red, green, blue, alpha).next();
+ }
}
- if (minX != maxX && minY != maxY) {
+ if (!sameY && !sameZ) {
if (mask) quadMaskedCount.getAndIncrement();
else quadNonMaskedCount.getAndIncrement();
- bufferBuilder.vertex(matrixEntry.getModel(), minX, minY, minZ).color(red, green, blue, alpha).next();
- bufferBuilder.vertex(matrixEntry.getModel(), minX, maxY, minZ).color(red, green, blue, alpha).next();
- bufferBuilder.vertex(matrixEntry.getModel(), maxX, maxY, minZ).color(red, green, blue, alpha).next();
- bufferBuilder.vertex(matrixEntry.getModel(), maxX, minY, minZ).color(red, green, blue, alpha).next();
+ bufferBuilder.vertex(matrixEntry.getPositionMatrix(), minX, minY, minZ).color(red, green, blue, alpha).next();
+ bufferBuilder.vertex(matrixEntry.getPositionMatrix(), minX, minY, maxZ).color(red, green, blue, alpha).next();
+ bufferBuilder.vertex(matrixEntry.getPositionMatrix(), minX, maxY, maxZ).color(red, green, blue, alpha).next();
+ bufferBuilder.vertex(matrixEntry.getPositionMatrix(), minX, maxY, minZ).color(red, green, blue, alpha).next();
+ if (!sameX) {
+ if (mask) quadMaskedCount.getAndIncrement();
+ else quadNonMaskedCount.getAndIncrement();
+ bufferBuilder.vertex(matrixEntry.getPositionMatrix(), maxX, minY, minZ).color(red, green, blue, alpha).next();
+ bufferBuilder.vertex(matrixEntry.getPositionMatrix(), maxX, maxY, minZ).color(red, green, blue, alpha).next();
+ bufferBuilder.vertex(matrixEntry.getPositionMatrix(), maxX, maxY, maxZ).color(red, green, blue, alpha).next();
+ bufferBuilder.vertex(matrixEntry.getPositionMatrix(), maxX, minY, maxZ).color(red, green, blue, alpha).next();
+ }
}
+ }
- if (minY != maxY && minZ != maxZ) {
- if (mask) quadMaskedCount.getAndIncrement();
- else quadNonMaskedCount.getAndIncrement();
- bufferBuilder.vertex(matrixEntry.getModel(), maxX, minY, minZ).color(red, green, blue, alpha).next();
- bufferBuilder.vertex(matrixEntry.getModel(), maxX, maxY, minZ).color(red, green, blue, alpha).next();
- bufferBuilder.vertex(matrixEntry.getModel(), maxX, maxY, maxZ).color(red, green, blue, alpha).next();
- bufferBuilder.vertex(matrixEntry.getModel(), maxX, minY, maxZ).color(red, green, blue, alpha).next();
- }
+ public static void drawFilledFace(MatrixStack.Entry matrixEntry, Point point1, Point point2, Point point3, Point point4, Color color, int alpha, boolean mask) {
+ int regionX = (((int) Camera.getX()) >> 9) * 512;
+ int regionZ = (((int) Camera.getZ()) >> 9) * 512;
- if (minX != maxX && minY != maxY) {
- if (mask) quadMaskedCount.getAndIncrement();
- else quadNonMaskedCount.getAndIncrement();
- bufferBuilder.vertex(matrixEntry.getModel(), minX, minY, maxZ).color(red, green, blue, alpha).next();
- bufferBuilder.vertex(matrixEntry.getModel(), maxX, minY, maxZ).color(red, green, blue, alpha).next();
- bufferBuilder.vertex(matrixEntry.getModel(), maxX, maxY, maxZ).color(red, green, blue, alpha).next();
- bufferBuilder.vertex(matrixEntry.getModel(), minX, maxY, maxZ).color(red, green, blue, alpha).next();
- }
+ if (mask) quadMaskedCount.getAndIncrement();
+ else quadNonMaskedCount.getAndIncrement();
- if (minY != maxY && minZ != maxZ) {
- if (mask) quadMaskedCount.getAndIncrement();
- else quadNonMaskedCount.getAndIncrement();
- bufferBuilder.vertex(matrixEntry.getModel(), minX, minY, minZ).color(red, green, blue, alpha).next();
- bufferBuilder.vertex(matrixEntry.getModel(), minX, minY, maxZ).color(red, green, blue, alpha).next();
- bufferBuilder.vertex(matrixEntry.getModel(), minX, maxY, maxZ).color(red, green, blue, alpha).next();
- bufferBuilder.vertex(matrixEntry.getModel(), minX, maxY, minZ).color(red, green, blue, alpha).next();
- }
+ final BufferBuilder bufferBuilder = mask ? RenderBatch.quadBufferBuilderMasked : RenderBatch.quadBufferBuilderNonMasked;
+
+ final float x1 = (float) point1.getX() - regionX;
+ final float y1 = (float) point1.getY();
+ final float z1 = (float) point1.getZ() - regionZ;
+ bufferBuilder.vertex(matrixEntry.getPositionMatrix(), x1, y1, z1).color(color.getRed(), color.getGreen(), color.getBlue(), alpha).next();
+
+ final float x2 = (float) point2.getX() - regionX;
+ final float y2 = (float) point2.getY();
+ final float z2 = (float) point2.getZ() - regionZ;
+ bufferBuilder.vertex(matrixEntry.getPositionMatrix(), x2, y2, z2).color(color.getRed(), color.getGreen(), color.getBlue(), alpha).next();
+
+ final float x3 = (float) point3.getX() - regionX;
+ final float y3 = (float) point3.getY();
+ final float z3 = (float) point3.getZ() - regionZ;
+ bufferBuilder.vertex(matrixEntry.getPositionMatrix(), x3, y3, z3).color(color.getRed(), color.getGreen(), color.getBlue(), alpha).next();
+
+ final float x4 = (float) point4.getX() - regionX;
+ final float y4 = (float) point4.getY();
+ final float z4 = (float) point4.getZ() - regionZ;
+ bufferBuilder.vertex(matrixEntry.getPositionMatrix(), x4, y4, z4).color(color.getRed(), color.getGreen(), color.getBlue(), alpha).next();
}
- static void drawLine(MatrixStack.Entry matrixEntry, Point startPoint, Point endPoint, Color color, int alpha) {
+ public static void drawLine(MatrixStack.Entry matrixEntry, Point startPoint, Point endPoint, Color color, int alpha) {
int regionX = (((int) Camera.getX()) >> 9) * 512;
int regionZ = (((int) Camera.getZ()) >> 9) * 512;
lineCount.getAndIncrement();
lineBufferBuilder
- .vertex(matrixEntry.getModel(),
+ .vertex(matrixEntry.getPositionMatrix(),
(float) startPoint.getX() - regionX,
(float) startPoint.getY(),
(float) startPoint.getZ() - regionZ)
.color(color.getRed(), color.getGreen(), color.getBlue(), alpha)
.next();
lineBufferBuilder
- .vertex(matrixEntry.getModel(),
+ .vertex(matrixEntry.getPositionMatrix(),
(float) endPoint.getX() - regionX,
(float) endPoint.getY(),
(float) endPoint.getZ() - regionZ)
static void endBatch() {
RenderSystem.setShader(GameRenderer::getPositionColorShader);
long startTime = System.nanoTime();
- quadBufferBuilderMasked.end();
- quadBufferBuilderNonMasked.end();
- lineBufferBuilder.end();
+ BufferBuilder.BuiltBuffer quadBufferMasked = quadBufferBuilderMasked.end();
+ BufferBuilder.BuiltBuffer quadBufferNonMasked = quadBufferBuilderNonMasked.end();
+ BufferBuilder.BuiltBuffer lineBuffer = lineBufferBuilder.end();
synchronized (mutex) {
quadMaskedCountLast.set(quadMaskedCount.get());
}
RenderSystem.depthMask(true);
- BufferRenderer.draw(quadBufferBuilderMasked);
- BufferRenderer.draw(lineBufferBuilder);
+ BufferRenderer.drawWithShader(quadBufferMasked);
+ BufferRenderer.drawWithShader(lineBuffer);
RenderSystem.depthMask(false);
- BufferRenderer.draw(quadBufferBuilderNonMasked);
+ BufferRenderer.drawWithShader(quadBufferNonMasked);
lastDurationNanos.set(System.nanoTime() - startTime);
RenderSystem.depthMask(true);
}
public static String debugString() {
- return String.format("[BBOR] Statistics: Filled faces: %d,%d Lines: %d @ %.2fms", quadMaskedCountLast.get(), quadNonMaskedCountLast.get(), lineCountLast.get(), lastDurationNanos.get() / 1_000_000.0);
+ return String.format("[BBOR] Statistics: Filled faces: %d+%d Lines: %d @ %.2fms", quadMaskedCountLast.get(), quadNonMaskedCountLast.get(), lineCountLast.get(), lastDurationNanos.get() / 1_000_000.0);
}
}