ARMapRenderer: Move last/thisColor to Class scope to avoid GC, add some basic code tidying.
ARMapRenderer: Move last/thisColor to Class scope to avoid GC, add some basic code tidying.

--- a/ARMapRenderer.cs
+++ b/ARMapRenderer.cs
@@ -39,7 +39,12 @@
 		#region Fields
 		private Dictionary<Guid, LineRenderer> vesselLineRenderers;
 		private Dictionary<Guid, bool> vesselFrameCache;
+
+		#pragma warning disable 414
 		private bool dumpBool;
+		private Color lastColor;
+		private Color thisColor;
+		#pragma warning restore 414
 		#endregion
 
 		#region Properties
@@ -174,10 +179,10 @@
 		}
 		#endregion
 
+		#region Utility
 		private void SetRelayVertices(IAntennaRelay relay)
 		{
-			Color lastColor = default(Color);
-			Color thisColor;
+			lastColor = default(Color);
 
 			LineRenderer renderer = this[relay.vessel.id];
 			Vector3d start = ScaledSpace.LocalToScaledSpace(relay.vessel.GetWorldPos3D());
@@ -262,7 +267,7 @@
 			}
 		}
 
-		public void Cleanup()
+		private void Cleanup()
 		{
 			if (this.vesselLineRenderers != null && this.vesselLineRenderers.Count > 0)
 			{
@@ -279,6 +284,7 @@
 				this.vesselFrameCache.Clear();
 			}
 		}
+		#endregion
 	}
 }
 

--- a/AntennaRelay.cs
+++ b/AntennaRelay.cs
@@ -392,18 +392,27 @@
 					// Since bestOccludedSqrDistance is infinity if there are no occluded relays, this is safe
 					if (bestOccludedSqrDistance < kerbinSqrDistance)
 					{
+						log.AppendFormat("\n\tBest occluded relay is closer than Kerbin ({0} < {1})",
+							bestOccludedRelay, kerbinSqrDistance);
+						
 						this.KerbinDirect = false;
 
 						// If the nearest relay is closer than the best occluded relay, pick it.
 						// Since nearestRelaySqrDistane is infinity if there are no nearby relays, this is safe.
 						if (nearestRelaySqrDistance < bestOccludedSqrDistance)
 						{
+							log.AppendFormat("\n\t\t...but the nearest relay is closer ({0} < {1}), so picking it.",
+								nearestRelaySqrDistance, bestOccludedSqrDistance);
+							
 							this.targetRelay = nearestRelay;
 							this.firstOccludingBody = null;
 						}
 						// Otherwise, target the best occluded relay.
 						else
 						{
+							log.AppendFormat("\n\t\t...and closer than the nearest relay ({0} >= {1}), so picking it.",
+								nearestRelaySqrDistance, bestOccludedSqrDistance);
+							
 							this.targetRelay = bestOccludedRelay;
 							this.firstOccludingBody = bodyOccludingBestOccludedRelay;
 						}
@@ -412,18 +421,27 @@
 					// Since we have LOS, blank the first occluding body.
 					else
 					{
+						log.AppendFormat("\n\tKerbin is closer than the best occluded relay ({0} >= {1})",
+							bestOccludedRelay, kerbinSqrDistance);
+						
 						this.firstOccludingBody = null;
 
 						// If the nearest relay is closer than Kerbin, pick it.
 						// Since nearestRelaySqrDistane is infinity if there are no nearby relays, this is safe.
 						if (nearestRelaySqrDistance < kerbinSqrDistance)
 						{
+							log.AppendFormat("\n\t\t...but the nearest relay is closer ({0} < {1}), so picking it.",
+								nearestRelaySqrDistance, kerbinSqrDistance);
+							
 							this.KerbinDirect = false;
 							this.targetRelay = nearestRelay;
 						}
 						// Otherwise, pick Kerbin.
 						else
 						{
+							log.AppendFormat("\n\t\t...and closer than the nearest relay ({0} >= {1}), so picking it.",
+								nearestRelaySqrDistance, kerbinSqrDistance);
+							
 							this.KerbinDirect = true;
 							this.targetRelay = null;
 						}