Skip to content

Conversation

AzureAaron
Copy link
Collaborator

No description provided.

@AzureAaron AzureAaron added new feature This issue or PR is a new feature reviews needed This PR needs reviews labels Mar 31, 2024
@LifeIsAParadox LifeIsAParadox removed the reviews needed This PR needs reviews label Apr 4, 2024
kevinthegreat1
kevinthegreat1 previously approved these changes Apr 4, 2024
@LifeIsAParadox LifeIsAParadox added the merge me please Pull requests that are ready to merge label Apr 4, 2024
@olim88
Copy link
Contributor

olim88 commented Apr 4, 2024

I have created a fix for the line from the cursor being buggy. but do not have permission to push to the branch so the code is here.

added to RenderHelper

public static void renderLineFromCursor(WorldRenderContext context, Vec3d point, float[] colorComponents, float alpha, float lineWidth) {
        Vec3d camera = context.camera().getPos();
        MatrixStack matrices = context.matrixStack();

        matrices.push();
        matrices.translate(-camera.x, -camera.y, -camera.z);

        Tessellator tessellator = RenderSystem.renderThreadTesselator();
        BufferBuilder buffer = tessellator.getBuffer();
        Matrix4f positionMatrix = matrices.peek().getPositionMatrix();

        GL11.glEnable(GL11.GL_LINE_SMOOTH);
        GL11.glHint(GL11.GL_LINE_SMOOTH_HINT, GL11.GL_NICEST);

        RenderSystem.setShader(GameRenderer::getRenderTypeLinesProgram);
        RenderSystem.setShaderColor(1f, 1f, 1f, 1f);
        RenderSystem.lineWidth(lineWidth);
        RenderSystem.enableBlend();
        RenderSystem.defaultBlendFunc();
        RenderSystem.disableCull();
        RenderSystem.enableDepthTest();
        RenderSystem.depthFunc(GL11.GL_ALWAYS);

        Vec3d offset = Vec3d.fromPolar(context.camera().getPitch(),context.camera().getYaw());
        Vec3d cameraPoint = camera.add(offset);

        buffer.begin(DrawMode.LINES, VertexFormats.LINES);
        Vector3f normal = new Vector3f((float) offset.x, (float) offset.y, (float) offset.z);
        buffer
                .vertex(positionMatrix,  (float) cameraPoint.x ,   (float) cameraPoint.y, (float) cameraPoint.z)
                .color(colorComponents[0], colorComponents[1], colorComponents[2], alpha)
                .normal(normal.x,normal.y,normal.z)
                .next();

        buffer
                .vertex(positionMatrix, (float) point.getX(), (float) point.getY(), (float) point.getZ())
                .color(colorComponents[0], colorComponents[1], colorComponents[2], alpha)
                .normal(normal.x,normal.y,normal.z)
                .next();


        tessellator.draw();

        matrices.pop();
        GL11.glDisable(GL11.GL_LINE_SMOOTH);
        RenderSystem.lineWidth(1f);
        RenderSystem.enableCull();
        RenderSystem.depthFunc(GL11.GL_LEQUAL);
    }

And Changed ordered waypoints to use the function

RenderHelper.renderLineFromCursor(wrc, Vec3d.ofCenter(next.getPos().up()), LIGHT_GRAY, 1f, 5f);

@AzureAaron AzureAaron removed the merge me please Pull requests that are ready to merge label Apr 4, 2024
Co-authored-by: olim <bobq4582@gmail.com>
@LifeIsAParadox LifeIsAParadox added merge me please Pull requests that are ready to merge and removed reviews needed This PR needs reviews labels Apr 5, 2024
@AzureAaron AzureAaron merged commit eadb318 into SkyblockerMod:master Apr 6, 2024
@LifeIsAParadox LifeIsAParadox removed the merge me please Pull requests that are ready to merge label Apr 6, 2024
@AzureAaron AzureAaron deleted the ordered-waypoints branch April 6, 2024 08:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new feature This issue or PR is a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants