aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/util
diff options
context:
space:
mode:
authorLinnea Gräf <nea@nea.moe>2025-09-08 01:06:09 +0200
committerLinnea Gräf <nea@nea.moe>2025-09-08 01:06:09 +0200
commitc79363f792a7ea51f777cf4c0aa31e0869aebf0d (patch)
treeb5771ccaf5c73508baed00cb01c9d324df8188bc /src/main/kotlin/util
parentd11912b5e15758ef72926976f9e7ead6ee263e92 (diff)
downloadFirmament-c79363f792a7ea51f777cf4c0aa31e0869aebf0d.tar.gz
Firmament-c79363f792a7ea51f777cf4c0aa31e0869aebf0d.tar.bz2
Firmament-c79363f792a7ea51f777cf4c0aa31e0869aebf0d.zip
fix: reduce overlap between wireframe cubes and the blocks / the vanilla outline
Diffstat (limited to 'src/main/kotlin/util')
-rw-r--r--src/main/kotlin/util/render/RenderInWorldContext.kt21
1 files changed, 15 insertions, 6 deletions
diff --git a/src/main/kotlin/util/render/RenderInWorldContext.kt b/src/main/kotlin/util/render/RenderInWorldContext.kt
index e7e5d01..154c413 100644
--- a/src/main/kotlin/util/render/RenderInWorldContext.kt
+++ b/src/main/kotlin/util/render/RenderInWorldContext.kt
@@ -5,6 +5,7 @@ import java.lang.Math.pow
import org.joml.Matrix4f
import org.joml.Vector3f
import util.render.CustomRenderLayers
+import kotlin.math.pow
import net.minecraft.client.render.Camera
import net.minecraft.client.render.RenderLayer
import net.minecraft.client.render.RenderTickCounter
@@ -145,8 +146,16 @@ class RenderInWorldContext private constructor(
matrixStack.push()
// TODO: add color arg to this
// TODO: this does not render through blocks (or water layers) anymore
- RenderSystem.lineWidth(lineWidth / pow(camera.pos.squaredDistanceTo(blockPos.toCenterPos()), 0.25).toFloat())
- matrixStack.translate(blockPos.x.toFloat(), blockPos.y.toFloat(), blockPos.z.toFloat())
+ RenderSystem.lineWidth(lineWidth / camera.pos.squaredDistanceTo(blockPos.toCenterPos()).pow(0.25).toFloat())
+ val offset = 1 / 512F
+ matrixStack.translate(
+ blockPos.x.toFloat() - offset,
+ blockPos.y.toFloat() - offset,
+ blockPos.z.toFloat() - offset
+ )
+ val scale = 1 + 2 * offset
+ matrixStack.scale(scale, scale, scale)
+
buildWireFrameCube(matrixStack.peek(), buf)
matrixStack.pop()
vertexConsumers.draw()
@@ -176,11 +185,11 @@ class RenderInWorldContext private constructor(
buffer.vertex(matrix.positionMatrix, a.x.toFloat(), a.y.toFloat(), a.z.toFloat())
.color(color)
.normal(matrix, lastNormal0.x, lastNormal0.y, lastNormal0.z)
-
+
buffer.vertex(matrix.positionMatrix, b.x.toFloat(), b.y.toFloat(), b.z.toFloat())
.color(color)
.normal(matrix, normal.x, normal.y, normal.z)
-
+
}
}
@@ -203,11 +212,11 @@ class RenderInWorldContext private constructor(
buf.vertex(matrix.positionMatrix, i, j, k)
.normal(matrix, normal.x, normal.y, normal.z)
.color(-1)
-
+
buf.vertex(matrix.positionMatrix, x, y, z)
.normal(matrix, normal.x, normal.y, normal.z)
.color(-1)
-
+
}