diff options
author | Linnea Gräf <nea@nea.moe> | 2024-09-06 20:23:01 +0200 |
---|---|---|
committer | Linnea Gräf <nea@nea.moe> | 2024-09-06 20:23:01 +0200 |
commit | 9cdc30e024fac9fe04eeeccb15dfd46f4aa648cb (patch) | |
tree | ddc3bbaee9a795dfa3b4ea774ce27d5cc7d93833 | |
parent | 94925ba3de7705345b30687f7845c3f850f489da (diff) | |
download | Firmament-9cdc30e024fac9fe04eeeccb15dfd46f4aa648cb.tar.gz Firmament-9cdc30e024fac9fe04eeeccb15dfd46f4aa648cb.tar.bz2 Firmament-9cdc30e024fac9fe04eeeccb15dfd46f4aa648cb.zip |
Fix tracer lines starting behind the player head
-rw-r--r-- | src/main/kotlin/util/render/RenderInWorldContext.kt | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/main/kotlin/util/render/RenderInWorldContext.kt b/src/main/kotlin/util/render/RenderInWorldContext.kt index 7faa499..775e8f3 100644 --- a/src/main/kotlin/util/render/RenderInWorldContext.kt +++ b/src/main/kotlin/util/render/RenderInWorldContext.kt @@ -49,6 +49,16 @@ class RenderInWorldContext private constructor( .transparency(RenderPhase.TRANSLUCENT_TRANSPARENCY) .program(RenderPhase.COLOR_PROGRAM) .build(false)) + val LINES = RenderLayer.of("firmament_rendertype_lines", + VertexFormats.LINES, + VertexFormat.DrawMode.LINES, + RenderLayer.DEFAULT_BUFFER_SIZE, + false, false, // do we need translucent? i dont think so + RenderLayer.MultiPhaseParameters.builder() + .depthTest(RenderPhase.ALWAYS_DEPTH_TEST) + .program(RenderPhase.LINES_PROGRAM) + .build(false) + ) } fun color(color: me.shedaniel.math.Color) { @@ -149,12 +159,11 @@ class RenderInWorldContext private constructor( } fun tracer(toWhere: Vec3d, lineWidth: Float = 3f) { - val cameraForward = Vector3f(0f, 0f, 1f).rotate(camera.rotation) + val cameraForward = Vector3f(0f, 0f, -1f).rotate(camera.rotation) line(camera.pos.add(Vec3d(cameraForward)), toWhere, lineWidth = lineWidth) } fun line(points: List<Vec3d>, lineWidth: Float = 10F) { - RenderSystem.setShader(GameRenderer::getRenderTypeLinesProgram) RenderSystem.lineWidth(lineWidth) val buffer = tesselator.begin(VertexFormat.DrawMode.LINES, VertexFormats.LINES) @@ -176,7 +185,7 @@ class RenderInWorldContext private constructor( .next() } - BufferRenderer.drawWithGlobalProgram(buffer.end()) + RenderLayers.LINES.draw(buffer.end()) } companion object { |