From 42eee2bba7b4132d3075ee10c1d895beb55724e3 Mon Sep 17 00:00:00 2001 From: minjaesong Date: Mon, 24 Mar 2025 22:02:07 +0900 Subject: [PATCH] small steps man :p --- .../modulebasegame/gameactors/ActorConveyors.kt | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/net/torvald/terrarum/modulebasegame/gameactors/ActorConveyors.kt b/src/net/torvald/terrarum/modulebasegame/gameactors/ActorConveyors.kt index ac0077bd0..5b96c2c18 100644 --- a/src/net/torvald/terrarum/modulebasegame/gameactors/ActorConveyors.kt +++ b/src/net/torvald/terrarum/modulebasegame/gameactors/ActorConveyors.kt @@ -217,9 +217,19 @@ class ActorConveyors : ActorWithBody { tooltipText = "di=$di, dd=$dd\nsegLen=$segmentLen\ntotalSegCnt=$c\nlSegCnt=$lSegCnt\ncSegCnt=$cSegCnt\ncSegOffset=$cSegOffset\nturnOffset=$turnOffset\nr=$r" for (i in 0 until 3) { // it.color = listOf(Color.LIME, Color.CORAL, Color.CYAN)[i] - drawArcOnWorld(cx2, cy2, r, - di - turnOffset - segmentLen * (-i + turn) / r, // use `di` as the baseline - -(segmentLen * 0.25) / r, 2f) + + val arcStart = di - turnOffset - segmentLen * (-i + turn) / r // use `di` as the baseline + val arcSize = -(segmentLen * 0.25) / r + val arcEnd = arcStart + arcSize + val arcRange = di-Math.PI..di + + // if the arc overlaps the larger arc... + if (arcStart in arcRange || arcEnd in arcRange) + drawArcOnWorld(cx2, cy2, r, + arcStart.coerceIn(arcRange), // this doesn't work due to sign flipping + arcSize.coerceIn(arcRange), + 2f + ) } // bottom straight part @@ -273,7 +283,6 @@ class ActorConveyors : ActorWithBody { private fun drawArcOnWorld(xc: Double, yc: Double, r: Double, arcStart: Double, arcDeg: Double, width: Float) { // dissect the circle - val pathLen = (arcDeg * r).absoluteValue * 2 //// estimated number of segments. pathLen divided by sqrt(2) val segments = (4 * Math.cbrt(r) * arcDeg.absoluteValue).toInt().coerceAtLeast(1)