Skip to content

Commit 666e696

Browse files
LachlanConnmeee1
authored andcommitted
HUD: Fix arc Drawing glitch
Floating point precision caused some errors in indexing and left some of the vertices in the array as 0 causing the arc to draw lines to origin.
1 parent e873bcc commit 666e696

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

ExtLibs/Controls/HUD.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1376,14 +1376,14 @@ public void DrawArc(Pen penn, RectangleF rect, float start, float degrees)
13761376

13771377
float x = 0, y = 0;
13781378
int length = 0;
1379-
for (float i = start; i <= start + degrees; i++)
1379+
for (int i = 0; i <= degrees; i++)
13801380
{
1381-
x = (float) Math.Sin(i * deg2rad) * rect.Width / 2;
1382-
y = (float) Math.Cos(i * deg2rad) * rect.Height / 2;
1381+
x = (float)Math.Sin((start + i) * deg2rad) * rect.Width / 2;
1382+
y = (float)Math.Cos((start + i) * deg2rad) * rect.Height / 2;
13831383
x = x + rect.X + rect.Width / 2;
13841384
y = y + rect.Y + rect.Height / 2;
1385-
vertices[(int)((i - start) * 2)] = x;
1386-
vertices[(int)((i - start) * 2 + 1)] = y;
1385+
vertices[i * 2] = x;
1386+
vertices[i * 2 + 1] = y;
13871387
length += 2;
13881388
//GL.Vertex2(x, y);
13891389
}

0 commit comments

Comments
 (0)