diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/GraphRendering.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/GraphRendering.kt index d8ef7fe50..c20392fce 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/GraphRendering.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/GraphRendering.kt @@ -63,16 +63,23 @@ fun renderGraph( val xDiff = x1 - x0 val yDiff = y1 - y0 - val length = (xDiff.pow(2f) + yDiff.pow(2f)).pow(0.5f) - val angle = acos(xDiff / length) * yDiff.sign - PI / 2f // rotate 90 deg + if (yDiff.sign == 0f) { + builder.vertex(pose, x0, y0 + LINE_WIDTH / 2f, 0f) + builder.vertex(pose, x0, y0 - LINE_WIDTH / 2f, 0f) + builder.vertex(pose, x1, y1 - LINE_WIDTH / 2f, 0f) + builder.vertex(pose, x1, y1 + LINE_WIDTH / 2f, 0f) + } else { + val length = (xDiff.pow(2f) + yDiff.pow(2f)).pow(0.5f) + val angle = acos(xDiff / length) * yDiff.sign - PI / 2f // rotate 90 deg - val xDisp = cos(angle).toFloat() * LINE_WIDTH / 2f - val yDisp = sin(angle).toFloat() * LINE_WIDTH / 2f + val xDisp = cos(angle).toFloat() * LINE_WIDTH / 2f + val yDisp = sin(angle).toFloat() * LINE_WIDTH / 2f - builder.vertex(pose, x1 - xDisp, y1 + yDisp, 0f) - builder.vertex(pose, x1 + xDisp, y1 - yDisp, 0f) - builder.vertex(pose, x0 + xDisp, y0 - yDisp, 0f) - builder.vertex(pose, x0 - xDisp, y0 + yDisp, 0f) + builder.vertex(pose, x0 + xDisp, y0 + yDisp, 0f) + builder.vertex(pose, x0 - xDisp, y0 - yDisp, 0f) + builder.vertex(pose, x1 - xDisp, y1 - yDisp, 0f) + builder.vertex(pose, x1 + xDisp, y1 + yDisp, 0f) + } //graphics.renderRect(x0, y0, LINE_WIDTH, LINE_WIDTH)