Skip to content

Commit bad3b3c

Browse files
committed
Fix #116: navball rendering for non-square screens
1 parent f6113cf commit bad3b3c

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

RasterPropMonitor/Handlers/JSIPrimaryFlightDisplay.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ struct Marker
114114
private bool firstRenderComplete;
115115

116116
float cameraSpan;
117+
float cameraSpanWidth;
117118

118119
private void ConfigureElements(float screenWidth, float screenHeight)
119120
{
@@ -138,6 +139,7 @@ private void ConfigureElements(float screenWidth, float screenHeight)
138139
// Figure out how we have to manipulate the camera to get the
139140
// navball in the right place, and in the right size.
140141
cameraSpan = navballRadius * screenHeight / navBallDiameter;
142+
cameraSpanWidth = navballRadius * screenWidth / navBallDiameter;
141143
float pixelSize = cameraSpan / (screenHeight * 0.5f);
142144

143145
float newXPos = navBallCenter.x - screenWidth * 0.5f;
@@ -352,7 +354,7 @@ public bool RenderPFD(RenderTexture screen, float aspect)
352354
// I wonder if doing this as a command buffer might be more efficient?
353355

354356
GL.PushMatrix();
355-
GL.LoadProjectionMatrix(Matrix4x4.Ortho(-cameraSpan, cameraSpan, -cameraSpan, cameraSpan, 0, 1.5f + navballRadius * 3));
357+
GL.LoadProjectionMatrix(Matrix4x4.Ortho(-cameraSpanWidth, cameraSpanWidth, -cameraSpan, cameraSpan, 0, 1.5f + navballRadius * 3));
356358

357359
var navballMeshFilter = navBall.GetComponent<MeshFilter>();
358360
var navballRenderer = navBall.GetComponent<MeshRenderer>();

0 commit comments

Comments
 (0)