Skip to content

Commit db01991

Browse files
committed
Fix potential NREs in Navball renderer (uncovered by NearFutureSpacecraft Rhea pod)
1 parent e425008 commit db01991

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

RasterPropMonitor/Handlers/JSIPrimaryFlightDisplay.cs

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -366,15 +366,21 @@ public bool RenderPFD(RenderTexture screen, float aspect)
366366
DrawMarker(markerDockingAlignment);
367367
DrawMarker(markerNavWaypoint);
368368

369-
var overlayMesh = overlay.GetComponent<MeshFilter>().mesh;
370-
var overlayMaterial = overlay.GetComponent<MeshRenderer>().material;
371-
overlayMaterial.SetPass(0);
372-
Graphics.DrawMeshNow(overlayMesh, overlay.transform.localToWorldMatrix);
373-
374-
var headingMesh = heading.GetComponent<MeshFilter>().mesh;
375-
var headingMaterial = heading.GetComponent<MeshRenderer>().material;
376-
headingMaterial.SetPass(0);
377-
Graphics.DrawMeshNow(headingMesh, heading.transform.localToWorldMatrix);
369+
if (overlay != null)
370+
{
371+
var overlayMesh = overlay.GetComponent<MeshFilter>().mesh;
372+
var overlayMaterial = overlay.GetComponent<MeshRenderer>().material;
373+
overlayMaterial.SetPass(0);
374+
Graphics.DrawMeshNow(overlayMesh, overlay.transform.localToWorldMatrix);
375+
}
376+
377+
if (heading != null)
378+
{
379+
var headingMesh = heading.GetComponent<MeshFilter>().mesh;
380+
var headingMaterial = heading.GetComponent<MeshRenderer>().material;
381+
headingMaterial.SetPass(0);
382+
Graphics.DrawMeshNow(headingMesh, heading.transform.localToWorldMatrix);
383+
}
378384

379385
GL.PopMatrix();
380386

0 commit comments

Comments
 (0)