ARMapRenderer: Fixed up some exceptional cases and generally made it mostly work sometimes for a while.
ARMapRenderer: Fixed up some exceptional cases and generally made it mostly work sometimes for a while.

--- a/ARMapRenderer.cs
+++ b/ARMapRenderer.cs
@@ -73,6 +73,7 @@
 		#region MonoBehaviour Lifecycle
 		private void Awake()
 		{
+			this.vesselLineRenderers = new Dictionary<Guid, LineRenderer>();
 			this.vesselFrameCache = new Dictionary<Guid, bool>();
 		}
 
@@ -88,30 +89,13 @@
 			try
 			{
 				log.AppendFormat("OnPreCull.\n");
-
-				double sma;
-
-				switch (MapView.MapCamera.target.type)
-				{
-					case MapObject.MapObjectType.CELESTIALBODY:
-						sma = MapView.MapCamera.target.celestialBody.orbit.semiMajorAxis;
-						break;
-					case MapObject.MapObjectType.VESSEL:
-						sma = MapView.MapCamera.target.vessel.orbit.semiMajorAxis;
-						break;
-					default:
-						sma = ScaledSpace.ScaleFactor;
-						break;
-				}
 
 				log.AppendFormat("\tMapView: Draw3DLines: {0}\n" +
 					"\tMapView.MapCamera.camera.fieldOfView: {1}\n" +
-					"\tMapView.MapCamera.Distance: {2}\n" +
-					"\tDistanceVSSMAFactor: {3}\n",
+					"\tMapView.MapCamera.Distance: {2}\n",
 					MapView.Draw3DLines,
 					MapView.MapCamera.camera.fieldOfView,
-					MapView.MapCamera.Distance,
-					(float)((double)MapView.MapCamera.Distance / Math.Abs(sma) * ScaledSpace.InverseScaleFactor)
+					MapView.MapCamera.Distance
 				);
 
 				this.vesselFrameCache.Clear();
@@ -143,6 +127,8 @@
 								continue;
 						}
 
+						log.Append("\tChecking connection status...\n");
+
 						if (vessel.HasConnectedRelay())
 						{
 							log.AppendLine("\tHas a connection, checking for the best relay to use for the line.");
@@ -185,10 +171,11 @@
 			}
 		}
 
-		private void Destroy()
+		private void OnDestroy()
 		{
 			this.vesselLineRenderers.Clear();
 			this.vesselLineRenderers = null;
+			print("ARMapRenderer: Destroyed.");
 		}
 		#endregion
 
@@ -210,6 +197,15 @@
 
 					renderer.enabled = true;
 
+					if (relay.transmitDistance < relay.nominalTransmitDistance)
+					{
+						renderer.SetColors(Color.green, Color.green);
+					}
+					else
+					{
+						renderer.SetColors(Color.yellow, Color.yellow);
+					}
+
 					start = ScaledSpace.LocalToScaledSpace(relay.vessel.GetWorldPos3D());
 
 					if (relay.nearestRelay == null)
@@ -235,8 +231,10 @@
 						end = MapView.MapCamera.camera.WorldToScreenPoint(end);
 
 						float d = Screen.height / 2f + 0.01f;
-						start.z = start.z >= 0.15f ? d : -d;
-						end.z = end.z >= 0.15f ? d : -d;
+						start.z = start.z >= 0f ? d : -d;
+						end.z = end.z >= 0f ? d : -d;
+
+						Debug.Log(string.Format("start.z: {0}", start.z));
 					}
 
 					renderer.SetWidth(lineWidth, lineWidth);