From bf9cb76604b576607f4c6b70f8a51a1a12493b14 Mon Sep 17 00:00:00 2001 From: Brady Date: Mon, 17 Jul 2023 16:34:01 -0500 Subject: [PATCH 1/3] VulkanMod compatibility + use `LINES` instead of `DEBUG_LINES` --- src/main/java/baritone/utils/GuiClick.java | 1 - src/main/java/baritone/utils/IRenderer.java | 85 +++++++++++-------- .../java/baritone/utils/PathRenderer.java | 68 ++++++--------- 3 files changed, 76 insertions(+), 78 deletions(-) diff --git a/src/main/java/baritone/utils/GuiClick.java b/src/main/java/baritone/utils/GuiClick.java index ab0e5c4fa..7e1a9cfce 100644 --- a/src/main/java/baritone/utils/GuiClick.java +++ b/src/main/java/baritone/utils/GuiClick.java @@ -43,7 +43,6 @@ import java.util.Collections; import static baritone.api.command.IBaritoneChatControl.FORCE_COMMAND_PREFIX; -import static org.lwjgl.opengl.GL11.*; public class GuiClick extends Screen implements Helper { diff --git a/src/main/java/baritone/utils/IRenderer.java b/src/main/java/baritone/utils/IRenderer.java index c7415b96c..83436c408 100644 --- a/src/main/java/baritone/utils/IRenderer.java +++ b/src/main/java/baritone/utils/IRenderer.java @@ -20,17 +20,19 @@ import baritone.api.BaritoneAPI; import baritone.api.Settings; import baritone.utils.accessor.IEntityRenderManager; +import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.systems.RenderSystem; +import com.mojang.math.Matrix3f; import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.GameRenderer; import net.minecraft.client.renderer.texture.TextureManager; import com.mojang.blaze3d.vertex.*; import com.mojang.math.Matrix4f; +import net.minecraft.util.Mth; import net.minecraft.world.phys.AABB; import java.awt.*; -import static org.lwjgl.opengl.GL11.*; - public interface IRenderer { Tesselator tessellator = Tesselator.getInstance(); @@ -51,17 +53,23 @@ static void glColor(Color color, float alpha) { static void startLines(Color color, float alpha, float lineWidth, boolean ignoreDepth) { RenderSystem.enableBlend(); - RenderSystem.blendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ZERO); + RenderSystem.blendFuncSeparate( + GlStateManager.SourceFactor.SRC_ALPHA, + GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, + GlStateManager.SourceFactor.ONE, + GlStateManager.DestFactor.ZERO + ); glColor(color, alpha); RenderSystem.lineWidth(lineWidth); RenderSystem.disableTexture(); RenderSystem.depthMask(false); + RenderSystem.disableCull(); if (ignoreDepth) { RenderSystem.disableDepthTest(); } - //TODO: check - buffer.begin(VertexFormat.Mode.DEBUG_LINES, DefaultVertexFormat.POSITION_COLOR); + RenderSystem.setShader(GameRenderer::getRendertypeLinesShader); + buffer.begin(VertexFormat.Mode.LINES, DefaultVertexFormat.POSITION_COLOR_NORMAL); } static void startLines(Color color, float lineWidth, boolean ignoreDepth) { @@ -74,51 +82,56 @@ static void endLines(boolean ignoredDepth) { RenderSystem.enableDepthTest(); } + RenderSystem.enableCull(); RenderSystem.depthMask(true); RenderSystem.enableTexture(); RenderSystem.disableBlend(); } + static void emitLine(PoseStack stack, double x1, double y1, double z1, double x2, double y2, double z2) { + final Matrix4f matrix4f = stack.last().pose(); + final Matrix3f normal = stack.last().normal(); + + final double dx = x2 - x1; + final double dy = y2 - y1; + final double dz = z2 - z1; + + final double invMag = Mth.fastInvSqrt(dx * dx + dy * dy + dz * dz); + final float nx = (float) (dx * invMag); + final float ny = (float) (dy * invMag); + final float nz = (float) (dz * invMag); + + buffer.vertex(matrix4f, (float) x1, (float) y1, (float) z1) + .color(color[0], color[1], color[2], color[3]) + .normal(normal, nx, ny, nz) + .endVertex(); + buffer.vertex(matrix4f, (float) x2, (float) y2, (float) z2) + .color(color[0], color[1], color[2], color[3]) + .normal(normal, nx, ny, nz) + .endVertex(); + } + static void emitAABB(PoseStack stack, AABB aabb) { AABB toDraw = aabb.move(-renderManager.renderPosX(), -renderManager.renderPosY(), -renderManager.renderPosZ()); - Matrix4f matrix4f = stack.last().pose(); // bottom - buffer.vertex(matrix4f, (float) toDraw.minX, (float) toDraw.minY, (float) toDraw.minZ).color(color[0], color[1], color[2], color[3]).endVertex(); - buffer.vertex(matrix4f, (float) toDraw.maxX, (float) toDraw.minY, (float) toDraw.minZ).color(color[0], color[1], color[2], color[3]).endVertex(); - buffer.vertex(matrix4f, (float) toDraw.maxX, (float) toDraw.minY, (float) toDraw.minZ).color(color[0], color[1], color[2], color[3]).endVertex(); - buffer.vertex(matrix4f, (float) toDraw.maxX, (float) toDraw.minY, (float) toDraw.maxZ).color(color[0], color[1], color[2], color[3]).endVertex(); - buffer.vertex(matrix4f, (float) toDraw.maxX, (float) toDraw.minY, (float) toDraw.maxZ).color(color[0], color[1], color[2], color[3]).endVertex(); - buffer.vertex(matrix4f, (float) toDraw.minX, (float) toDraw.minY, (float) toDraw.maxZ).color(color[0], color[1], color[2], color[3]).endVertex(); - buffer.vertex(matrix4f, (float) toDraw.minX, (float) toDraw.minY, (float) toDraw.maxZ).color(color[0], color[1], color[2], color[3]).endVertex(); - buffer.vertex(matrix4f, (float) toDraw.minX, (float) toDraw.minY, (float) toDraw.minZ).color(color[0], color[1], color[2], color[3]).endVertex(); + emitLine(stack, toDraw.minX, toDraw.minY, toDraw.minZ, toDraw.maxX, toDraw.minY, toDraw.minZ); + emitLine(stack, toDraw.maxX, toDraw.minY, toDraw.minZ, toDraw.maxX, toDraw.minY, toDraw.maxZ); + emitLine(stack, toDraw.maxX, toDraw.minY, toDraw.maxZ, toDraw.minX, toDraw.minY, toDraw.maxZ); + emitLine(stack, toDraw.minX, toDraw.minY, toDraw.maxZ, toDraw.minX, toDraw.minY, toDraw.minZ); // top - buffer.vertex(matrix4f, (float) toDraw.minX, (float) toDraw.maxY, (float) toDraw.minZ).color(color[0], color[1], color[2], color[3]).endVertex(); - buffer.vertex(matrix4f, (float) toDraw.maxX, (float) toDraw.maxY, (float) toDraw.minZ).color(color[0], color[1], color[2], color[3]).endVertex(); - buffer.vertex(matrix4f, (float) toDraw.maxX, (float) toDraw.maxY, (float) toDraw.minZ).color(color[0], color[1], color[2], color[3]).endVertex(); - buffer.vertex(matrix4f, (float) toDraw.maxX, (float) toDraw.maxY, (float) toDraw.maxZ).color(color[0], color[1], color[2], color[3]).endVertex(); - buffer.vertex(matrix4f, (float) toDraw.maxX, (float) toDraw.maxY, (float) toDraw.maxZ).color(color[0], color[1], color[2], color[3]).endVertex(); - buffer.vertex(matrix4f, (float) toDraw.minX, (float) toDraw.maxY, (float) toDraw.maxZ).color(color[0], color[1], color[2], color[3]).endVertex(); - buffer.vertex(matrix4f, (float) toDraw.minX, (float) toDraw.maxY, (float) toDraw.maxZ).color(color[0], color[1], color[2], color[3]).endVertex(); - buffer.vertex(matrix4f, (float) toDraw.minX, (float) toDraw.maxY, (float) toDraw.minZ).color(color[0], color[1], color[2], color[3]).endVertex(); + emitLine(stack, toDraw.minX, toDraw.maxY, toDraw.minZ, toDraw.maxX, toDraw.maxY, toDraw.minZ); + emitLine(stack, toDraw.maxX, toDraw.maxY, toDraw.minZ, toDraw.maxX, toDraw.maxY, toDraw.maxZ); + emitLine(stack, toDraw.maxX, toDraw.maxY, toDraw.maxZ, toDraw.minX, toDraw.maxY, toDraw.maxZ); + emitLine(stack, toDraw.minX, toDraw.maxY, toDraw.maxZ, toDraw.minX, toDraw.maxY, toDraw.minZ); // corners - buffer.vertex(matrix4f, (float) toDraw.minX, (float) toDraw.minY, (float) toDraw.minZ).color(color[0], color[1], color[2], color[3]).endVertex(); - buffer.vertex(matrix4f, (float) toDraw.minX, (float) toDraw.maxY, (float) toDraw.minZ).color(color[0], color[1], color[2], color[3]).endVertex(); - buffer.vertex(matrix4f, (float) toDraw.maxX, (float) toDraw.minY, (float) toDraw.minZ).color(color[0], color[1], color[2], color[3]).endVertex(); - buffer.vertex(matrix4f, (float) toDraw.maxX, (float) toDraw.maxY, (float) toDraw.minZ).color(color[0], color[1], color[2], color[3]).endVertex(); - buffer.vertex(matrix4f, (float) toDraw.maxX, (float) toDraw.minY, (float) toDraw.maxZ).color(color[0], color[1], color[2], color[3]).endVertex(); - buffer.vertex(matrix4f, (float) toDraw.maxX, (float) toDraw.maxY, (float) toDraw.maxZ).color(color[0], color[1], color[2], color[3]).endVertex(); - buffer.vertex(matrix4f, (float) toDraw.minX, (float) toDraw.minY, (float) toDraw.maxZ).color(color[0], color[1], color[2], color[3]).endVertex(); - buffer.vertex(matrix4f, (float) toDraw.minX, (float) toDraw.maxY, (float) toDraw.maxZ).color(color[0], color[1], color[2], color[3]).endVertex(); + emitLine(stack, toDraw.minX, toDraw.minY, toDraw.minZ, toDraw.minX, toDraw.maxY, toDraw.minZ); + emitLine(stack, toDraw.maxX, toDraw.minY, toDraw.minZ, toDraw.maxX, toDraw.maxY, toDraw.minZ); + emitLine(stack, toDraw.maxX, toDraw.minY, toDraw.maxZ, toDraw.maxX, toDraw.maxY, toDraw.maxZ); + emitLine(stack, toDraw.minX, toDraw.minY, toDraw.maxZ, toDraw.minX, toDraw.maxY, toDraw.maxZ); } static void emitAABB(PoseStack stack, AABB aabb, double expand) { emitAABB(stack, aabb.inflate(expand, expand, expand)); } - - static void drawAABB(PoseStack stack, AABB aabb) { - buffer.begin(VertexFormat.Mode.DEBUG_LINES, DefaultVertexFormat.POSITION_COLOR); - emitAABB(stack, aabb); - tessellator.end(); - } } diff --git a/src/main/java/baritone/utils/PathRenderer.java b/src/main/java/baritone/utils/PathRenderer.java index 304de21cd..edb3bca5d 100644 --- a/src/main/java/baritone/utils/PathRenderer.java +++ b/src/main/java/baritone/utils/PathRenderer.java @@ -28,6 +28,7 @@ import baritone.pathing.path.PathExecutor; import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.math.Matrix3f; import com.mojang.math.Matrix4f; import net.minecraft.client.renderer.blockentity.BeaconRenderer; import net.minecraft.core.BlockPos; @@ -46,8 +47,6 @@ import java.util.Collections; import java.util.List; -import static org.lwjgl.opengl.GL11.*; - /** * @author Brady * @since 8/9/2018 @@ -168,31 +167,35 @@ private static void drawPath(PoseStack stack, IPath path, int startIndex, Color IRenderer.glColor(color, alpha); } - emitLine(stack, start.x, start.y, start.z, end.x, end.y, end.z); + emitPathLine(stack, start.x, start.y, start.z, end.x, end.y, end.z); } IRenderer.endLines(settings.renderPathIgnoreDepth.value); } - private static void emitLine(PoseStack stack, double x1, double y1, double z1, double x2, double y2, double z2) { - Matrix4f matrix4f = stack.last().pose(); + private static void emitPathLine(PoseStack stack, double x1, double y1, double z1, double x2, double y2, double z2) { double vpX = posX(); double vpY = posY(); double vpZ = posZ(); boolean renderPathAsFrickinThingy = !settings.renderPathAsLine.value; - buffer.vertex(matrix4f, (float) (x1 + 0.5D - vpX), (float) (y1 + 0.5D - vpY), (float) (z1 + 0.5D - vpZ)).color(color[0], color[1], color[2], color[3]).endVertex(); - buffer.vertex(matrix4f, (float) (x2 + 0.5D - vpX), (float) (y2 + 0.5D - vpY), (float) (z2 + 0.5D - vpZ)).color(color[0], color[1], color[2], color[3]).endVertex(); - + IRenderer.emitLine(stack, + x1 + 0.5D - vpX, y1 + 0.5D - vpY, z1 + 0.5D - vpZ, + x2 + 0.5D - vpX, y2 + 0.5D - vpY, z2 + 0.5D - vpZ + ); if (renderPathAsFrickinThingy) { - buffer.vertex(matrix4f, (float) (x2 + 0.5D - vpX), (float) (y2 + 0.5D - vpY), (float) (z2 + 0.5D - vpZ)).color(color[0], color[1], color[2], color[3]).endVertex(); - buffer.vertex(matrix4f, (float) (x2 + 0.5D - vpX), (float) (y2 + 0.53D - vpY), (float) (z2 + 0.5D - vpZ)).color(color[0], color[1], color[2], color[3]).endVertex(); - - buffer.vertex(matrix4f, (float) (x2 + 0.5D - vpX), (float) (y2 + 0.53D - vpY), (float) (z2 + 0.5D - vpZ)).color(color[0], color[1], color[2], color[3]).endVertex(); - buffer.vertex(matrix4f, (float) (x1 + 0.5D - vpX), (float) (y1 + 0.53D - vpY), (float) (z1 + 0.5D - vpZ)).color(color[0], color[1], color[2], color[3]).endVertex(); - - buffer.vertex(matrix4f, (float) (x1 + 0.5D - vpX), (float) (y1 + 0.53D - vpY), (float) (z1 + 0.5D - vpZ)).color(color[0], color[1], color[2], color[3]).endVertex(); - buffer.vertex(matrix4f, (float) (x1 + 0.5D - vpX), (float) (y1 + 0.5D - vpY), (float) (z1 + 0.5D - vpZ)).color(color[0], color[1], color[2], color[3]).endVertex(); + IRenderer.emitLine(stack, + x2 + 0.5D - vpX, y2 + 0.5D - vpY, z2 + 0.5D - vpZ, + x2 + 0.5D - vpX, y2 + 0.53D - vpY, z2 + 0.5D - vpZ + ); + IRenderer.emitLine(stack, + x2 + 0.5D - vpX, y2 + 0.53D - vpY, z2 + 0.5D - vpZ, + x1 + 0.5D - vpX, y1 + 0.53D - vpY, z1 + 0.5D - vpZ + ); + IRenderer.emitLine(stack, + x1 + 0.5D - vpX, y1 + 0.53D - vpY, z1 + 0.5D - vpZ, + x1 + 0.5D - vpX, y1 + 0.5D - vpY, z1 + 0.5D - vpZ + ); } } @@ -256,8 +259,6 @@ private static void drawGoal(PoseStack stack, IPlayerContext ctx, Goal goal, flo maxY = ctx.world().getMaxBuildHeight(); if (settings.renderGoalXZBeacon.value) { - glPushAttrib(GL_LIGHTING_BIT); - //TODO: check textureManager.bindForSetup(TEXTURE_BEACON_BEAM); if (settings.renderGoalIgnoreDepth.value) { @@ -289,8 +290,6 @@ private static void drawGoal(PoseStack stack, IPlayerContext ctx, Goal goal, flo if (settings.renderGoalIgnoreDepth.value) { RenderSystem.enableDepthTest(); } - - glPopAttrib(); return; } @@ -341,15 +340,10 @@ private static void drawDankLitGoalBox(PoseStack stack, Color colorIn, double mi renderHorizontalQuad(stack, minX, maxX, minZ, maxZ, y1); renderHorizontalQuad(stack, minX, maxX, minZ, maxZ, y2); - Matrix4f matrix4f = stack.last().pose(); - buffer.vertex(matrix4f, (float) minX, (float) minY, (float) minZ).color(color[0], color[1], color[2], color[3]).endVertex(); - buffer.vertex(matrix4f, (float) minX, (float) maxY, (float) minZ).color(color[0], color[1], color[2], color[3]).endVertex(); - buffer.vertex(matrix4f, (float) maxX, (float) minY, (float) minZ).color(color[0], color[1], color[2], color[3]).endVertex(); - buffer.vertex(matrix4f, (float) maxX, (float) maxY, (float) minZ).color(color[0], color[1], color[2], color[3]).endVertex(); - buffer.vertex(matrix4f, (float) maxX, (float) minY, (float) maxZ).color(color[0], color[1], color[2], color[3]).endVertex(); - buffer.vertex(matrix4f, (float) maxX, (float) maxY, (float) maxZ).color(color[0], color[1], color[2], color[3]).endVertex(); - buffer.vertex(matrix4f, (float) minX, (float) minY, (float) maxZ).color(color[0], color[1], color[2], color[3]).endVertex(); - buffer.vertex(matrix4f, (float) minX, (float) maxY, (float) maxZ).color(color[0], color[1], color[2], color[3]).endVertex(); + IRenderer.emitLine(stack, minX, minY, minZ, minX, maxY, minZ); + IRenderer.emitLine(stack, maxX, minY, minZ, maxX, maxY, minZ); + IRenderer.emitLine(stack, maxX, minY, maxZ, maxX, maxY, maxZ); + IRenderer.emitLine(stack, minX, minY, maxZ, minX, maxY, maxZ); if (setupRender) { IRenderer.endLines(settings.renderGoalIgnoreDepth.value); @@ -358,18 +352,10 @@ private static void drawDankLitGoalBox(PoseStack stack, Color colorIn, double mi private static void renderHorizontalQuad(PoseStack stack, double minX, double maxX, double minZ, double maxZ, double y) { if (y != 0) { - Matrix4f matrix4f = stack.last().pose(); - buffer.vertex(matrix4f, (float) minX, (float) y, (float) minZ).color(color[0], color[1], color[2], color[3]).endVertex(); - buffer.vertex(matrix4f, (float) maxX, (float) y, (float) minZ).color(color[0], color[1], color[2], color[3]).endVertex(); - - buffer.vertex(matrix4f, (float) maxX, (float) y, (float) minZ).color(color[0], color[1], color[2], color[3]).endVertex(); - buffer.vertex(matrix4f, (float) maxX, (float) y, (float) maxZ).color(color[0], color[1], color[2], color[3]).endVertex(); - - buffer.vertex(matrix4f, (float) maxX, (float) y, (float) maxZ).color(color[0], color[1], color[2], color[3]).endVertex(); - buffer.vertex(matrix4f, (float) minX, (float) y, (float) maxZ).color(color[0], color[1], color[2], color[3]).endVertex(); - - buffer.vertex(matrix4f, (float) minX, (float) y, (float) maxZ).color(color[0], color[1], color[2], color[3]).endVertex(); - buffer.vertex(matrix4f, (float) minX, (float) y, (float) minZ).color(color[0], color[1], color[2], color[3]).endVertex(); + IRenderer.emitLine(stack, minX, y, minZ, maxX, y, minZ); + IRenderer.emitLine(stack, maxX, y, minZ, maxX, y, maxZ); + IRenderer.emitLine(stack, maxX, y, maxZ, minX, y, maxZ); + IRenderer.emitLine(stack, minX, y, maxZ, minX, y, minZ); } } } From 6a9694b03a7fda9a4b0af7be9935a38be60a7760 Mon Sep 17 00:00:00 2001 From: Brady Date: Tue, 18 Jul 2023 15:24:21 -0500 Subject: [PATCH 2/3] Manually specify some normals, fix GoalXZ rendering --- src/main/java/baritone/utils/IRenderer.java | 58 +++++++++++-------- .../java/baritone/utils/PathRenderer.java | 19 +++--- 2 files changed, 46 insertions(+), 31 deletions(-) diff --git a/src/main/java/baritone/utils/IRenderer.java b/src/main/java/baritone/utils/IRenderer.java index 83436c408..e7a853859 100644 --- a/src/main/java/baritone/utils/IRenderer.java +++ b/src/main/java/baritone/utils/IRenderer.java @@ -89,9 +89,6 @@ static void endLines(boolean ignoredDepth) { } static void emitLine(PoseStack stack, double x1, double y1, double z1, double x2, double y2, double z2) { - final Matrix4f matrix4f = stack.last().pose(); - final Matrix3f normal = stack.last().normal(); - final double dx = x2 - x1; final double dy = y2 - y1; final double dz = z2 - z1; @@ -101,34 +98,49 @@ static void emitLine(PoseStack stack, double x1, double y1, double z1, double x2 final float ny = (float) (dy * invMag); final float nz = (float) (dz * invMag); - buffer.vertex(matrix4f, (float) x1, (float) y1, (float) z1) - .color(color[0], color[1], color[2], color[3]) - .normal(normal, nx, ny, nz) - .endVertex(); - buffer.vertex(matrix4f, (float) x2, (float) y2, (float) z2) - .color(color[0], color[1], color[2], color[3]) - .normal(normal, nx, ny, nz) - .endVertex(); + emitLine(stack, x1, y1, z1, x2, y2, z2, nx, ny, nz); + } + + static void emitLine(PoseStack stack, + double x1, double y1, double z1, + double x2, double y2, double z2, + double nx, double ny, double nz) { + emitLine(stack, + (float) x1, (float) y1, (float) z1, + (float) x2, (float) y2, (float) z2, + (float) nx, (float) ny, (float) nz + ); + } + + static void emitLine(PoseStack stack, + float x1, float y1, float z1, + float x2, float y2, float z2, + float nx, float ny, float nz) { + final Matrix4f matrix4f = stack.last().pose(); + final Matrix3f normal = stack.last().normal(); + + buffer.vertex(matrix4f, x1, y1, z1).color(color[0], color[1], color[2], color[3]).normal(normal, nx, ny, nz).endVertex(); + buffer.vertex(matrix4f, x2, y2, z2).color(color[0], color[1], color[2], color[3]).normal(normal, nx, ny, nz).endVertex(); } static void emitAABB(PoseStack stack, AABB aabb) { AABB toDraw = aabb.move(-renderManager.renderPosX(), -renderManager.renderPosY(), -renderManager.renderPosZ()); // bottom - emitLine(stack, toDraw.minX, toDraw.minY, toDraw.minZ, toDraw.maxX, toDraw.minY, toDraw.minZ); - emitLine(stack, toDraw.maxX, toDraw.minY, toDraw.minZ, toDraw.maxX, toDraw.minY, toDraw.maxZ); - emitLine(stack, toDraw.maxX, toDraw.minY, toDraw.maxZ, toDraw.minX, toDraw.minY, toDraw.maxZ); - emitLine(stack, toDraw.minX, toDraw.minY, toDraw.maxZ, toDraw.minX, toDraw.minY, toDraw.minZ); + emitLine(stack, toDraw.minX, toDraw.minY, toDraw.minZ, toDraw.maxX, toDraw.minY, toDraw.minZ, 1.0, 0.0, 0.0); + emitLine(stack, toDraw.maxX, toDraw.minY, toDraw.minZ, toDraw.maxX, toDraw.minY, toDraw.maxZ, 0.0, 0.0, 1.0); + emitLine(stack, toDraw.maxX, toDraw.minY, toDraw.maxZ, toDraw.minX, toDraw.minY, toDraw.maxZ, -1.0, 0.0, 0.0); + emitLine(stack, toDraw.minX, toDraw.minY, toDraw.maxZ, toDraw.minX, toDraw.minY, toDraw.minZ, 0.0, 0.0, -1.0); // top - emitLine(stack, toDraw.minX, toDraw.maxY, toDraw.minZ, toDraw.maxX, toDraw.maxY, toDraw.minZ); - emitLine(stack, toDraw.maxX, toDraw.maxY, toDraw.minZ, toDraw.maxX, toDraw.maxY, toDraw.maxZ); - emitLine(stack, toDraw.maxX, toDraw.maxY, toDraw.maxZ, toDraw.minX, toDraw.maxY, toDraw.maxZ); - emitLine(stack, toDraw.minX, toDraw.maxY, toDraw.maxZ, toDraw.minX, toDraw.maxY, toDraw.minZ); + emitLine(stack, toDraw.minX, toDraw.maxY, toDraw.minZ, toDraw.maxX, toDraw.maxY, toDraw.minZ, 1.0, 0.0, 0.0); + emitLine(stack, toDraw.maxX, toDraw.maxY, toDraw.minZ, toDraw.maxX, toDraw.maxY, toDraw.maxZ, 0.0, 0.0, 1.0); + emitLine(stack, toDraw.maxX, toDraw.maxY, toDraw.maxZ, toDraw.minX, toDraw.maxY, toDraw.maxZ, -1.0, 0.0, 0.0); + emitLine(stack, toDraw.minX, toDraw.maxY, toDraw.maxZ, toDraw.minX, toDraw.maxY, toDraw.minZ, 0.0, 0.0, -1.0); // corners - emitLine(stack, toDraw.minX, toDraw.minY, toDraw.minZ, toDraw.minX, toDraw.maxY, toDraw.minZ); - emitLine(stack, toDraw.maxX, toDraw.minY, toDraw.minZ, toDraw.maxX, toDraw.maxY, toDraw.minZ); - emitLine(stack, toDraw.maxX, toDraw.minY, toDraw.maxZ, toDraw.maxX, toDraw.maxY, toDraw.maxZ); - emitLine(stack, toDraw.minX, toDraw.minY, toDraw.maxZ, toDraw.minX, toDraw.maxY, toDraw.maxZ); + emitLine(stack, toDraw.minX, toDraw.minY, toDraw.minZ, toDraw.minX, toDraw.maxY, toDraw.minZ, 0.0, 1.0, 0.0); + emitLine(stack, toDraw.maxX, toDraw.minY, toDraw.minZ, toDraw.maxX, toDraw.maxY, toDraw.minZ, 0.0, 1.0, 0.0); + emitLine(stack, toDraw.maxX, toDraw.minY, toDraw.maxZ, toDraw.maxX, toDraw.maxY, toDraw.maxZ, 0.0, 1.0, 0.0); + emitLine(stack, toDraw.minX, toDraw.minY, toDraw.maxZ, toDraw.minX, toDraw.maxY, toDraw.maxZ, 0.0, 1.0, 0.0); } static void emitAABB(PoseStack stack, AABB aabb, double expand) { diff --git a/src/main/java/baritone/utils/PathRenderer.java b/src/main/java/baritone/utils/PathRenderer.java index edb3bca5d..88c56bc96 100644 --- a/src/main/java/baritone/utils/PathRenderer.java +++ b/src/main/java/baritone/utils/PathRenderer.java @@ -340,10 +340,13 @@ private static void drawDankLitGoalBox(PoseStack stack, Color colorIn, double mi renderHorizontalQuad(stack, minX, maxX, minZ, maxZ, y1); renderHorizontalQuad(stack, minX, maxX, minZ, maxZ, y2); - IRenderer.emitLine(stack, minX, minY, minZ, minX, maxY, minZ); - IRenderer.emitLine(stack, maxX, minY, minZ, maxX, maxY, minZ); - IRenderer.emitLine(stack, maxX, minY, maxZ, maxX, maxY, maxZ); - IRenderer.emitLine(stack, minX, minY, maxZ, minX, maxY, maxZ); + for (double y = minY; y < maxY; y += 16) { + double max = Math.min(maxY, y + 16); + IRenderer.emitLine(stack, minX, y, minZ, minX, max, minZ, 0.0, 1.0, 0.0); + IRenderer.emitLine(stack, maxX, y, minZ, maxX, max, minZ, 0.0, 1.0, 0.0); + IRenderer.emitLine(stack, maxX, y, maxZ, maxX, max, maxZ, 0.0, 1.0, 0.0); + IRenderer.emitLine(stack, minX, y, maxZ, minX, max, maxZ, 0.0, 1.0, 0.0); + } if (setupRender) { IRenderer.endLines(settings.renderGoalIgnoreDepth.value); @@ -352,10 +355,10 @@ private static void drawDankLitGoalBox(PoseStack stack, Color colorIn, double mi private static void renderHorizontalQuad(PoseStack stack, double minX, double maxX, double minZ, double maxZ, double y) { if (y != 0) { - IRenderer.emitLine(stack, minX, y, minZ, maxX, y, minZ); - IRenderer.emitLine(stack, maxX, y, minZ, maxX, y, maxZ); - IRenderer.emitLine(stack, maxX, y, maxZ, minX, y, maxZ); - IRenderer.emitLine(stack, minX, y, maxZ, minX, y, minZ); + IRenderer.emitLine(stack, minX, y, minZ, maxX, y, minZ, 1.0, 0.0, 0.0); + IRenderer.emitLine(stack, maxX, y, minZ, maxX, y, maxZ, 0.0, 0.0, 1.0); + IRenderer.emitLine(stack, maxX, y, maxZ, minX, y, maxZ, -1.0, 0.0, 0.0); + IRenderer.emitLine(stack, minX, y, maxZ, minX, y, minZ, 0.0, 0.0, -1.0); } } } From dfa838a6f94f3fc4090a30143ba24f0ec747f352 Mon Sep 17 00:00:00 2001 From: Brady Date: Tue, 18 Jul 2023 19:19:08 -0500 Subject: [PATCH 3/3] Replace `Mth.fastInvSqrt` with `1.0 / Math.sqrt` --- src/main/java/baritone/utils/IRenderer.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/baritone/utils/IRenderer.java b/src/main/java/baritone/utils/IRenderer.java index e7a853859..010346bd9 100644 --- a/src/main/java/baritone/utils/IRenderer.java +++ b/src/main/java/baritone/utils/IRenderer.java @@ -28,7 +28,6 @@ import net.minecraft.client.renderer.texture.TextureManager; import com.mojang.blaze3d.vertex.*; import com.mojang.math.Matrix4f; -import net.minecraft.util.Mth; import net.minecraft.world.phys.AABB; import java.awt.*; @@ -93,7 +92,7 @@ static void emitLine(PoseStack stack, double x1, double y1, double z1, double x2 final double dy = y2 - y1; final double dz = z2 - z1; - final double invMag = Mth.fastInvSqrt(dx * dx + dy * dy + dz * dz); + final double invMag = 1.0 / Math.sqrt(dx * dx + dy * dy + dz * dz); final float nx = (float) (dx * invMag); final float ny = (float) (dy * invMag); final float nz = (float) (dz * invMag);