From d7902e06cd7285c72cd4ea2be6f18ead56a8775e Mon Sep 17 00:00:00 2001 From: Linnea Gräf Date: Thu, 18 Jan 2024 00:10:25 +0100 Subject: Add Ancestral Spade solver --- .../kotlin/moe/nea/firmament/util/render/RenderInWorldContext.kt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/main/kotlin/moe/nea/firmament/util') diff --git a/src/main/kotlin/moe/nea/firmament/util/render/RenderInWorldContext.kt b/src/main/kotlin/moe/nea/firmament/util/render/RenderInWorldContext.kt index aa54979..20f9de8 100644 --- a/src/main/kotlin/moe/nea/firmament/util/render/RenderInWorldContext.kt +++ b/src/main/kotlin/moe/nea/firmament/util/render/RenderInWorldContext.kt @@ -147,12 +147,16 @@ class RenderInWorldContext private constructor( } fun line(vararg points: Vec3d, lineWidth: Float = 10F) { + line(points.toList(), lineWidth) + } + + fun line(points: List, lineWidth: Float = 10F) { RenderSystem.setShader(GameRenderer::getRenderTypeLinesProgram) RenderSystem.lineWidth(lineWidth / pow(camera.pos.squaredDistanceTo(points.first()), 0.25).toFloat()) buffer.begin(VertexFormat.DrawMode.LINES, VertexFormats.LINES) buffer.fixedColor(255, 255, 255, 255) - points.toList().zipWithNext().forEach { (a, b) -> + points.zipWithNext().forEach { (a, b) -> doLine(matrixStack.peek(), buffer, a.x, a.y, a.z, b.x, b.y, b.z) } buffer.unfixColor() @@ -173,7 +177,7 @@ class RenderInWorldContext private constructor( ) { val normal = Vector3f(x.toFloat(), y.toFloat(), z.toFloat()) .sub(i.toFloat(), j.toFloat(), k.toFloat()) - .mul(-1F) + .normalize() buf.vertex(matrix.positionMatrix, i.toFloat(), j.toFloat(), k.toFloat()) .normal(matrix.normalMatrix, normal.x, normal.y, normal.z).next() buf.vertex(matrix.positionMatrix, x.toFloat(), y.toFloat(), z.toFloat()) -- cgit