Skip to content

Commit

Permalink
fix: account for roll when calculating flight directors position
Browse files Browse the repository at this point in the history
Signed-off-by: Octol1ttle <[email protected]>
  • Loading branch information
Octol1ttle committed Feb 17, 2025
1 parent d8c9b17 commit 358a984
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,26 +77,26 @@ object ScreenSpace {
return pos.z > -1 && pos.z < 1
}

fun getX(heading: Float): Int? {
val vec: Vec3d = fromWorldSpace(Vec3d.fromPolar(0.0f, heading - 180.0f))
fun getX(heading: Float, useNoRollMatrix: Boolean = true): Int? {
val vec: Vec3d = fromWorldSpace(Vec3d.fromPolar(0.0f, heading - 180.0f), useNoRollMatrix)
if (!isVisible(vec)) {
return null
}

return vec.x.toInt()
}

fun getY(pitch: Float): Int? {
val vec: Vec3d = fromWorldSpace(Vec3d.fromPolar(-pitch, mc.entityRenderDispatcher.camera.yaw))
fun getY(pitch: Float, useNoRollMatrix: Boolean = true): Int? {
val vec: Vec3d = fromWorldSpace(Vec3d.fromPolar(-pitch, mc.entityRenderDispatcher.camera.yaw), useNoRollMatrix)
if (!isVisible(vec)) {
return null
}

return vec.y.toInt()
}

fun getVec3d(deltaPos: Vec3d): Vec3d? {
val vec: Vec3d = fromWorldSpace(deltaPos, false)
fun getVec3d(deltaPos: Vec3d, useNoRollMatrix: Boolean = true): Vec3d? {
val vec: Vec3d = fromWorldSpace(deltaPos, useNoRollMatrix)
if (!isVisible(vec)) {
return null
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ class FlightDirectorsDisplay(computers: ComputerView) : Display(computers) {
matrices.push()
matrices.translate(0, 0, -50)

val pitchY: Int = ScreenSpace.getY(computers.pitch.activeInput?.target ?: return) ?: return
val pitchY: Int = ScreenSpace.getY(computers.pitch.activeInput?.target ?: return, false) ?: return
drawHorizontalLine(this.centerXI - halfWidth, this.centerXI + halfWidth, pitchY, advisoryColor)

val headingX: Int = ScreenSpace.getX(computers.heading.activeInput?.target ?: return) ?: return
val headingX: Int = ScreenSpace.getX(computers.heading.activeInput?.target ?: return, false) ?: return
drawVerticalLine(headingX, this.centerYI - halfWidth, this.centerYI + halfWidth, advisoryColor)

matrices.pop()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class FlightPathDisplay(computers: ComputerView) : Display(computers) {

override fun render(drawContext: DrawContext) {
with(drawContext) {
val screenSpaceVec: Vec3d = ScreenSpace.getVec3d(computers.data.velocity) ?: return
val screenSpaceVec: Vec3d = ScreenSpace.getVec3d(computers.data.velocity, false) ?: return
val trueX: Int = screenSpaceVec.x.toInt()
val trueY: Int = screenSpaceVec.y.toInt()

Expand Down

0 comments on commit 358a984

Please sign in to comment.