[Bf-blender-cvs] [e862abaf646] greasepencil-object: GPencil: Draw Edit Lines for 1 point strokes

Antonio Vazquez noreply at git.blender.org
Sun Nov 17 19:13:15 CET 2019


Commit: e862abaf6463f1c40450fc06a3d292d5fd1e09c0
Author: Antonio Vazquez
Date:   Sun Nov 17 19:12:58 2019 +0100
Branches: greasepencil-object
https://developer.blender.org/rBe862abaf6463f1c40450fc06a3d292d5fd1e09c0

GPencil: Draw Edit Lines for 1 point strokes

===================================================================

M	source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
M	source/blender/draw/engines/gpencil/gpencil_draw_utils.c

===================================================================

diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c b/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
index 90aa7428183..5db9e88a4c6 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
@@ -938,6 +938,7 @@ void gpencil_get_edlin_geom(struct GpencilBatchCacheElem *be,
   Object *ob = draw_ctx->obact;
   bGPdata *gpd = ob->data;
   const bool is_weight_paint = (gpd) && (gpd->flag & GP_DATA_STROKE_WEIGHTMODE);
+  const int fake_point = (gps->totpoints == 1) ? 1 : 0;
 
   int vgindex = ob->actdef - 1;
   if (!BLI_findlink(&ob->defbase, vgindex)) {
@@ -959,7 +960,7 @@ void gpencil_get_edlin_geom(struct GpencilBatchCacheElem *be,
     GPU_vertbuf_data_alloc(be->vbo, be->tot_vertex);
     be->vbo_len = 0;
   }
-  gpencil_vbo_ensure_size(be, gps->totpoints);
+  gpencil_vbo_ensure_size(be, gps->totpoints + fake_point);
 
   /* Draw all the stroke lines (selected or not) */
   bGPDspoint *pt = gps->points;
@@ -993,6 +994,15 @@ void gpencil_get_edlin_geom(struct GpencilBatchCacheElem *be,
       dvert++;
     }
   }
+  /* If only 1 point in the stroke, add a point moved slightly. */
+  if (fake_point > 0) {
+    float fpt[3];
+    pt = &gps->points[0];
+    mul_v3_v3fl(fpt, &pt->x, 1.001f);
+    GPU_vertbuf_attr_set(be->vbo, be->color_id, be->vbo_len, fcolor);
+    GPU_vertbuf_attr_set(be->vbo, be->pos_id, be->vbo_len, fpt);
+    be->vbo_len++;
+  }
 }
 
 static void set_grid_point(GPUVertBuf *vbo,
diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
index 537242a80a8..fb87189101a 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
@@ -1193,7 +1193,7 @@ static void gpencil_add_editpoints_vertexdata(GpencilBatchCache *cache,
 
     if (cache->is_dirty) {
       if ((obact == ob) && (is_overlay) && (v3d->gp_flag & V3D_GP_SHOW_EDIT_LINES) &&
-          (gps->totpoints > 1) && (!hide_vertex_lines)) {
+          (!hide_vertex_lines)) {
         /* line of the original stroke */
         gpencil_get_edlin_geom(&cache->b_edlin, gps, edit_alpha, hide_select);



More information about the Bf-blender-cvs mailing list