@@ -155,18 +155,103 @@ public IEnumerable<float2> ForEachAdditionalSegmentPoint()
155155 /// <param name="iterator">The generated segment points in grid coordinates.</param>
156156 private void DrawSegments ( IEnumerable < float2 > iterator )
157157 {
158- float2 last = editor . GridPointToScreen ( segment . position ) ;
159- GL . Color ( ( segment . selected && segment . next . selected ) ? ShapeEditorWindow . segmentPivotOutlineColor : segment . shape . segmentColor ) ;
158+ float2 last = segment . position ;
159+ var color = ( segment . selected && segment . next . selected ) ? ShapeEditorWindow . segmentPivotOutlineColor : segment . shape . segmentColor ;
160160
161161 foreach ( var point in iterator )
162162 {
163- float2 next = editor . GridPointToScreen ( point ) ;
164- GLUtilities . DrawLine ( 1.0f , last . x , last . y , next . x , next . y ) ;
165- last = next ;
163+ DrawGridLine ( 1.0f , last , point , color ) ;
164+ last = point ;
166165 }
167166
168- float2 final = editor . GridPointToScreen ( segment . next . position ) ;
169- GLUtilities . DrawLine ( 1.0f , last . x , last . y , final . x , final . y ) ;
167+ DrawGridLine ( 1.0f , last , segment . next . position , color ) ;
168+ }
169+
170+ private static readonly float2 mirrorXY = new float2 ( - 1f , - 1f ) ;
171+ private static readonly float2 mirrorX = new float2 ( - 1f , 1f ) ;
172+ private static readonly float2 mirrorY = new float2 ( 1f , - 1f ) ;
173+
174+ /// <summary>
175+ /// <see cref="GLUtilities.DrawLine"/> in grid coordinates that takes shape symmetry into account.
176+ /// </summary>
177+ private void DrawGridLine ( float thickness , float2 from , float2 to , Color beginColor , Color endColor )
178+ {
179+ var p1 = editor . GridPointToScreen ( from ) ;
180+ var p2 = editor . GridPointToScreen ( to ) ;
181+ GLUtilities . DrawLine ( thickness , p1 . x , p1 . y , p2 . x , p2 . y , beginColor , endColor ) ;
182+
183+ var symmetry = segment . shape . symmetryAxes ;
184+ if ( symmetry != SimpleGlobalAxis . None )
185+ {
186+ bool flipX = symmetry . HasFlag ( SimpleGlobalAxis . Horizontal ) ;
187+ bool flipY = symmetry . HasFlag ( SimpleGlobalAxis . Vertical ) ;
188+
189+ beginColor . a = 0.75f ;
190+ endColor . a = 0.75f ;
191+
192+ if ( flipX && flipY )
193+ {
194+ p1 = editor . GridPointToScreen ( from * mirrorXY ) ;
195+ p2 = editor . GridPointToScreen ( to * mirrorXY ) ;
196+ GLUtilities . DrawLine ( thickness , p1 . x , p1 . y , p2 . x , p2 . y , beginColor , endColor ) ;
197+ }
198+
199+ if ( flipX )
200+ {
201+ p1 = editor . GridPointToScreen ( from * mirrorX ) ;
202+ p2 = editor . GridPointToScreen ( to * mirrorX ) ;
203+ GLUtilities . DrawLine ( thickness , p1 . x , p1 . y , p2 . x , p2 . y , beginColor , endColor ) ;
204+ }
205+
206+ if ( flipY )
207+ {
208+ p1 = editor . GridPointToScreen ( from * mirrorY ) ;
209+ p2 = editor . GridPointToScreen ( to * mirrorY ) ;
210+ GLUtilities . DrawLine ( thickness , p1 . x , p1 . y , p2 . x , p2 . y , beginColor , endColor ) ;
211+ }
212+ }
213+ }
214+
215+ /// <summary>
216+ /// <see cref="GLUtilities.DrawLine"/> in grid coordinates that takes shape symmetry into account.
217+ /// </summary>
218+ private void DrawGridLine ( float thickness , float2 from , float2 to , Color color )
219+ {
220+ var p1 = editor . GridPointToScreen ( from ) ;
221+ var p2 = editor . GridPointToScreen ( to ) ;
222+ GL . Color ( color ) ;
223+ GLUtilities . DrawLine ( thickness , p1 . x , p1 . y , p2 . x , p2 . y ) ;
224+
225+ var symmetry = segment . shape . symmetryAxes ;
226+ if ( symmetry != SimpleGlobalAxis . None )
227+ {
228+ bool flipX = symmetry . HasFlag ( SimpleGlobalAxis . Horizontal ) ;
229+ bool flipY = symmetry . HasFlag ( SimpleGlobalAxis . Vertical ) ;
230+
231+ color . a = 0.75f ;
232+ GL . Color ( color ) ;
233+
234+ if ( flipX && flipY )
235+ {
236+ p1 = editor . GridPointToScreen ( from * mirrorXY ) ;
237+ p2 = editor . GridPointToScreen ( to * mirrorXY ) ;
238+ GLUtilities . DrawLine ( thickness , p1 . x , p1 . y , p2 . x , p2 . y ) ;
239+ }
240+
241+ if ( flipX )
242+ {
243+ p1 = editor . GridPointToScreen ( from * mirrorX ) ;
244+ p2 = editor . GridPointToScreen ( to * mirrorX ) ;
245+ GLUtilities . DrawLine ( thickness , p1 . x , p1 . y , p2 . x , p2 . y ) ;
246+ }
247+
248+ if ( flipY )
249+ {
250+ p1 = editor . GridPointToScreen ( from * mirrorY ) ;
251+ p2 = editor . GridPointToScreen ( to * mirrorY ) ;
252+ GLUtilities . DrawLine ( thickness , p1 . x , p1 . y , p2 . x , p2 . y ) ;
253+ }
254+ }
170255 }
171256
172257 /// <summary>Applies a generator by inserting the generated points as new segments.</summary>
0 commit comments