]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/client/View.qc
Merge remote branch 'origin/fruitiex/precache_crosshair_ring'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / View.qc
index be554c4f7eb1165099606307a66f71c23fe410db..9953af664b7b4db76233623bfa69a9c8d2aa166c 100644 (file)
@@ -698,149 +698,22 @@ void CSQC_UpdateView(float w, float h)
                                CSQC_common_hud();
 
 
+               precache_pic("gfx/nex_ring.tga");
                // ring around crosshair representing velocity-dependent damage for the nex
                if (activeweapon == WEP_NEX)
                {
-                       float x, y, x0, y0, q, d;
-                       vector ringorigin, ringsize, t;
-                       ringorigin = '0.5 0 0' * vid_conwidth + '0 0.5 0' * vid_conheight;
-                       ringsize = 64 * '1 1 0'; // testing only
-
-                       // TODO send from server
-                       float maxvel, minvel, curvel;
-                       minvel = 400;
-                       maxvel = 1000;
-                       curvel = vlen(pmove_vel);
-
-                       f = bound(0, (curvel - minvel) / (maxvel - minvel), 1);
-                       x = cos(f * 2 * M_PI);
-                       y = sin(f * 2 * M_PI);
-                       q = fabs(x) + fabs(y);
-                       x /= q;
-                       y /= q;
-
-                       if(f >= 1)
-                       {
-                               // draw full rectangle
-                               R_BeginPolygon("gfx/nex_ring.tga", DRAWFLAG_ADDITIVE);
-                                       v = ringorigin;                 t = '0.5 0.5 0';
-                                       v_x += 0.5 * ringsize_x;        t += '0.5 0.5 0';
-                                       R_PolygonVertex(v, t, '1 1 1', 1);
-
-                                       v = ringorigin;                 t = '0.5 0.5 0';
-                                       v_y += 0.5 * ringsize_y;        t += '0.5 -0.5 0';
-                                       R_PolygonVertex(v, t, '1 1 1', 1);
-
-                                       v = ringorigin;                 t = '0.5 0.5 0';
-                                       v_x -= 0.5 * ringsize_y;        t -= '0.5 0.5 0';
-                                       R_PolygonVertex(v, t, '1 1 1', 1);
-
-                                       v = ringorigin;                 t = '0.5 0.5 0';
-                                       v_y -= 0.5 * ringsize_y;        t -= '0.5 -0.5 0';
-                                       R_PolygonVertex(v, t, '1 1 1', 1);
-                               R_EndPolygon();
-
-                               x0 = 1;
-                               y0 = 0;
-                               d = q - 1;
-                       }
-                       else if(f > 0.75)
-                       {
-                               // draw upper and first triangle
-                               R_BeginPolygon("gfx/nex_ring.tga", DRAWFLAG_ADDITIVE);
-                                       v = ringorigin;                 t = '0.5 0.5 0';
-                                       v_x += 0.5 * ringsize_x;        t += '0.5 0.5 0';
-                                       R_PolygonVertex(v, t, '1 1 1', 1);
-
-                                       v = ringorigin;                 t = '0.5 0.5 0';
-                                       v_y += 0.5 * ringsize_y;        t += '0.5 -0.5 0';
-                                       R_PolygonVertex(v, t, '1 1 1', 1);
-
-                                       v = ringorigin;                 t = '0.5 0.5 0';
-                                       v_x -= 0.5 * ringsize_y;        t -= '0.5 0.5 0';
-                                       R_PolygonVertex(v, t, '1 1 1', 1);
-                               R_EndPolygon();
-                               R_BeginPolygon("gfx/nex_ring.tga", DRAWFLAG_ADDITIVE);
-                                       v = ringorigin;                 t = '0.5 0.5 0';
-                                       R_PolygonVertex(v, t, '1 1 1', 1);
-
-                                       v = ringorigin;                 t = '0.5 0.5 0';
-                                       v_x -= 0.5 * ringsize_y;        t -= '0.5 0.5 0';
-                                       R_PolygonVertex(v, t, '1 1 1', 1);
-
-                                       v = ringorigin;                 t = '0.5 0.5 0';
-                                       v_y -= 0.5 * ringsize_y;        t -= '0.5 -0.5 0';
-                                       R_PolygonVertex(v, t, '1 1 1', 1);
-                               R_EndPolygon();
-
-                               x0 = 0;
-                               y0 = -1;
-                               d = q - 0.75;
-                       }
-                       else if(f > 0.5)
-                       {
-                               // draw upper triangle
-                               R_BeginPolygon("gfx/nex_ring.tga", DRAWFLAG_ADDITIVE);
-                                       v = ringorigin;                 t = '0.5 0.5 0';
-                                       v_x += 0.5 * ringsize_x;        t += '0.5 0.5 0';
-                                       R_PolygonVertex(v, t, '1 1 1', 1);
-
-                                       v = ringorigin;                 t = '0.5 0.5 0';
-                                       v_y += 0.5 * ringsize_y;        t += '0.5 -0.5 0';
-                                       R_PolygonVertex(v, t, '1 1 1', 1);
-
-                                       v = ringorigin;                 t = '0.5 0.5 0';
-                                       v_x -= 0.5 * ringsize_y;        t -= '0.5 0.5 0';
-                                       R_PolygonVertex(v, t, '1 1 1', 1);
-                               R_EndPolygon();
-
-                               x0 = -1;
-                               y0 = 0;
-                               d = q - 0.5;
-                       }
-                       else if(f > 0.25)
-                       {
-                               // draw first triangle
-                               R_BeginPolygon("gfx/nex_ring.tga", DRAWFLAG_ADDITIVE);
-                                       v = ringorigin;                 t = '0.5 0.5 0';
-                                       R_PolygonVertex(v, t, '1 1 1', 1);
-
-                                       v = ringorigin;                 t = '0.5 0.5 0';
-                                       v_x += 0.5 * ringsize_y;        t += '0.5 0.5 0';
-                                       R_PolygonVertex(v, t, '1 1 1', 1);
-
-                                       v = ringorigin;                 t = '0.5 0.5 0';
-                                       v_y += 0.5 * ringsize_y;        t += '0.5 -0.5 0';
-                                       R_PolygonVertex(v, t, '1 1 1', 1);
-                               R_EndPolygon();
-
-                               x0 = 0;
-                               y0 = 1;
-                               d = q - 0.25;
-                       }
-                       else
-                       {
-                               x0 = 1;
-                               y0 = 0;
-                       }
+                       float f, a, curvel;
+                       vector rgb;
 
-                       if(d >= 0)
-                       {
-                               R_BeginPolygon("gfx/nex_ring.tga", DRAWFLAG_ADDITIVE);
-                               v = ringorigin;                 t = '0.5 0.5 0';
-                               R_PolygonVertex(v, t, '1 1 1', 1);
-
-                               v = ringorigin;                 t = '0.5 0.5 0';
-                               v_x += x0 * 0.5 * ringsize_x;   t += x0 * '0.5 0.5 0';
-                               v_y += y0 * 0.5 * ringsize_x;   t += y0 * '0.5 -0.5 0';
-                               R_PolygonVertex(v, t, '1 1 1', 1);
-
-                               v = ringorigin;                 t = '0.5 0.5 0';
-                               v_x += x * 0.5 * ringsize_x;    t += x * '0.5 0.5 0';
-                               v_y += y * 0.5 * ringsize_y;    t += y * '0.5 -0.5 0';
-                               R_PolygonVertex(v, t, '1 1 1', 1);
-                               R_EndPolygon();
-                       }
+                       rgb_x = cvar("crosshair_nexvelocity_color_red");
+                       rgb_y = cvar("crosshair_nexvelocity_color_green");
+                       rgb_z = cvar("crosshair_nexvelocity_color_blue");
+                       a = cvar("crosshair_nexvelocity_alpha");
+
+                       curvel = vlen('1 0 0' * pmove_vel_x + '0 1 0' * pmove_vel_y);
+                       f = bound(0, (curvel - nex_minvelocity) / (nex_maxvelocity - nex_minvelocity), 1);
+
+                       DrawCircleClippedPic('0.5 0 0' * vid_conwidth + '0 0.5 0' * vid_conheight, 0.1 * vid_conheight, "gfx/nex_ring.tga", f, rgb, a, DRAWFLAG_ADDITIVE);
                }
 
                // crosshair goes VERY LAST
@@ -1021,7 +894,12 @@ void CSQC_UpdateView(float w, float h)
                                {
                                        CROSSHAIR_DO_BLUR(CROSSHAIR_DRAW_RING, wcross_resolution, wcross_name, wcross_alpha);
                                }
+
                                CROSSHAIR_DRAW(wcross_resolution, wcross_name, wcross_alpha * f);
+
+                               if(cvar("crosshair_dot"))
+                                       CROSSHAIR_DRAW(wcross_resolution * cvar("crosshair_dot_size"), "gfx/crosshairdot.tga", wcross_alpha * f * cvar("crosshair_dot_alpha"));
+
                                wcross_name_alpha_goal_prev = f;
                        }
                }