Skip to content

Commit

Permalink
chore: better circle drawing method
Browse files Browse the repository at this point in the history
  • Loading branch information
Sychic committed Jan 20, 2024
1 parent d757468 commit 8817406
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/main/kotlin/gg/skytils/skytilsmod/utils/RenderUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -700,6 +700,18 @@ object RenderUtil {
}
}

fun drawCircle(matrixStack: UMatrixStack, x: Double, y: Double, z: Double, partialTicks: Float, radius: Double, edges: Int, r: Int, g: Int, b: Int, a: Int = 255) {
val ug = UGraphics.getFromTessellator()
val angleDelta = Math.PI * 2 / edges
GL11.glLineWidth(5f)
ug.beginWithDefaultShader(UGraphics.DrawMode.LINE_STRIP, UGraphics.CommonVertexFormats.POSITION_COLOR)
repeat(edges) { idx ->
ug.pos(matrixStack, x - mc.renderManager.viewerPosX + radius * cos(idx * angleDelta), y - mc.renderManager.viewerPosY, z - mc.renderManager.viewerPosZ + radius * sin(idx * angleDelta)).color(r, g, b, a).endVertex()
}
ug.pos(matrixStack, x + radius - mc.renderManager.viewerPosX, y - mc.renderManager.viewerPosY, z - mc.renderManager.viewerPosZ).color(r, g, b, a).endVertex()
ug.drawDirect()
}

fun getViewerPos(partialTicks: Float): Triple<Double, Double, Double> {
val viewer = mc.renderViewEntity
val viewerX = viewer.lastTickPosX + (viewer.posX - viewer.lastTickPosX) * partialTicks
Expand Down

0 comments on commit 8817406

Please sign in to comment.