]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/client/miscfunctions.qc
Merge branch 'divVerent/simpler-clipped-rectangle' into 'master'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / miscfunctions.qc
index d801ceabd7d7ccde6edf099e3aacd4b6f67b1a44..a7af09c7c82a146fcc259558ae8c46e9bd789a2c 100644 (file)
@@ -422,7 +422,6 @@ void PolyDrawModel(entity e)
 
 void DrawCircleClippedPic(vector centre, float radi, string pic, float f, vector rgb, float a, float drawflag)
 {
-       float d;
        vector ringsize, v, t;
        ringsize = radi * '1 1 0';
        centre = HUD_Shift(centre);
@@ -454,22 +453,11 @@ void DrawCircleClippedPic(vector centre, float radi, string pic, float f, vector
                        v.y -= 0.5 * ringsize.y;        t -= '0.5 -0.5 0';
                        R_PolygonVertex(v, t, rgb, a);
                R_EndPolygon();
-
-               d = q - 1;
-               if(d > 0)
-               {
-                       R_BeginPolygon(pic, drawflag, true);
-                               v = centre;                     t = '0.5 0.5 0';
-                               R_PolygonVertex(v, t, rgb, a);
-
-                               v = centre;                     t = '0.5 0.5 0';
-                               v.x += 0.5 * ringsize.x;        t += '0.5 0.5 0';
-                               R_PolygonVertex(v, t, rgb, a);
-               }
+               return;  // Complete rectangle, nothing more needed.
        }
        else if(f > 0.75)
        {
-               // draw upper and first triangle
+               // draw upper half in full
                R_BeginPolygon(pic, drawflag, true);
                        v = centre;                     t = '0.5 0.5 0';
                        v.x += 0.5 * ringsize.x;        t += '0.5 0.5 0';
@@ -483,6 +471,7 @@ void DrawCircleClippedPic(vector centre, float radi, string pic, float f, vector
                        v.x -= 0.5 * ringsize.x;        t -= '0.5 0.5 0';
                        R_PolygonVertex(v, t, rgb, a);
                R_EndPolygon();
+               // draw clipped lower half as a quad
                R_BeginPolygon(pic, drawflag, true);
                        v = centre;                     t = '0.5 0.5 0';
                        R_PolygonVertex(v, t, rgb, a);
@@ -494,14 +483,10 @@ void DrawCircleClippedPic(vector centre, float radi, string pic, float f, vector
                        v = centre;                     t = '0.5 0.5 0';
                        v.y -= 0.5 * ringsize.y;        t -= '0.5 -0.5 0';
                        R_PolygonVertex(v, t, rgb, a);
-
-               d = q - 0.75;
-               if(d <= 0)
-                       R_EndPolygon();
        }
        else if(f > 0.5)
        {
-               // draw upper triangle
+               // draw upper half in full
                R_BeginPolygon(pic, drawflag, true);
                        v = centre;                     t = '0.5 0.5 0';
                        v.x += 0.5 * ringsize.x;        t += '0.5 0.5 0';
@@ -515,22 +500,18 @@ void DrawCircleClippedPic(vector centre, float radi, string pic, float f, vector
                        v.x -= 0.5 * ringsize.x;        t -= '0.5 0.5 0';
                        R_PolygonVertex(v, t, rgb, a);
                R_EndPolygon();
+               // draw clipped lower half as a triangle
+               R_BeginPolygon(pic, drawflag, true);
+                       v = centre;                     t = '0.5 0.5 0';
+                       R_PolygonVertex(v, t, rgb, a);
 
-               d = q - 0.5;
-               if(d > 0)
-               {
-                       R_BeginPolygon(pic, drawflag, true);
-                               v = centre;                     t = '0.5 0.5 0';
-                               R_PolygonVertex(v, t, rgb, a);
-
-                               v = centre;                     t = '0.5 0.5 0';
-                               v.x -= 0.5 * ringsize.x;        t -= '0.5 0.5 0';
-                               R_PolygonVertex(v, t, rgb, a);
-               }
+                       v = centre;                     t = '0.5 0.5 0';
+                       v.x -= 0.5 * ringsize.x;        t -= '0.5 0.5 0';
+                       R_PolygonVertex(v, t, rgb, a);
        }
        else if(f > 0.25)
        {
-               // draw first triangle
+               // draw clipped lower half as a quad
                R_BeginPolygon(pic, drawflag, true);
                        v = centre;                     t = '0.5 0.5 0';
                        R_PolygonVertex(v, t, rgb, a);
@@ -542,34 +523,30 @@ void DrawCircleClippedPic(vector centre, float radi, string pic, float f, vector
                        v = centre;                     t = '0.5 0.5 0';
                        v.y += 0.5 * ringsize.y;        t += '0.5 -0.5 0';
                        R_PolygonVertex(v, t, rgb, a);
-
-               d = q - 0.25;
-               if(d <= 0)
-                       R_EndPolygon();
        }
-       else
+       else if (f > 0)
        {
-               d = q;
-               if(d > 0)
-               {
-                       R_BeginPolygon(pic, drawflag, true);
-                               v = centre;                     t = '0.5 0.5 0';
-                               R_PolygonVertex(v, t, rgb, a);
-
-                               v = centre;                     t = '0.5 0.5 0';
-                               v.x += 0.5 * ringsize.x;        t += '0.5 0.5 0';
-                               R_PolygonVertex(v, t, rgb, a);
-               }
-       }
+               // draw clipped lower half as a triangle
+               R_BeginPolygon(pic, drawflag, true);
+                       v = centre;                     t = '0.5 0.5 0';
+                       R_PolygonVertex(v, t, rgb, a);
 
-       if(d > 0)
-       {
                        v = centre;                     t = '0.5 0.5 0';
-                       v.x += co * 0.5 * ringsize.x;   t += co * '0.5 0.5 0';
-                       v.y += si * 0.5 * ringsize.y;   t += si * '0.5 -0.5 0';
+                       v.x += 0.5 * ringsize.x;        t += '0.5 0.5 0';
                        R_PolygonVertex(v, t, rgb, a);
-               R_EndPolygon();
        }
+       else
+       {
+               // Nothing to draw.
+               return;
+       }
+
+       // The last, moving vertex.
+               v = centre;                     t = '0.5 0.5 0';
+               v.x += co * 0.5 * ringsize.x;   t += co * '0.5 0.5 0';
+               v.y += si * 0.5 * ringsize.y;   t += si * '0.5 -0.5 0';
+               R_PolygonVertex(v, t, rgb, a);
+       R_EndPolygon();
 }
 
 /** engine callback */