@@ -64,45 +64,49 @@ public void Awake()
6464 Material = new Material ( "Shader \" Vertex Colors/Alpha\" {Category{Tags {\" Queue\" =\" Transparent\" \" IgnoreProjector\" =\" True\" \" RenderType\" =\" Transparent\" }SubShader {Cull Off ZWrite On Blend SrcAlpha OneMinusSrcAlpha Pass {BindChannels {Bind \" Color\" , color Bind \" Vertex\" , vertex}}}}}" ) ;
6565 }
6666
67- private void UpdateMesh ( Vector3d center , IAntenna a )
67+ private void UpdateMesh ( Vector3d center , IAntenna dish )
6868 {
6969 var camera = MapView . MapCamera . camera ;
7070
71- Vector3d antenna_pos = ScaledSpace . LocalToScaledSpace ( RTCore . Instance . Network [ a . Guid ] . Position ) ;
72- Vector3d planet_pos = ScaledSpace . LocalToScaledSpace ( center ) ;
71+ Vector3d antennaPos = ScaledSpace . LocalToScaledSpace ( RTCore . Instance . Network [ dish . Guid ] . Position ) ;
72+ Vector3d planetPos = ScaledSpace . LocalToScaledSpace ( center ) ;
7373
7474 CelestialBody refFrame = ( MapView . MapCamera . target . vessel != null
7575 ? MapView . MapCamera . target . vessel . mainBody
7676 : MapView . MapCamera . target . celestialBody ) ;
7777 Vector3 up = refFrame . transform . up ;
7878
79- var space = Vector3 . Cross ( planet_pos - antenna_pos , up ) . normalized * Vector3 . Distance ( antenna_pos , planet_pos ) * ( float ) Math . Tan ( Math . Acos ( a . CosAngle ) ) ;
80- var end1 = antenna_pos + ( planet_pos + space - antenna_pos ) . normalized * Math . Min ( a . Dish / ScaledSpace . ScaleFactor , Vector3 . Distance ( antenna_pos , planet_pos ) ) ;
81- var end2 = antenna_pos + ( planet_pos - space - antenna_pos ) . normalized * Math . Min ( a . Dish / ScaledSpace . ScaleFactor , Vector3 . Distance ( antenna_pos , planet_pos ) ) ;
79+ Vector3 space = Vector3 . Cross ( planetPos - antennaPos , up ) . normalized
80+ * Vector3 . Distance ( antennaPos , planetPos )
81+ * ( float ) Math . Tan ( Math . Acos ( dish . CosAngle ) ) ;
82+ Vector3d end1 = antennaPos + ( planetPos + space - antennaPos ) . normalized
83+ * Math . Min ( dish . Dish / ScaledSpace . ScaleFactor , Vector3 . Distance ( antennaPos , planetPos ) ) ;
84+ Vector3d end2 = antennaPos + ( planetPos - space - antennaPos ) . normalized
85+ * Math . Min ( dish . Dish / ScaledSpace . ScaleFactor , Vector3 . Distance ( antennaPos , planetPos ) ) ;
8286
8387
84- var line_start = camera . WorldToScreenPoint ( antenna_pos ) ;
85- var line_end1 = camera . WorldToScreenPoint ( end1 ) ;
86- var line_end2 = camera . WorldToScreenPoint ( end2 ) ;
87- var segment1 = new Vector3 ( line_end1 . y - line_start . y , line_start . x - line_end1 . x , 0 ) . normalized * ( LineWidth / 2 ) ;
88- var segment2 = new Vector3 ( line_end2 . y - line_start . y , line_start . x - line_end2 . x , 0 ) . normalized * ( LineWidth / 2 ) ;
88+ Vector3 lineStart = camera . WorldToScreenPoint ( antennaPos ) ;
89+ Vector3 lineEnd1 = camera . WorldToScreenPoint ( end1 ) ;
90+ Vector3 lineEnd2 = camera . WorldToScreenPoint ( end2 ) ;
91+ var segment1 = new Vector3 ( lineEnd1 . y - lineStart . y , lineStart . x - lineEnd1 . x , 0 ) . normalized * ( LineWidth / 2 ) ;
92+ var segment2 = new Vector3 ( lineEnd2 . y - lineStart . y , lineStart . x - lineEnd2 . x , 0 ) . normalized * ( LineWidth / 2 ) ;
8993
9094 if ( ! MapView . Draw3DLines )
9195 {
92- var dist = Screen . height / 2 ;
93- line_start . z = line_start . z > 0 ? dist : - dist ;
94- line_end1 . z = line_end1 . z > 0 ? dist : - dist ;
95- line_end2 . z = line_end2 . z > 0 ? dist : - dist ;
96+ int dist = Screen . height / 2 ;
97+ lineStart . z = lineStart . z > 0 ? dist : - dist ;
98+ lineEnd1 . z = lineEnd1 . z > 0 ? dist : - dist ;
99+ lineEnd2 . z = lineEnd2 . z > 0 ? dist : - dist ;
96100 }
97101
98- mPoints2D [ 0 ] = ( line_start - segment1 ) ;
99- mPoints2D [ 1 ] = ( line_start + segment1 ) ;
100- mPoints2D [ 2 ] = ( line_end1 - segment1 ) ;
101- mPoints2D [ 3 ] = ( line_end1 + segment1 ) ;
102- mPoints2D [ 4 ] = ( line_start - segment2 ) ;
103- mPoints2D [ 5 ] = ( line_start + segment2 ) ;
104- mPoints2D [ 6 ] = ( line_end2 - segment2 ) ;
105- mPoints2D [ 7 ] = ( line_end2 + segment2 ) ;
102+ mPoints2D [ 0 ] = ( lineStart - segment1 ) ;
103+ mPoints2D [ 1 ] = ( lineStart + segment1 ) ;
104+ mPoints2D [ 2 ] = ( lineEnd1 - segment1 ) ;
105+ mPoints2D [ 3 ] = ( lineEnd1 + segment1 ) ;
106+ mPoints2D [ 4 ] = ( lineStart - segment2 ) ;
107+ mPoints2D [ 5 ] = ( lineStart + segment2 ) ;
108+ mPoints2D [ 6 ] = ( lineEnd2 - segment2 ) ;
109+ mPoints2D [ 7 ] = ( lineEnd2 + segment2 ) ;
106110
107111 for ( int i = 0 ; i < 8 ; i ++ )
108112 {
0 commit comments