Fix dashed line drawing
authorCampbell Barton <ideasman42@gmail.com>
Thu, 20 Jun 2019 22:24:58 +0000 (08:24 +1000)
committerCampbell Barton <ideasman42@gmail.com>
Thu, 20 Jun 2019 22:29:08 +0000 (08:29 +1000)
The dash_factor wasn't being set in many places, having the graph editor
open for eg, caused box-select in the 3D view not to show dashes.

source/blender/editors/interface/interface_draw.c
source/blender/editors/mask/mask_draw.c
source/blender/editors/sculpt_paint/paint_stroke.c
source/blender/editors/space_image/image_draw.c
source/blender/editors/space_view3d/view3d_gizmo_ruler.c
source/blender/editors/uvedit/uvedit_draw.c
source/blender/windowmanager/intern/wm_gesture.c

index 022c3b3cb519d93690bb939159598871618e7074..7afdbe9d26663a20678fb74f87301b6945330385 100644 (file)
@@ -1526,6 +1526,7 @@ static void ui_draw_colorband_handle(uint shdr_pos,
     immUniformArray4fv(
         "colors", (float *)(float[][4]){{0.8f, 0.8f, 0.8f, 1.0f}, {0.0f, 0.0f, 0.0f, 1.0f}}, 2);
     immUniform1f("dash_width", active ? 4.0f : 2.0f);
+    immUniform1f("dash_factor", 0.5f);
 
     immBegin(GPU_PRIM_LINES, 2);
     immVertex2f(shdr_pos, x, y1);
index d9ca58fa88ccdae5bbc90946dc7ec82ce12c9053..c00223a3c493d13b92cf08a3471ee2185fe8df3d 100644 (file)
@@ -500,6 +500,7 @@ static void mask_draw_curve_type(const bContext *C,
       immUniform1i("colors_len", 2); /* "advanced" mode */
       immUniformArray4fv("colors", colors, 2);
       immUniform1f("dash_width", 4.0f);
+      immUniform1f("dash_factor", 0.5f);
       GPU_line_width(1.0f);
 
       mask_draw_array(pos, draw_method, points, tot_point);
index 9a46dab8c207772e712c5538613b7b66760b7efe..12891484e7385c12ef365b625b22ccba10f2d880 100644 (file)
@@ -182,6 +182,7 @@ static void paint_draw_line_cursor(bContext *C, int x, int y, void *customdata)
   immUniformArray4fv(
       "colors", (float *)(float[][4]){{0.0f, 0.0f, 0.0f, alpha}, {1.0f, 1.0f, 1.0f, alpha}}, 2);
   immUniform1f("dash_width", 6.0f);
+  immUniform1f("dash_factor", 0.5f);
 
   immBegin(GPU_PRIM_LINES, 2);
 
index 9b57644b6ec207a46b78951b8cf9ddf78af03d68..86db6d50fcc68158ca8952ca0872b09a053e1dd3 100644 (file)
@@ -699,6 +699,7 @@ void draw_image_sample_line(SpaceImage *sima)
     immUniformArray4fv(
         "colors", (float *)(float[][4]){{1.0f, 1.0f, 1.0f, 1.0f}, {0.0f, 0.0f, 0.0f, 1.0f}}, 2);
     immUniform1f("dash_width", 2.0f);
+    immUniform1f("dash_factor", 0.5f);
 
     immBegin(GPU_PRIM_LINES, 2);
     immVertex2fv(shdr_dashed_pos, hist->co[0]);
index 566a15cc7b774ee857980cc5979d0e1613e37fe0..ebfd66008f7c371d774a759e6142a1beff940cb7 100644 (file)
@@ -563,6 +563,7 @@ static void gizmo_ruler_draw(const bContext *C, wmGizmo *gz)
         (float *)(float[][4]){{0.67f, 0.67f, 0.67f, 1.0f}, {col[0], col[1], col[2], col[3]}},
         2);
     immUniform1f("dash_width", 6.0f);
+    immUniform1f("dash_factor", 0.5f);
 
     immBegin(GPU_PRIM_LINE_STRIP, 3);
 
@@ -725,6 +726,7 @@ static void gizmo_ruler_draw(const bContext *C, wmGizmo *gz)
         (float *)(float[][4]){{0.67f, 0.67f, 0.67f, 1.0f}, {col[0], col[1], col[2], col[3]}},
         2);
     immUniform1f("dash_width", 6.0f);
+    immUniform1f("dash_factor", 0.5f);
 
     immBegin(GPU_PRIM_LINES, 2);
 
index fa2a7eb981221bdfcacdc45d4f562f4b50f52a20..b1d22e12b1022527146f4ae499bd819a870ddf1b 100644 (file)
@@ -117,6 +117,7 @@ void ED_image_draw_cursor(ARegion *ar, const float cursor[2])
   immUniformArray4fv(
       "colors", (float *)(float[][4]){{1.0f, 0.0f, 0.0f, 1.0f}, {1.0f, 1.0f, 1.0f, 1.0f}}, 2);
   immUniform1f("dash_width", 8.0f);
+  immUniform1f("dash_factor", 0.5f);
 
   immBegin(GPU_PRIM_LINES, 8);
 
@@ -137,6 +138,7 @@ void ED_image_draw_cursor(ARegion *ar, const float cursor[2])
   immUniformArray4fv(
       "colors", (float *)(float[][4]){{1.0f, 1.0f, 1.0f, 1.0f}, {0.0f, 0.0f, 0.0f, 1.0f}}, 2);
   immUniform1f("dash_width", 2.0f);
+  immUniform1f("dash_factor", 0.5f);
 
   immBegin(GPU_PRIM_LINES, 8);
 
@@ -360,6 +362,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit, Depsgraph *
             edges, "viewport_size", viewport_size[2] / UI_DPI_FAC, viewport_size[3] / UI_DPI_FAC);
         GPU_batch_uniform_1i(edges, "colors_len", 2); /* "advanced" mode */
         GPU_batch_uniform_1f(edges, "dash_width", 4.0f);
+        GPU_batch_uniform_1f(edges, "dash_factor", 0.5f);
         GPU_batch_draw(edges);
         break;
       }
index 11f9ef917fd33ea47713c72d45df53535a82749e..b79de4370d032a964c62273fbeaf5d02de7a3d54 100644 (file)
@@ -215,6 +215,7 @@ static void wm_gesture_draw_line(wmGesture *gt)
   immUniformArray4fv(
       "colors", (float *)(float[][4]){{0.4f, 0.4f, 0.4f, 1.0f}, {1.0f, 1.0f, 1.0f, 1.0f}}, 2);
   immUniform1f("dash_width", 8.0f);
+  immUniform1f("dash_factor", 0.5f);
 
   float xmin = (float)rect->xmin;
   float ymin = (float)rect->ymin;
@@ -257,6 +258,7 @@ static void wm_gesture_draw_rect(wmGesture *gt)
   immUniformArray4fv(
       "colors", (float *)(float[][4]){{0.4f, 0.4f, 0.4f, 1.0f}, {1.0f, 1.0f, 1.0f, 1.0f}}, 2);
   immUniform1f("dash_width", 8.0f);
+  immUniform1f("dash_factor", 0.5f);
 
   imm_draw_box_wire_2d(
       shdr_pos, (float)rect->xmin, (float)rect->ymin, (float)rect->xmax, (float)rect->ymax);
@@ -295,6 +297,7 @@ static void wm_gesture_draw_circle(wmGesture *gt)
   immUniformArray4fv(
       "colors", (float *)(float[][4]){{0.4f, 0.4f, 0.4f, 1.0f}, {1.0f, 1.0f, 1.0f, 1.0f}}, 2);
   immUniform1f("dash_width", 4.0f);
+  immUniform1f("dash_factor", 0.5f);
 
   imm_draw_circle_wire_2d(shdr_pos, (float)rect->xmin, (float)rect->ymin, (float)rect->xmax, 40);
 
@@ -418,6 +421,7 @@ static void wm_gesture_draw_lasso(wmGesture *gt, bool filled)
   immUniformArray4fv(
       "colors", (float *)(float[][4]){{0.4f, 0.4f, 0.4f, 1.0f}, {1.0f, 1.0f, 1.0f, 1.0f}}, 2);
   immUniform1f("dash_width", 2.0f);
+  immUniform1f("dash_factor", 0.5f);
 
   immBegin((gt->type == WM_GESTURE_LASSO) ? GPU_PRIM_LINE_LOOP : GPU_PRIM_LINE_STRIP, numverts);
 
@@ -451,6 +455,7 @@ static void wm_gesture_draw_cross(wmWindow *win, wmGesture *gt)
   immUniformArray4fv(
       "colors", (float *)(float[][4]){{0.4f, 0.4f, 0.4f, 1.0f}, {1.0f, 1.0f, 1.0f, 1.0f}}, 2);
   immUniform1f("dash_width", 8.0f);
+  immUniform1f("dash_factor", 0.5f);
 
   immBegin(GPU_PRIM_LINES, 4);