]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/client/view.qc
Avoid a glitch when the HUD cursor gets (re)displayed
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / view.qc
index 8fba190c64bfb32db161be60402cbbda6e8db29b..e26f90894d7ce24f9df890eeeeca4223d3aa290c 100644 (file)
@@ -1357,20 +1357,21 @@ void HUD_Crosshair(entity this)
 
 #define CROSSHAIR_DO_BLUR(M,sz,wcross_name,wcross_alpha) \
                        MACRO_BEGIN { \
+                               vector scaled_sz = sz * wcross_size; \
                                if(wcross_blur > 0) \
                                { \
                                        for(i = -2; i <= 2; ++i) \
                                        for(j = -2; j <= 2; ++j) \
-                                       M(i,j,sz,wcross_name,wcross_alpha*0.04); \
+                                       M(i,j,sz,scaled_sz,wcross_name,wcross_alpha*0.04); \
                                } \
                                else \
                                { \
-                                       M(0,0,sz,wcross_name,wcross_alpha); \
+                                       M(0,0,sz,scaled_sz,wcross_name,wcross_alpha); \
                                } \
                        } MACRO_END
 
-#define CROSSHAIR_DRAW_SINGLE(i,j,sz,wcross_name,wcross_alpha) \
-                       drawpic(wcross_origin - ('0.5 0 0' * (sz * wcross_size.x + i * wcross_blur) + '0 0.5 0' * (sz * wcross_size.y + j * wcross_blur)), wcross_name, sz * wcross_size, wcross_color, wcross_alpha, DRAWFLAG_NORMAL)
+#define CROSSHAIR_DRAW_SINGLE(i,j,sz,scaled_sz,wcross_name,wcross_alpha) \
+                       drawpic(wcross_origin - ('0.5 0 0' * (scaled_sz.x + i * wcross_blur) + '0 0.5 0' * (scaled_sz.y + j * wcross_blur)), wcross_name, scaled_sz, wcross_color, wcross_alpha, DRAWFLAG_NORMAL)
 
 #define CROSSHAIR_DRAW(sz,wcross_name,wcross_alpha) \
                        CROSSHAIR_DO_BLUR(CROSSHAIR_DRAW_SINGLE,sz,wcross_name,wcross_alpha)
@@ -1591,6 +1592,15 @@ void HUD_Mouse(entity player)
                return;
        }
 
+       if (cursor_active == -1) // starting to display the cursor
+       {
+               // since HUD_Mouse is called by CSQC_UpdateView before CSQC_InputEvent,
+               // in the first frame mousepos is the mouse position of the last time
+               // the cursor was displayed, thus we ignore it to avoid a glictch
+               cursor_active = 1;
+               return;
+       }
+
        if(!autocvar_hud_cursormode)
                update_mousepos();
 
@@ -1946,10 +1956,7 @@ void CSQC_UpdateView(entity this, float w, float h)
        // Render the Scene
        view_origin = getpropertyvec(VF_ORIGIN);
        view_angles = getpropertyvec(VF_ANGLES);
-       makevectors(view_angles);
-       view_forward = v_forward;
-       view_right = v_right;
-       view_up = v_up;
+       MAKEVECTORS(makevectors, view_angles, view_forward, view_right, view_up);
 
 #ifdef BLURTEST
        if(time > blurtest_time0 && time < blurtest_time1)